/* ------------------------------------------------------------------ *
   The Next Step - a Living Oracle
   Sacred Camino theme.

   Every colour below was sampled out of Yanik's actual markers rather than
   picked by eye, which is why the yellow is a deep ochre and not a lemon:
   that is the pen he drew the Buen Camino arrow with.
 * ------------------------------------------------------------------ */

:root {
  --paper:        #f8f3e8;
  --paper-deep:   #f0e8d8;
  --paper-edge:   #e4d9c3;
  --ink:          #2a2621;   /* soft charcoal, warm */
  --ink-soft:     #6d6559;
  --yellow:       #c6b123;   /* his arrow, measured */
  --yellow-lift:  #e0bc2b;   /* same hue, lifted for interactive contrast */
  --blue:         #16215e;   /* his shell tile, measured */
  --blue-soft:    #3b4680;
  --purple:       #241444;   /* his title pen */
  --gold:         #a8872f;

  --serif: "Cormorant Garamond", ui-serif, Georgia, "Iowan Old Style", serif;
  --hand:  "Caveat", "Bradley Hand", cursive;
  --sans:  ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;

  --read: 34rem;             /* comfortable measure for scripture */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  /* warm journal paper: two soft pools of light, then a fine grain on top.
     Kept very low contrast, because the brief asks for paper, not parchment. */
  background-image:
    radial-gradient(120% 80% at 50% -10%, #fffdf7 0%, rgba(255,253,247,0) 60%),
    radial-gradient(90% 60% at 50% 115%, var(--paper-deep) 0%, rgba(240,232,216,0) 65%);
  background-attachment: fixed;
}

body::after {                 /* paper grain */
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* keep real content above the grain */
#oracle, .page, #preview-banner { position: relative; z-index: 1; }

/* ---------------------------------------------------- view switching */
/* Visibility is driven entirely by the hidden attribute, set in one place by
   setView(). An earlier version also had display rules keyed off data-view,
   and the two disagreed: the attribute won and the revelation never appeared. */
[hidden] { display: none !important; }

#preview-banner {
  background: var(--purple); color: #f6eccf;
  font-family: var(--sans); font-size: 12px; letter-spacing: .06em;
  text-align: center; padding: 7px 14px;
}

/* ----------------------------------------------------------- layout */
.screen, .page {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(28px, 7vw, 64px) clamp(20px, 6vw, 40px) 90px;
}

/* ---------------------------------------------------------- arrival */
#arrival { text-align: center; }

.eyebrow {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .34em; text-transform: uppercase;
  color: var(--blue-soft); margin: 0 0 clamp(20px, 5vw, 34px);
}

.marker {
  width: min(58vw, 236px); height: auto; display: block; margin: 0 auto;
  /* the drawing is ink on paper; a faint shadow keeps it from floating */
  filter: drop-shadow(0 6px 14px rgba(42,38,33,.13));
  animation: settle 1.5s cubic-bezier(.2,.7,.3,1) both;
}

.invite {
  font-family: var(--hand); font-size: clamp(25px, 6vw, 31px);
  color: var(--blue); margin: clamp(22px, 5vw, 32px) 0 0;
  animation: rise .9s .5s cubic-bezier(.2,.7,.3,1) both;
}

.begin {
  margin-top: clamp(22px, 5vw, 30px);
  display: inline-flex; align-items: center; gap: 13px;
  background: none; border: 0; cursor: pointer; padding: 12px 10px;
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: .26em; text-transform: uppercase; color: var(--ink);
  animation: rise .9s .85s cubic-bezier(.2,.7,.3,1) both;
}
.begin img { width: 54px; height: auto; transition: transform .45s cubic-bezier(.2,.7,.3,1); }
.begin:hover img, .begin:focus-visible img { transform: translateX(7px); }

/* -------------------------------------------------- 1. THE WORD */
.stage { text-align: center; }

.scripture {
  font-size: clamp(21px, 4.6vw, 27px);
  line-height: 1.68;
  max-width: var(--read);
  margin: 0 auto;
  color: var(--ink);
  text-wrap: pretty;
}

/* Each word is its own element so it can be revealed in turn. The look is
   ink arriving on paper: a little below its place, soft, slightly spread,
   coming into focus. Deliberately not a typewriter, which the brief rules out. */
.scripture .w {
  display: inline-block;
  opacity: 0;
  filter: blur(7px);
  transform: translateY(.3em);
  animation: ink var(--ink-dur, 1.1s) var(--d, 0s) cubic-bezier(.22,.7,.28,1) forwards;
}
@keyframes ink {
  60%  { filter: blur(1.4px); }
  100% { opacity: 1; filter: blur(0); transform: none; }
}

.reference {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .28em; text-transform: uppercase;
  color: var(--blue-soft);
  margin: clamp(20px, 4vw, 28px) 0 0;
  opacity: 0;
}
.reference.in { animation: rise .9s cubic-bezier(.2,.7,.3,1) forwards; }

/* the old draw clears before the new one arrives */
#revelation { transition: opacity .4s ease; }
#revelation.fading { opacity: 0; }

/* ------------------------------------------------ 2. THE MEMORY */
.polaroid {
  --tilt: -2deg;
  width: min(74vw, 272px);
  margin: clamp(34px, 8vw, 54px) auto 0;
  padding: 11px 11px 0;
  background: #fdfaf2;
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset,
              0 14px 30px -10px rgba(42,38,33,.34),
              0 3px 8px rgba(42,38,33,.12);
  transform: rotate(var(--tilt));
  opacity: 0;
}
.polaroid.in { animation: develop 1.5s cubic-bezier(.2,.7,.3,1) forwards; }

.polaroid .shot {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--paper-edge);
}
.polaroid img { width: 100%; height: 100%; object-fit: cover; display: block;
  /* aged instant film: warm, a touch flat, slightly lifted blacks */
  filter: sepia(.16) saturate(.86) contrast(.94) brightness(1.04); }

