/* ==========================================================================
   page.css: layout + motion for the pre-launch page, top to bottom:
     1. Top bar   2. Hero (Rua stage + countdown)   3. Screenshots
     4. The mystery card   5. Existing users   6. Footer   7. Keyframes
   Mobile first: base styles are for phones, @media blocks widen it.
   ========================================================================== */

.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }

/* ===================== 1. Top bar ===================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: min(100% - 2 * var(--gutter), var(--max));
  margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top));
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand__icon {
  width: 46px; height: 46px; border-radius: 14px;
  border: var(--line-sm) solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  rotate: -4deg;
}
.brand__name { font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1; padding-top: 4px; }

/* ===================== 2. Hero ===================== */
.hero {
  display: flex; flex-direction: column; align-items: center;
  width: min(100% - 2 * var(--gutter), var(--max));
  margin: 0 auto;
  text-align: center;
}

/* --- Rua's stage --- */
.stage {
  position: relative;
  /* Rua is as big as the screen allows while the countdown still fits on the
     first screen: the 410px is everything else above the fold (top bar,
     headline, tiles). Rua is ~1.15x taller than wide, hence the 0.85. */
  width: clamp(230px, calc((100vh - 410px) * 0.85), min(86vw, 380px));
  width: clamp(230px, calc((100svh - 410px) * 0.85), min(86vw, 380px));
  margin-top: 18px;
  isolation: isolate;
}

/* The sun behind him: a solid tangerine disc with soft rays around it */
.stage__rays {
  position: absolute; z-index: -2;
  left: 50%; top: 54%;
  width: 190%; aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--sunny) 0deg 9deg, transparent 9deg 20deg);
  opacity: 0.55;
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 68%);
          mask: radial-gradient(circle, #000 30%, transparent 68%);
  animation: spin 120s linear infinite;
}
.stage::before {                       /* the disc */
  content: ""; position: absolute; z-index: -1;
  left: 50%; top: 56%;
  width: 92%; aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--tangerine);
  border: var(--line) solid var(--ink);
  box-shadow: 0 var(--lift) 0 var(--tangerine-lip), 0 var(--lift) 0 var(--line) var(--ink);
}

/* Floating biro doodles. Fixed spots and tilts (never random). */
.doodle {
  position: absolute; z-index: 1; pointer-events: none;
  width: 18%; height: auto;
  animation: float 6s var(--ease-in-out) infinite alternate;
}
.doodle--shamrock { left: -9%;  top: 10%;  rotate: -14deg; width: 20%; }
.doodle--sparkle  { right: -6%; top: 22%;  rotate: 10deg;  width: 13%; animation-delay: -2s; }
.doodle--star     { right: -9%; top: 58%;  rotate: 16deg;  width: 17%; animation-delay: -4s; animation-duration: 7s; }
.doodle--swirl    { left: -7%;  top: 64%;  rotate: -6deg;  width: 18%; animation-delay: -1s; animation-duration: 8s; }
.doodle--heart    { left: 6%;   top: 1%;   rotate: -12deg; width: 11%; animation-delay: -3s; }

/* Speech bubble */
.bubble {
  position: absolute; z-index: 3;
  right: -5%; top: -2%;
  width: max-content; max-width: 66%;
  padding: 9px 14px 8px;
  background: var(--cream);
  border: var(--line-sm) solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: clamp(0.92rem, 4vw, 1.02rem); line-height: 1.15;
  text-align: left;
  rotate: 4deg;
  transform-origin: 20% 100%;
}
.bubble::after {                       /* the tail, pointing at Rua */
  content: ""; position: absolute; left: 18%; bottom: -9px;
  width: 16px; height: 16px;
  background: var(--cream);
  border-right: var(--line-sm) solid var(--ink);
  border-bottom: var(--line-sm) solid var(--ink);
  rotate: 45deg; skew: 8deg 8deg;
}

