/* Aulama "一線" — the cinematic layer for the home and About pages.
   The WebGL sky sits behind everything; the copy keeps the site's tokens,
   since the sky follows the theme (night sky in dark, pearl morning in light). */

/* ------------------------------------------------------------------ stage */
.journey-sky,
.journey-canvas,
.journey-veil {
  position: fixed; inset: 0; z-index: 0;
  width: 100vw; height: 100vh; height: 100lvh;
  pointer-events: none;
}
/* Painted sky underneath the canvas: what low-power devices, reduced data
   and failed WebGL get, and what shows for the instant before the first frame. */
.journey-sky {
  background:
    radial-gradient(60% 40% at 72% 56%, color-mix(in srgb, var(--b3) 22%, transparent), transparent 70%),
    radial-gradient(70% 50% at 20% 18%, color-mix(in srgb, var(--b1) 14%, transparent), transparent 70%),
    linear-gradient(180deg, var(--j-top) 0%, var(--j-mid) 52%, var(--j-low) 100%);
  --j-top: #8ab8e8; --j-mid: #cfe5f1; --j-low: #eef6e8;
}
:root[data-theme="dark"] .journey-sky { --j-top: #010306; --j-mid: #05111a; --j-low: #0d2b2c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .journey-sky { --j-top: #010306; --j-mid: #05111a; --j-low: #0d2b2c; }
}
.journey-canvas { opacity: 0; transition: opacity 1.2s var(--ease); }
.journey-canvas.is-live { opacity: 1; }
.no-webgl .journey-canvas { display: none; }
/* A quiet wash on the side the copy sits on, so text never competes with a
   bright stretch of thread passing behind it. */
.journey-veil {
  background: linear-gradient(90deg, color-mix(in srgb, var(--bg) 46%, transparent), color-mix(in srgb, var(--bg) 0%, transparent) 58%);
}
@media (max-width: 900px) {
  .journey-veil { background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 34%, transparent), color-mix(in srgb, var(--bg) 0%, transparent) 70%); }
}
body:has(.journey-canvas) .page-glow { display: none; }

/* ------------------------------------------------------------------ opening */
.j-hero {
  position: relative;
  overflow-x: clip;
  min-height: 100vh; min-height: 100svh;
  display: grid; align-content: center;
  padding: calc(var(--nav-h) + var(--nav-top) + 24px) 0 clamp(120px, 22vh, 220px);
  text-align: center;
}
.j-hero-copy {
  display: grid; justify-items: center; gap: clamp(16px, 2.4vh, 24px);
  transform: translateY(calc(var(--p, 0) * -120px));
  opacity: clamp(0, calc(1 - var(--p, 0) * 1.8), 1);
}
/* the headline is lifted above the thread rather than boxed in glass */
.j-hero-copy::before {
  content: ""; position: absolute; inset: -12% -20% -6%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--bg) 58%, transparent), transparent);
}
.j-hero-copy { position: relative; }
.j-hero .eyebrow { margin: 0; color: var(--ink); text-transform: none; letter-spacing: .06em; }
.j-hero .display { font-size: clamp(48px, 8vw, 124px); letter-spacing: -.04em; }
.j-hero .lead { max-width: 34em; color: var(--ink); opacity: .86; font-weight: 500; }
.j-hero .btn-row { justify-content: center; margin-top: 6px; }
.j-hero .scroll-cue { opacity: clamp(0, calc(1 - var(--p, 0) * 6), 1); }

/* Painted thread for devices without the 3D scene: the same promise, still. */
.j-hero-line { display: none; }
.no-webgl .j-hero-line {
  display: block; position: absolute; left: 0; right: 0; bottom: 14vh; z-index: -1;
  width: 100%; height: 34vh; pointer-events: none;
}
.j-hero-line path { fill: none; stroke-linecap: round; }
.j-hero-line .glow { stroke-width: 26; opacity: .22; filter: blur(10px); }
.j-hero-line .core { stroke-width: 3.5; }