/* the faint bloom instant film gets at its edges */
.polaroid .shot::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(110% 80% at 50% 40%, rgba(255,245,220,0) 55%, rgba(120,95,50,.17) 100%);
}

.polaroid figcaption {
  font-family: var(--hand); font-size: 19px; line-height: 1.25;
  color: #4a4135; text-align: center;
  min-height: 54px; padding: 11px 8px 14px;
  transform: rotate(-.6deg);
}

@keyframes develop {
  from { opacity: 0; transform: rotate(var(--tilt)) translateY(16px) scale(.975); }
  to   { opacity: 1; transform: rotate(var(--tilt)); }
}

/* ------------------------------------------------- 3. THE VOICE */
.voice { text-align: center; margin-top: clamp(32px, 7vw, 50px); position: relative; }

.voice .point {
  width: 62px; height: auto; display: block; margin: 0 auto 10px;
  opacity: 0;
}
.voice.in .point { animation: nudge 1.1s cubic-bezier(.2,.7,.3,1) forwards; }

.hear {
  display: inline-flex; align-items: center; gap: 11px;
  padding: 15px 27px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 700;
  letter-spacing: .17em; text-transform: uppercase;
  color: #2d2403;
  background: var(--yellow-lift);
  border: 2px solid #9c8615;
  /* uneven corners so the button belongs with hand-drawn art */
  border-radius: 19px 15px 20px 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 -1px rgba(120,100,16,.3);
  opacity: 0;
  transition: transform .18s, box-shadow .18s;
}
.voice.in .hear { animation: rise .8s .35s cubic-bezier(.2,.7,.3,1) forwards; }
.hear:active { transform: translateY(3px); box-shadow: 0 2px 0 -1px rgba(120,100,16,.3); }
.hear .sun { font-size: 16px; }

.playing { max-width: 19rem; margin: 20px auto 0; }
/* once the clip has finished the bar has nothing left to say, and a full-width
   line across the page reads as a divider rather than as progress */