/* Rua himself: a big button you can tap */
.rua {
  position: relative; z-index: 2;
  display: block; width: 100%;
  border-radius: 40%;
  transition: transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  animation: rua-in 900ms var(--ease-spring) 80ms backwards;
}
.rua:active { transform: scale(0.97); }
.rua__ground {                         /* soft shadow he sits on */
  position: absolute; left: 14%; right: 14%; bottom: 1%; height: 9%;
  border-radius: 50%;
  background: var(--tangerine-lip);
  opacity: 0.35;
}
.rua__hop, .rua__breathe { display: block; transform-origin: 50% 100%; }
.rua__breathe { display: grid; animation: breathe 3.6s var(--ease-in-out) infinite; }

/* --- Boil: stacked frames, only one visible (rua.js sets data-frame) --- */
.boil { display: none; grid-area: 1 / 1; align-self: end; justify-self: center; width: 100%; }
.boil.is-active { display: grid; }
.boil > img { grid-area: 1 / 1; width: 100%; height: auto; visibility: hidden; }
.boil:not([data-frame]) > img:nth-child(1),
.boil[data-frame="0"] > img:nth-child(1),
.boil[data-frame="1"] > img:nth-child(2),
.boil[data-frame="2"] > img:nth-child(3) { visibility: visible; }
.boil[data-pose="cheer"]   { width: 104%; }
.boil[data-pose="bunting"] { width: 86%; }

/* --- Copy + countdown --- */
.hero__copy { display: flex; flex-direction: column; align-items: center; margin-top: 12px; }
.hero__copy > * { animation: rise 700ms var(--ease-out) both; }
.hero__copy > .display   { animation-delay: 160ms; }
.hero__copy > .countdown { animation-delay: 240ms; }
.hero__copy > .lede      { animation-delay: 320ms; }
.hero__copy > .actions   { animation-delay: 400ms; }

.lede {
  max-width: 30ch;
  margin-top: 16px;
  font-size: 1.12rem; font-weight: 700;
  color: var(--ink-soft);
}

.countdown { margin-top: 18px; width: 100%; }
.countdown__tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  max-width: 460px; margin-inline: auto;
}
.tile {
  --fill: var(--cream); --lip: var(--border-soft); --text: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 2px 8px;
  background: var(--fill); color: var(--text);
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 var(--lift) 0 var(--lip), 0 var(--lift) 0 var(--line) var(--ink);
}
.tile:nth-child(1) { rotate: -3deg; }
.tile:nth-child(2) { rotate: 2deg; translate: 0 4px; }
.tile:nth-child(3) { rotate: -1.5deg; }
.tile:nth-child(4) { rotate: 3deg; translate: 0 3px; }
.tile--sunny     { --fill: var(--sunny);     --lip: var(--sunny-lip);     --text: var(--sunny-ink); }
.tile--tangerine { --fill: var(--tangerine); --lip: var(--tangerine-lip); --text: var(--tangerine-ink); }
.tile--bubblegum { --fill: var(--bubblegum); --lip: var(--bubblegum-lip); --text: var(--bubblegum-ink); }
.tile--sky       { --fill: var(--sky);       --lip: var(--sky-lip);       --text: var(--sky-ink); }