/* entrance: the thread draws first (in the scene), then the words surface */
.j-hero .eyebrow { animation: rise-in 1s var(--ease) .5s backwards; }
.j-hero .display > span { animation: title-in 1.4s var(--ease) backwards; }
.j-hero .display > span:nth-child(1) { animation-delay: .7s; }
.j-hero .display > span:nth-child(2) { animation-delay: .86s; }
.j-hero .lead { animation: rise-in 1.1s var(--ease) 1.15s backwards; }
.j-hero .btn-row { animation: rise-in 1.1s var(--ease) 1.3s backwards; }
.j-hero .scroll-cue { animation: fade-in 1s var(--ease) 2s backwards; }
body:has(.j-hero) .site-nav { animation: nav-in 1s var(--ease) .2s backwards; }

/* ------------------------------------------------------------------ chapters */
/* Product cards turn to clearer glass so each product's bead glows through
   the card it belongs to. */
body:has(.journey-canvas) .stack-card {
  background: var(--lg-fill);
  -webkit-backdrop-filter: var(--lg-blur); backdrop-filter: var(--lg-blur);
}
body:has(.journey-canvas) .stack-visual {
  background: radial-gradient(70% 70% at 70% 40%, rgb(var(--tone-rgb) / .16), transparent 70%);
}
/* the statement reads against open sky */
body:has(.journey-canvas) .statement-text { text-shadow: 0 0 40px color-mix(in srgb, var(--bg) 70%, transparent); }

/* chapter index: where you are in the journey, and a way to jump */
.j-index {
  position: fixed; right: clamp(14px, 1.6vw, 26px); top: 50%; z-index: 30;
  display: grid; gap: 6px;
  transform: translateY(-50%);
  margin: 0; padding: 0; list-style: none;
  opacity: 0; transition: opacity .5s var(--ease);
}
.j-index.is-shown { opacity: 1; }
.j-index a {
  position: relative; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
}
.j-index a::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 30%, transparent);
  transition: transform .4s var(--spring), background-color .3s var(--ease);
}
.j-index a[aria-current="true"]::before { background: var(--b2); transform: scale(1.55); box-shadow: 0 0 0 4px color-mix(in srgb, var(--b2) 22%, transparent); }
.j-index a span {
  position: absolute; right: 34px; top: 50%; transform: translate(6px, -50%);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--glass-bg-strong); color: var(--ink);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: var(--glass-shadow);
  font-size: 12.5px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.j-index a:hover span, .j-index a:focus-visible span { opacity: 1; transform: translate(0, -50%); }
@media (max-width: 1080px), (pointer: coarse) { .j-index { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .j-hero-copy { transform: none; }
  .j-hero .eyebrow, .j-hero .display > span, .j-hero .lead, .j-hero .btn-row, .j-hero .scroll-cue { animation: none; }
}

/* Wide screens: the product cards lose their panel and float in the sky, so
   each product's bead glows behind its screenshots. A card fades and lifts
   away as the next one slides up over it. */
@media (min-width: 901px) {
  body:has(.journey-canvas.is-live) .stack-card {
    overflow: visible;
    opacity: clamp(0, calc(1 - var(--p, 0) * 2.4), 1);
    transform: translateY(calc(var(--p, 0) * -48px)) scale(calc(1 - var(--p, 0) * .04));
    filter: none;
  }
  body:has(.journey-canvas.is-live) .stack-visual { background: none; }
  body:has(.journey-canvas.is-live) .stack-copy p { color: var(--ink); opacity: .82; }
}

/* The edge under the navigation: a soft tinted blur that eases in, rather
   than a dark band that snaps on as the opening scrolls away. */
body:has(.journey-canvas) .scroll-edge {
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 50%, transparent), color-mix(in srgb, var(--bg) 0%, transparent));
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: opacity 1.2s var(--ease);
}

/* the scroll cue sits over the thread, so it gets a small glass backing */
.j-hero .scroll-cue {
  padding: 8px 14px 0; border-radius: 999px 999px 0 0;
  color: var(--ink-2);
}
.j-hero .scroll-cue::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 30px; z-index: -1;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}

