/* Layout: one painted scene, the story's words set low on the left over the Giant's shadow,
   spring light falling in from the right. */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("assets/fonts/cormorant.woff2") format("woff2");
  font-weight: 300 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("assets/fonts/cormorant-italic.woff2") format("woff2");
  font-weight: 300 700; font-style: italic; font-display: swap;
}

:root {
  --night: #0f1d24;          /* the Giant's winter shadow */
  --moss: #2c4a3c;
  --parchment: #fbf3e1;      /* the light on the right of the painting */
  --petal: #f2a3b3;
  --blossom: #e7718c;
  --gold: #f5d58a;
  --ink-soft: rgba(251, 243, 225, 0.82);
  --serif: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--night);
  color: var(--parchment);
  font-family: var(--serif);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- the painting ---------- */
.scene { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.scene picture, .bg {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none;
}
.bg {
  object-fit: cover;
  object-position: 58% 40%;
  transform-origin: 66% 55%;
  animation: breathe 38s ease-in-out infinite alternate;
  filter: saturate(1.05);
}
@keyframes breathe {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to   { transform: scale(1.13) translate3d(-1.2%, -0.8%, 0); }
}
/* a slow pulse of spring light where the girl swings */
.glow {
  position: absolute; inset: 0;
  background: radial-gradient(42% 52% at 72% 52%, rgba(255, 244, 214, 0.55), rgba(255, 244, 214, 0) 70%);
  mix-blend-mode: screen;
  animation: glow 9s ease-in-out infinite alternate;
}
@keyframes breathe-sm {
  from { transform: scale(1.02); }
  to   { transform: scale(1.07) translate3d(-1.5%, 0, 0); }
}
@keyframes glow { from { opacity: 0.35; } to { opacity: 0.85; } }
.veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(10, 22, 28, 0.78) 0%, rgba(10, 22, 28, 0.45) 34%, rgba(10, 22, 28, 0) 62%),
    linear-gradient(0deg, rgba(10, 22, 28, 0.82) 0%, rgba(10, 22, 28, 0.25) 38%, rgba(10, 22, 28, 0) 60%);
}
#petals { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- words ---------- */
.stage {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: clamp(20px, 3vh, 36px);
  padding-block: clamp(32px, 8vh, 96px) clamp(56px, 10vh, 110px);
  padding-left: max(clamp(20px, 7vw, 120px), env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  max-width: 900px;
}
.hero { display: flex; flex-direction: column; gap: clamp(10px, 1.6vh, 18px); }
.eyebrow {
  margin: 0;
  font-size: clamp(14px, 1.4vw, 18px);
  letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--gold);
  opacity: 0; animation: rise 1.6s 0.2s cubic-bezier(.2,.7,.2,1) forwards;
}
.title {
  margin: 0;
  font-weight: 500; font-style: italic;
  font-size: clamp(54px, 10.5vw, 148px);
  line-height: 0.88;
  letter-spacing: -0.01em;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(255, 226, 180, 0.28), 0 1px 2px rgba(0,0,0,0.4);
}
.title span { display: inline-block; opacity: 0; filter: blur(14px); animation: unveil 2.2s cubic-bezier(.2,.7,.2,1) forwards; }
.title span:first-child { animation-delay: 0.45s; }
.title span:last-child { animation-delay: 0.95s; color: #ffe9d6; }
.lede {
  margin: 0; max-width: 32ch;
  font-size: clamp(20px, 2.1vw, 28px);
  line-height: 1.35; font-weight: 500;
  color: var(--ink-soft);
  opacity: 0; animation: rise 1.8s 1.5s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes unveil { to { opacity: 1; filter: blur(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.actions {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: clamp(8px, 1.6vh, 18px);
  opacity: 0; animation: rise 1.6s 2s cubic-bezier(.2,.7,.2,1) forwards;
}
.btn {
  font-family: var(--serif); font-size: clamp(20px, 1.9vw, 26px); font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.5em 1.7em; border-radius: 999px;
  cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s, background .35s, color .35s;
}
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.btn-ghost {
  color: var(--parchment);
  background: rgba(251, 243, 225, 0.08);
  border: 1px solid rgba(251, 243, 225, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.btn-ghost:hover, .btn-ghost[aria-expanded="true"] { background: rgba(251, 243, 225, 0.2); }
.btn-bloom {
  color: #3a1420;
  background: linear-gradient(135deg, #ffd9c2, var(--petal) 55%, var(--blossom));
  border: 1px solid rgba(255, 230, 210, 0.9);
  box-shadow: 0 8px 34px rgba(231, 113, 140, 0.45), inset 0 1px 0 rgba(255,255,255,0.6);
}
.btn:hover { transform: translateY(-2px); }
.btn-bloom:hover { box-shadow: 0 12px 44px rgba(231, 113, 140, 0.65), inset 0 1px 0 rgba(255,255,255,0.6); }

/* ---------- summary ---------- */
.summary[hidden] { display: none; }
.summary {
  max-width: 62ch;
  display: flex; flex-direction: column; gap: 0.9em;
  padding: clamp(20px, 3vw, 34px) clamp(22px, 3.2vw, 40px);
  border-radius: 6px 28px 6px 28px;
  background: linear-gradient(160deg, rgba(14, 30, 36, 0.62), rgba(14, 30, 36, 0.48));
  border: 1px solid rgba(251, 243, 225, 0.28);
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.summary p {
  margin: 0;
  font-size: clamp(19px, 1.8vw, 24px); line-height: 1.5; font-weight: 500;
  color: var(--parchment);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.summary p:first-child::first-letter {
  float: left; font-style: italic; font-size: 3.3em; line-height: 0.8;
  padding: 0.06em 0.12em 0 0; color: var(--gold);
}
.summary.open p { animation: rise 1.1s cubic-bezier(.2,.7,.2,1) both; }
.summary.open p:nth-child(2) { animation-delay: 0.35s; }
.summary.open p:nth-child(3) { animation-delay: 0.7s; }

.foot {
  position: fixed; z-index: 1;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  font-size: 15px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(58, 40, 30, 0.6);
}

@media (max-width: 700px) {
  .bg { object-position: 66% 50%; animation-name: breathe-sm; }
  .veil {
    background: linear-gradient(0deg, rgba(10, 22, 28, 0.92) 0%, rgba(10, 22, 28, 0.72) 42%, rgba(10, 22, 28, 0.15) 70%, rgba(10, 22, 28, 0.35) 100%);
  }
  .foot { position: relative; right: auto; bottom: auto; text-align: center; padding: 0 0 18px; color: rgba(251,243,225,0.5); }
  .stage { padding-bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg, .glow { animation: none; }
  .title span, .eyebrow, .lede, .actions, .summary.open p { animation: none; opacity: 1; filter: none; }
}

/* ---------- Història: full-screen painted chapters ---------- */
.actions .btn { flex: 0 0 auto; }
.story {
  position: fixed; inset: 0; z-index: 20;
  background: var(--night);
  overflow: hidden;
  animation: storyIn .9s ease both;
}
.story[hidden] { display: none; }
@keyframes storyIn { from { opacity: 0; } to { opacity: 1; } }
.slides { position: absolute; inset: 0; }
.slide {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transition: opacity 1.4s ease, visibility 0s linear 1.4s;
}
.slide.active { opacity: 1; visibility: visible; transition: opacity 1.4s ease, visibility 0s; }
.slide img {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none;
  object-fit: cover;
  transform: scale(1.03);
}
.slide.active img { animation: drift 26s ease-out forwards; }
@keyframes drift { from { transform: scale(1.03); } to { transform: scale(1.12) translate3d(-1%, -0.6%, 0); } }
.slide::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(8, 18, 24, 0.55) 0%, rgba(8, 18, 24, 0.25) 32%, rgba(8, 18, 24, 0) 55%),
    linear-gradient(0deg, rgba(8, 18, 24, 0.86) 0%, rgba(8, 18, 24, 0.35) 34%, rgba(8, 18, 24, 0) 58%);
}
.card {
  position: absolute; z-index: 2;
  left: max(clamp(20px, 6vw, 96px), env(safe-area-inset-left, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(clamp(84px, 12vh, 120px) + env(safe-area-inset-bottom, 0px));
  max-width: 60ch;
  display: flex; flex-direction: column; gap: 0.45em; align-items: flex-start;
}
.card .chapter {
  margin: 0; font-size: clamp(14px, 1.3vw, 17px);
  letter-spacing: 0.38em; text-transform: uppercase; color: var(--gold);
}
.card h2 {
  margin: 0; font-style: italic; font-weight: 500;
  font-size: clamp(40px, 6vw, 84px); line-height: 0.95;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
}
.card p:not(.chapter) {
  margin: 0.3em 0 0; font-size: clamp(19px, 1.85vw, 26px); line-height: 1.45; font-weight: 500;
  color: var(--parchment);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 22px rgba(0, 0, 0, 0.35);
}
.slide.active .card > * { animation: rise 1.3s cubic-bezier(.2,.7,.2,1) both; }
.slide.active .card > :nth-child(1) { animation-delay: .5s; }
.slide.active .card > :nth-child(2) { animation-delay: .75s; }
.slide.active .card > :nth-child(3) { animation-delay: 1.1s; }
.slide.active .card > :nth-child(4) { animation-delay: 1.6s; }
.btn-small { font-size: clamp(17px, 1.5vw, 21px); padding: 0.4em 1.3em; margin-top: 0.6em; }
#storyFx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--serif); font-size: 30px; line-height: 1;
  color: var(--parchment); cursor: pointer;
  background: rgba(15, 29, 36, 0.35);
  border: 1px solid rgba(251, 243, 225, 0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background .3s, transform .3s, opacity .3s;
}
.icon-btn:hover { background: rgba(251, 243, 225, 0.18); }
.icon-btn:disabled { opacity: 0.25; cursor: default; }
.icon-btn:focus-visible, .dots button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.close {
  position: absolute; z-index: 3; font-size: 22px;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
}
.story-bar {
  position: absolute; z-index: 3;
  left: max(clamp(20px, 6vw, 96px), env(safe-area-inset-left, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(clamp(18px, 3vh, 34px) + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.dots { display: flex; gap: 10px; align-items: center; }
.dots button {
  width: 10px; height: 10px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(251, 243, 225, 0.7); background: transparent;
  transition: width .5s cubic-bezier(.2,.7,.2,1), background .5s;
}
.dots button[aria-current="true"] { width: 34px; background: var(--gold); border-color: var(--gold); }
.audio { margin: 0 0 0 auto; display: inline-flex; gap: 0.4em; align-items: center; }
.audio[hidden] { display: none; }
.audio .ico { font-size: 0.8em; }

@media (max-width: 700px) {
  .slide::after { background: linear-gradient(0deg, rgba(8, 18, 24, 0.93) 0%, rgba(8, 18, 24, 0.7) 42%, rgba(8, 18, 24, 0.1) 68%); }
  .card { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .icon-btn { width: 46px; height: 46px; }
  .actions { gap: 10px; }
  .actions .btn { padding: 0.45em 0.95em; font-size: 19px; letter-spacing: 0.03em; }
}
@media (prefers-reduced-motion: reduce) {
  .slide.active img, .slide.active .card > *, .story { animation: none; }
  .slide, .slide.active { transition: none; }
}