.tile__num {
  display: flex; justify-content: center;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.3rem, 11.5vw, 4.4rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  overflow: hidden;                    /* digits slide in/out inside the tile */
  padding-top: 0.06em;
}
.digit-slot { position: relative; display: inline-block; width: 0.58em; text-align: center; }
.digit-slot > span { display: block; }
.digit-slot > .is-out { position: absolute; inset: 0; animation: digit-out 320ms var(--ease-out) forwards; }
.digit-slot > .is-in { animation: digit-in 480ms var(--ease-spring) both; }
.tile__label {
  font-weight: 800; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  margin-top: 2px;
}
/* white text on sky is too faint for small type: give it the ink outline the headline uses */
.tile--sky .tile__label { -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.tile.is-bump { animation: bump 420ms var(--ease-spring); }

.countdown__when {
  margin-top: 14px;
  font-weight: 800; font-size: 0.95rem; color: var(--ink-soft);
}

.actions {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 14px;
  margin-top: 20px;
}

/* Store buttons */
.store { gap: 12px; padding-inline: 22px 26px; min-height: 64px; text-align: left; }
.store .btn__icon { width: 1.6em; height: 1.6em; }
.store__text { display: flex; flex-direction: column; font-size: 1.35rem; line-height: 1; }
.store__text small { font-family: var(--font-body); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.02em; margin-bottom: 3px; opacity: 0.85; }

/* ===================== 3. Screenshots ===================== */
.peek { margin-top: 60px; }
.peek__head { display: flex; flex-direction: column; align-items: center; }
.peek__rua { display: block; width: 168px; margin-bottom: -10px; position: relative; z-index: 0; }
.sticker-title {
  position: relative; z-index: 1;
  font-size: clamp(2rem, 8vw, 3rem);
  padding: 12px 28px 8px;
  background: var(--cream);
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 var(--lift) 0 var(--ink);
  rotate: -2deg;
}

/* Phones: a swipeable row */
.screens {
  position: relative;                  /* main.js measures the middle phone from here */
  display: flex; gap: 18px;
  margin-top: 30px;
  padding: 24px max(var(--gutter), calc(50vw - 120px)) 40px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.screens::-webkit-scrollbar { display: none; }
.screen {
  flex: 0 0 min(60vw, 240px);
  scroll-snap-align: center;
  transition: translate 400ms var(--ease-out), rotate 400ms var(--ease-out), scale 400ms var(--ease-out);
}
.screen:nth-child(odd)  { rotate: -2.5deg; }
.screen:nth-child(even) { rotate: 2deg; translate: 0 10px; }
.screen__float { display: block; animation: drift 7s var(--ease-in-out) infinite alternate; }
.screen:nth-child(2) .screen__float { animation-delay: -2.5s; }
.screen:nth-child(3) .screen__float { animation-delay: -5s; }
.screen:nth-child(4) .screen__float { animation-delay: -1.2s; }
.screen:nth-child(5) .screen__float { animation-delay: -3.7s; }
.screen img {
  width: 100%; height: auto;
  border: var(--line) solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 8px 0 var(--ink);
  background: var(--cream);
}

/* ===================== 4. The mystery ===================== */
.secret { width: min(100% - 2 * var(--gutter), 1000px); margin: 36px auto 0; }
.secret__card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 26px 22px 30px;
  background: var(--bubblegum-soft);
  border: var(--line) solid var(--ink);
  border-radius: 32px;
  box-shadow: 0 var(--lift) 0 var(--bubblegum-lip), 0 var(--lift) 0 var(--line) var(--ink);
  rotate: -1deg;
}
.secret__rua { display: block; width: 170px; }
.secret__copy p { max-width: 34ch; margin: 12px auto 0; font-size: 1.12rem; font-weight: 700; color: var(--ink-soft); }
.section-title { margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 10px; margin-top: 22px; }
.chip {
  --fill: var(--cream); --lip: var(--border-soft); --text: var(--ink);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px 6px;
  background: var(--fill); color: var(--text);
  border: var(--line-sm) solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 0 var(--lip), 0 4px 0 var(--line-sm) var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.1;
}
.chip:nth-child(1) { rotate: -3deg; }
.chip:nth-child(2) { rotate: 2deg; }
.chip:nth-child(3) { rotate: -1deg; }
.chip:nth-child(4) { rotate: 3deg; }
.chip--sky, .chip--grape { -webkit-text-stroke: 0.16em var(--ink); paint-order: stroke fill; }  /* white text: outlined so it reads */
.chip--sky       { --fill: var(--sky);       --lip: var(--sky-lip);       --text: var(--sky-ink); }
.chip--grape     { --fill: var(--grape);     --lip: var(--grape-lip);     --text: var(--grape-ink); }
.chip--tangerine { --fill: var(--tangerine); --lip: var(--tangerine-lip); --text: var(--tangerine-ink); }
.chip--mint      { --fill: var(--mint);      --lip: var(--mint-lip);      --text: var(--mint-ink); }
.chip--mystery {
  --fill: var(--ink); --lip: var(--cocoa); --text: var(--sunny);
  rotate: -4deg;
  animation: wobble 4s var(--ease-in-out) infinite;
}
.chip__icon { width: 1em; height: 1em; }
html[data-state="launched"] .chip--mystery { --fill: var(--sunny); --lip: var(--sunny-lip); --text: var(--ink); }

/* ===================== 5. Existing users ===================== */
.already { width: min(100% - 2 * var(--gutter), 640px); margin: 44px auto 0; }
.already__card {
  padding: 16px 22px;
  background: var(--cocoa-soft);
  border: var(--line-sm) solid var(--border);
  border-radius: 22px;
  text-align: center;
  font-weight: 700; color: var(--ink-soft);
}
.already__card strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1.2rem; }