/* Phones on their side: the whole opening, buttons included, fits in the
   first screen, and the copy gets a firmer backing over the threads. */
@media (orientation: landscape) and (max-height: 520px) {
  .j-hero { padding: calc(var(--nav-h) + var(--nav-top) + 4px) 0 44px; }
  .j-hero-copy { gap: 10px; }
  .j-hero .display { font-size: clamp(34px, 12vh, 58px); }
  .j-hero .lead { font-size: 14.5px; line-height: 1.55; max-width: 40em; }
  .j-hero .btn-row { margin-top: 2px; }
  .j-hero .scroll-cue { display: none; }
  .j-hero-copy::before { inset: -8% -10% -12%; background: radial-gradient(closest-side, color-mix(in srgb, var(--bg) 72%, transparent), transparent); }
}

/* ------------------------------------------------------------------ type */
/* Rounded, heavier type to match Anime and Aulama ID: Fredoka for Latin,
   Resource Han Rounded for Chinese and Japanese (sliced in aulama-round.css).
   Rounded heavy strokes need a little air, so tight display tracking eases. */
body:has(.journey-canvas) {
  --font: "Aulama Round Latin", "Aulama Round HK", "PingFang HK", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  font-family: var(--font);
  font-weight: 500;
}
/* Chinese pages put the CJK face first so its full-width punctuation (——, “”)
   wins; it carries no Latin, so letters still fall through to Fredoka. */
html[lang^="zh"] body:has(.journey-canvas) {
  --font: "Aulama Round HK", "Aulama Round Latin", "PingFang HK", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}
html[lang="zh-CN"] body:has(.journey-canvas), html[lang="zh-Hans"] body:has(.journey-canvas) {
  --font: "Aulama Round CN", "Aulama Round Latin", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}
body:has(.journey-canvas) :is(button, input, select, textarea) { font-family: var(--font); }
body:has(.journey-canvas) :is(.display, .h2, .h3, .statement-text) { font-weight: 700; letter-spacing: -.012em; }
body:has(.journey-canvas) .lead { font-weight: 500; }

/* ------------------------------------------------------------------ v6 world */
/* Painted stand-in for the 3D world (no WebGL, or the instant before the
   first frame): space above a curved, glowing horizon. */