.voice.done .point, .voice.done .bar { display: none; }
.voice.done .voice-title { font-size: 17px; opacity: .75; }
.playing .bar { height: 3px; background: var(--paper-edge); border-radius: 2px; overflow: hidden; }
.playing .bar i { display: block; height: 100%; width: 0; background: var(--yellow); }
.voice-title {
  font-family: var(--hand); font-size: 20px; color: var(--ink-soft);
  margin: 10px 0 0;
}

/* -------------------------------------------- 4. THE COMPLETION */
.completion { text-align: center; margin-top: clamp(40px, 9vw, 66px); }

/* His "each step brings you closer to greater illumination" drawing opens the
   completion. An earlier version floated it behind the buttons as a watermark,
   where the stamp landed squarely on top of "Receive another" and the whole
   thing read as a mistake. It is a drawing, so it gets its own room. */
.completion .rays {
  display: block; width: min(52vw, 184px); height: auto;
  margin: 0 auto clamp(14px, 3vw, 20px);
  opacity: 0;
}
.completion.in .rays { animation: glow 2.1s cubic-bezier(.2,.7,.3,1) forwards; }

.completion h2 {
  font-size: clamp(27px, 6.6vw, 40px); font-weight: 500;
  line-height: 1.22; color: var(--blue);
  margin: 0 0 clamp(24px, 5vw, 34px);
  opacity: 0;
}
.completion h2 em { font-family: var(--hand); font-style: normal;
  font-size: 1.22em; color: var(--purple); }
.completion.in h2 { animation: rise 1s .35s cubic-bezier(.2,.7,.3,1) forwards; }

.actions {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  opacity: 0;
}
.completion.in .actions { animation: rise 1s .6s cubic-bezier(.2,.7,.3,1) forwards; }

.action {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: .15em; text-transform: uppercase;
  padding: 13px 21px; cursor: pointer;
  border-radius: 15px 12px 16px 11px;
  display: inline-flex; align-items: center; gap: 11px;
}
.action.ghost { background: transparent; border: 1.6px solid var(--paper-edge); color: var(--ink-soft); }
.action.ghost:hover { border-color: var(--gold); color: var(--ink); }
/* Receive Another IS the arrow. Squeezed into a 46px slot beside a text label
   the BUEN CAMINO lettering inside it turned to mush, which is a poor way to
   treat the drawing the whole identity rests on. Given its own room it reads. */
.again {
  background: none; border: 0; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.again img {
  width: min(62vw, 232px); height: auto; display: block;
  transition: transform .5s cubic-bezier(.2,.7,.3,1);
}
.again span {
  font-family: var(--sans); font-size: 11.5px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; color: var(--blue);
}
.again:hover img, .again:focus-visible img { transform: translateX(9px); }

.completion .path {
  display: block; width: min(86%, 400px); margin: clamp(38px, 8vw, 58px) auto 0;
  opacity: 0;
}
.completion.in .path { animation: draw 1.4s .9s ease-out forwards; }

/* ------------------------------------------------------- gateways */
.gateways {
  display: flex; flex-wrap: wrap; gap: clamp(8px, 3vw, 30px);
  justify-content: center; margin-top: clamp(22px, 5vw, 32px);
  opacity: 0;
}
.completion.in .gateways { animation: rise 1s 1.15s cubic-bezier(.2,.7,.3,1) forwards; }

.gate {
  background: none; border: 0; cursor: pointer; padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 6.2rem; color: var(--blue);
}
.gate img, .gate svg { width: 48px; height: 48px; object-fit: contain; }
.gate svg { color: #b4472f; }      /* a red pen, as a heart would be drawn */
.gate span {
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-soft);
  line-height: 1.35;
}
.gate:hover img, .gate:hover svg { transform: translateY(-3px); }
.gate img, .gate svg { transition: transform .35s cubic-bezier(.2,.7,.3,1); }

.completion .closer {
  display: block; width: min(56vw, 198px); height: auto;
  margin: clamp(34px, 8vw, 52px) auto 0;
  opacity: 0;
}
.completion.in .closer { animation: fadeTo 1.4s 1.5s ease-out forwards; }

/* ---------------------------------------------------- inner pages */
.page-head { text-align: center; margin-bottom: clamp(26px, 6vw, 40px); }
.page-head h1 {
  font-size: clamp(29px, 7vw, 42px); font-weight: 500; color: var(--blue);
  margin: 16px 0 8px;
}
.lede { color: var(--ink-soft); margin: 0; font-size: 17px; }

.back {
  background: none; border: 0; cursor: pointer; padding: 8px 2px;
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft);
  float: left;
}
.back:hover { color: var(--blue); }