/* ===================== 6. Footer ===================== */
.footer {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-top: 56px;
  padding: 0 var(--gutter) max(40px, env(safe-area-inset-bottom));
}
.footer__rua { display: block; width: 150px; }
.footer__line { margin-top: 6px; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; }
.socials { display: flex; gap: 12px; margin-top: 12px; }
.footer__links { display: flex; gap: 22px; margin-top: 28px; font-weight: 800; }
.footer__links a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.footer__copy { margin-top: 8px; font-size: 0.9rem; color: var(--ink-soft); }

/* ===================== Scroll reveal (only when JS runs) ===================== */
html.js [data-reveal] { transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out); }
html.js [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(28px); }
html.js .screens:not(.is-in) .screen { opacity: 0; transform: translateY(60px); }
html.js .screens .screen { transition: opacity 700ms var(--ease-out), transform 800ms var(--ease-spring), translate 400ms var(--ease-out), rotate 400ms var(--ease-out); }
html.js .screens.is-in .screen:nth-child(1) { transition-delay: 0ms; }
html.js .screens.is-in .screen:nth-child(2) { transition-delay: 70ms; }
html.js .screens.is-in .screen:nth-child(3) { transition-delay: 140ms; }
html.js .screens.is-in .screen:nth-child(4) { transition-delay: 210ms; }
html.js .screens.is-in .screen:nth-child(5) { transition-delay: 280ms; }
html.js .screens[data-reveal]:not(.is-in) { opacity: 1; transform: none; }

/* ===================== Wider screens ===================== */
@media (min-width: 720px) {
  .stage { width: clamp(300px, calc((100vh - 470px) * 0.85), 440px); width: clamp(300px, calc((100svh - 470px) * 0.85), 440px); }
  .bubble { font-size: 1.15rem; }
  .countdown__tiles { gap: 14px; }
  .secret__card { flex-direction: row; text-align: left; gap: 30px; padding: 34px 44px 38px 30px; }
  .secret__rua { width: 230px; flex: none; }
  .secret__copy p { margin-left: 0; max-width: 40ch; font-size: 1.22rem; }
  .chips { justify-content: flex-start; }
}

/* Wide screens: Rua big in the middle, headline on his left, countdown on his
   right. .hero__copy steps aside (display: contents) so its children can sit
   in the hero's grid directly. */