.journey-sky {
  background:
    radial-gradient(150% 70% at 50% 128%, #0e2f4f 0 49.6%, #7cc8ff 50.2%, rgba(124, 200, 255, .35) 51.2%, rgba(124, 200, 255, 0) 56%),
    radial-gradient(60% 40% at 80% 20%, rgba(80, 120, 220, .12), transparent 70%),
    linear-gradient(180deg, #010206 0%, #030814 55%, #071426 100%);
}
:root[data-theme="light"] .journey-sky {
  background:
    radial-gradient(150% 70% at 50% 128%, #3f7fae 0 49.6%, #ffffff 50.2%, rgba(255, 255, 255, .6) 51.5%, rgba(255, 255, 255, 0) 57%),
    linear-gradient(180deg, #78aaee 0%, #bcd8f6 55%, #e8f3ff 100%);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .journey-sky {
    background:
      radial-gradient(150% 70% at 50% 128%, #3f7fae 0 49.6%, #ffffff 50.2%, rgba(255, 255, 255, .6) 51.5%, rgba(255, 255, 255, 0) 57%),
      linear-gradient(180deg, #78aaee 0%, #bcd8f6 55%, #e8f3ff 100%);
  }
}
.no-webgl .j-hero-line { display: none; }

/* ------------------------------------------------------------------ v7 world */
/* The opening sits on a real sky, so its copy follows the sun, not the
   theme: dark ink by day, light ink after dusk. */
:root[data-hero-sky="day"] .j-hero {
  --bg: #eef4f8; --ink: #0a0c12; --ink-2: #2f3646; --ink-3: #4a5162;
  --b1: #4f9e1f; --b2: #157a47; --b3: #0b6f6b; --accent: #0f6e3c;
  --grad: linear-gradient(115deg, var(--b1), var(--b2) 50%, var(--b3));
  --glass-bg-strong: rgba(250, 251, 255, .72);
  color: var(--ink);
}
:root[data-hero-sky="night"] .j-hero {
  --bg: #04070d; --ink: #f2f4f9; --ink-2: #ccd3df; --ink-3: #a9b1c0;
  --b1: #c4f06a; --b2: #4ade80; --b3: #2dd4bf; --accent: #5ee08f;
  --grad: linear-gradient(115deg, var(--b1), var(--b2) 50%, var(--b3));
  --glass-bg-strong: rgba(12, 18, 26, .66);
  color: var(--ink);
}
.j-hero .btn-primary { background: var(--ink); color: var(--bg); }

/* Space is always dark. In the dark theme copy sits on it directly; in the
   light theme each block of copy gets a light card, so it reads as a light page. */
body:has(.journey-canvas) .journey-veil { background: linear-gradient(90deg, rgba(0, 0, 0, .38), rgba(0, 0, 0, 0) 58%); }
/* by day the opening copy sits in a soft haze of light, so the green line
   reads against the trees */
:root[data-world-sky="day"] body:has(.journey-canvas) .journey-veil { background: radial-gradient(ellipse 58% 46% at 50% 44%, rgba(255, 255, 255, .3), rgba(255, 255, 255, 0) 72%); }
@media (max-width: 900px) { body:has(.journey-canvas) .journey-veil { background: linear-gradient(180deg, rgba(0, 0, 0, .3), rgba(0, 0, 0, 0) 70%); } }
:root[data-theme="light"] body:has(.journey-canvas) :is(#products .section-head, #aulama-id .id-grid > .reveal, #craft .container, #platforms .container, #next .container, .cta .container, #one-account .container, #founder .container, #values .container, #roadmap .container, #future .container, .auth-intro), :root[data-theme="light"] body:has(.journey-canvas) .statement-text {
  padding: clamp(22px, 3.4vw, 44px); border-radius: 28px;
  background: rgba(250, 251, 249, .9); border: 1px solid rgba(12, 16, 28, .08);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .55);
}
:root[data-theme="light"] body:has(.journey-canvas.is-live) .stack-card { background: color-mix(in srgb, var(--glass-bg-strong) 92%, #fff); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body:has(.journey-canvas) :is(#products .section-head, #aulama-id .id-grid > .reveal, #craft .container, #platforms .container, #next .container, .cta .container, #one-account .container, #founder .container, #values .container, #roadmap .container, #future .container, .auth-intro), :root:not([data-theme="dark"]) body:has(.journey-canvas) .statement-text {
    padding: clamp(22px, 3.4vw, 44px); border-radius: 28px;
    background: rgba(250, 251, 249, .9); border: 1px solid rgba(12, 16, 28, .08);
    box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .55);
  }
  :root:not([data-theme="dark"]) body:has(.journey-canvas.is-live) .stack-card { background: color-mix(in srgb, var(--glass-bg-strong) 92%, #fff); }
}
.world-credit { margin: 14px 0 0; color: var(--ink-3); font-size: 12.5px; line-height: 1.6; }
.world-credit a { text-decoration: underline; text-underline-offset: 3px; }

/* Keep the wordmark and touch controls inside narrow phone headers. */
@media (max-width: 440px) {
  body:has(.j-hero) .site-nav .brand img { width: 110px; }
  body:has(.j-hero) .nav-sheet-foot { flex-direction: column; align-items: stretch; }
  body:has(.j-hero) .nav-sheet-foot .seg { width: 100%; }
  body:has(.j-hero) .nav-sheet-foot .seg button { flex: 1; padding-inline: 8px; white-space: nowrap; }
}

/* The mobile sheet sits below the fixed-height header, outside its grid. */
@media (max-width: 899px) {
  body:has(.j-hero) .site-nav .nav-sheet {
    position: absolute; top: 100%;
    left: clamp(16px, 3vw, 40px); right: clamp(16px, 3vw, 40px);
    width: auto;
  }
}