.list { display: flex; flex-direction: column; gap: 18px; }

.reflection {
  background: #fdfaf3;
  border: 1px solid var(--paper-edge);
  border-left: 3px solid var(--yellow);
  border-radius: 4px 12px 12px 4px;
  padding: clamp(18px, 4vw, 26px);
  box-shadow: 0 2px 10px -4px rgba(42,38,33,.14);
}
.reflection h2 {
  font-size: 22px; font-weight: 600; color: var(--blue); margin: 0 0 4px;
}
.reflection .ref {
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase; color: var(--gold);
  margin: 0 0 14px;
}
.reflection blockquote {
  margin: 0 0 14px; font-size: 19px; line-height: 1.62; color: var(--ink);
  font-style: italic;
}
.reflection .summary { font-size: 16px; color: var(--ink-soft); margin: 0 0 16px; }

.play {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--sans); font-size: 11.5px; font-weight: 700;
  letter-spacing: .15em; text-transform: uppercase;
  padding: 11px 19px; cursor: pointer; color: #2d2403;
  background: var(--yellow-lift); border: 2px solid #9c8615;
  border-radius: 16px 12px 17px 11px;
}
.play[data-state="playing"] { background: var(--paper-deep); color: var(--ink-soft); border-color: var(--paper-edge); }

/* ------------------------------------------------------ memories */
.grid {
  display: grid; gap: clamp(16px, 4vw, 26px);
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
}
.grid .polaroid { width: 100%; margin: 0; opacity: 1; animation: none; }
.grid .polaroid figcaption { min-height: 0; font-size: 17px; padding: 9px 6px 12px; }

.empty {
  text-align: center; color: var(--ink-soft); font-size: 17px;
  max-width: 28rem; margin: 30px auto 0; line-height: 1.7;
}

.flag {
  display: block; text-align: center; margin: 0 auto 22px;
  font-family: var(--sans); font-size: 11px; letter-spacing: .1em;
  color: #8a5a2b; background: #f6ead3; border: 1px solid #e3cfa6;
  border-radius: 7px; padding: 8px 14px; max-width: 32rem;
}

/* ------------------------------------------------------- motion */
@keyframes rise   { from { opacity: 0; transform: translateY(13px); } to { opacity: 1; transform: none; } }
@keyframes settle { from { opacity: 0; transform: translateY(-9px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes nudge  { from { opacity: 0; transform: translateX(-16px); } to { opacity: .95; transform: none; } }
@keyframes glow   { from { opacity: 0; transform: scale(.9); } to { opacity: .92; transform: none; } }
@keyframes fadeTo { from { opacity: 0; } to { opacity: .8; } }
@keyframes draw   { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: .55; clip-path: inset(0 0 0 0); } }

/* Respect the system setting: everything arrives, nothing travels. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  .scripture .w, .reference, .polaroid, .voice .point, .hear,
  .completion h2, .completion .actions, .completion .path, .completion .gateways,
  .completion .rays, .completion .closer {
    opacity: 1 !important; filter: none !important; transform: none !important;
    clip-path: none !important;
  }
  .completion .rays { opacity: .92 !important; }
  .completion .closer { opacity: .8 !important; }
}