@media (min-width: 1000px) {
  .topbar { width: min(100% - 2 * var(--gutter), 1320px); }
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: 1fr auto auto 1fr;
    grid-template-areas:
      ".     stage ."
      "title stage count"
      "lede  stage actions"
      ".     stage .";
    column-gap: clamp(48px, 5vw, 88px);
    width: min(100% - 2 * var(--gutter), 1320px);
    min-height: min(860px, calc(100vh - 80px));
    min-height: min(860px, calc(100svh - 80px));
    padding-block: 8px 24px;
  }
  .stage {
    grid-area: stage; align-self: center;
    width: clamp(380px, calc((100vh - 150px) * 0.82), min(38vw, 560px));
    width: clamp(380px, calc((100svh - 150px) * 0.82), min(38vw, 560px));
    margin: 30px 0 0;
  }
  .hero__copy { display: contents; }

  .hero .display {
    grid-area: title; align-self: end; justify-self: end; text-align: right;
    font-size: clamp(3.8rem, 6vw, 6rem);
  }
  .hero .lede {
    grid-area: lede; align-self: start; justify-self: end; text-align: right;
    max-width: 22ch; margin-top: 22px; font-size: 1.25rem;
  }
  .hero .countdown { grid-area: count; align-self: end; justify-self: start; width: 100%; max-width: 360px; margin: 0; }
  .countdown__tiles { grid-template-columns: repeat(2, 1fr); gap: 18px 16px; max-width: none; }
  .tile { padding: 12px 4px 10px; }
  .tile__num { font-size: clamp(3.2rem, 5.2vw, 5rem); }
  .tile:nth-child(2), .tile:nth-child(4) { translate: 0 0; }
  .countdown__when { text-align: left; margin-top: 18px; }
  .hero .actions { grid-area: actions; align-self: start; justify-content: flex-start; margin-top: 22px; }
  html[data-state="launched"] .hero .actions { flex-direction: column; align-items: flex-start; }
  html[data-state="launched"] .hero .lede { align-self: start; }

  .peek { margin-top: 64px; }
  /* Desktop: fan the phones out like a hand of cards */
  .screens {
    justify-content: center; overflow: visible;
    padding: 30px var(--gutter) 60px;
    gap: 0;
  }
  .screen { flex: 0 0 clamp(190px, 17vw, 250px); margin-inline: -14px; }
  .screen:nth-child(1) { rotate: -10deg; translate: 0 56px; }
  .screen:nth-child(2) { rotate: -5deg;  translate: 0 14px; }
  .screen:nth-child(3) { rotate: 0deg;   translate: 0 -8px; scale: 1.06; z-index: 2; }
  .screen:nth-child(4) { rotate: 5deg;   translate: 0 14px; }
  .screen:nth-child(5) { rotate: 10deg;  translate: 0 56px; }
}
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  .screen:hover { translate: 0 -30px; rotate: 0deg; z-index: 3; scale: 1.08; }
}

/* ===================== 7. Keyframes ===================== */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes float   { from { transform: translateY(0) rotate(0deg); } to { transform: translateY(-10px) rotate(6deg); } }
@keyframes drift   { from { transform: translateY(0); } to { transform: translateY(-12px); } }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 0.99); } }
@keyframes rua-in  { from { opacity: 0; transform: translateY(40px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes rise    { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes digit-in  { from { transform: translateY(70%) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes digit-out { to { transform: translateY(-70%) scale(0.8); opacity: 0; } }
@keyframes bump    { 0% { scale: 1; } 40% { scale: 1.07; } 100% { scale: 1; } }
@keyframes wobble  { 0%, 80%, 100% { transform: rotate(0); } 84% { transform: rotate(-6deg); } 88% { transform: rotate(5deg); } 92% { transform: rotate(-3deg); } 96% { transform: rotate(2deg); } }

@media (prefers-reduced-motion: reduce) {
  .stage__rays, .doodle, .rua__breathe, .screen__float, .chip--mystery { animation: none !important; }
  html.js [data-reveal]:not(.is-in), html.js .screens:not(.is-in) .screen { transform: none; }
}

/* ===================== 404 page ===================== */
.lost__main {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(100% - 2 * var(--gutter), 560px);
  margin: 8vh auto 60px; text-align: center;
}
.lost__rua { display: block; width: min(80vw, 380px); }
.lost__line { font-weight: 700; font-size: 1.12rem; color: var(--ink-soft); margin-bottom: 14px; }
