/* Notegram story page (/notegram).
   Self-contained on purpose: this page has its own palette (the app's, light by default) and does
   not use cloud.css, which is the dark-only Synogram Cloud design system. Light follows the app;
   dark follows prefers-color-scheme and the toggle in the header. */
:root {
  color-scheme: light;
  --bg: #F7F7F4; --surface: #FFFFFF; --tile: #F2F2EE;
  --ink: #1C1C1E; --ink-2: rgba(60,60,67,.74); --ink-3: rgba(60,60,67,.5);
  --line: rgba(60,60,67,.14);
  --accent: #4B6B10; --accent-ink: #FFFFFF; --accent-text: #3D5A0B;
  --pill: #1C1C1E; --pill-ink: #FFFFFF;
  --record: #FF3B30;
  --card-glass: rgba(247,247,244,.86);
  --word: rgba(28,28,30,.07);
  --font: "Inter Tight", "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  --hdr: calc(max(12px, env(safe-area-inset-top)) + 36px + 12px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0C0C0B; --surface: #1C1C1E; --tile: #2C2C2E;
    --ink: #F2F2F0; --ink-2: rgba(235,235,245,.72); --ink-3: rgba(235,235,245,.46);
    --line: rgba(235,235,245,.12);
    --accent: #A9CB57; --accent-ink: #10170A; --accent-text: #A9CB57;
    --pill: #F2F2F0; --pill-ink: #1C1C1E;
    --card-glass: rgba(12,12,11,.82);
    --word: rgba(242,242,240,.06);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C0C0B; --surface: #1C1C1E; --tile: #2C2C2E;
  --ink: #F2F2F0; --ink-2: rgba(235,235,245,.72); --ink-3: rgba(235,235,245,.46);
  --line: rgba(235,235,245,.12);
  --accent: #A9CB57; --accent-ink: #10170A; --accent-text: #A9CB57;
  --pill: #F2F2F0; --pill-ink: #1C1C1E;
  --card-glass: rgba(12,12,11,.82);
  --word: rgba(242,242,240,.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 1.0625rem; line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: clip; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 40; padding: 10px 14px; border-radius: 10px; background: var(--pill); color: var(--pill-ink); text-decoration: none; font-weight: 600; }
.skip:focus { top: 12px; }

/* Header */
.top { position: fixed; inset: 0 0 auto 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; }
.top::before { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--line); z-index: -1; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.top .spacer { flex: 1; }
.theme { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: .9rem; }

.pill { display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px 12px 16px; border-radius: 999px; background: var(--pill); color: var(--pill-ink); text-decoration: none; font-weight: 600; font-size: .9375rem; white-space: nowrap; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.pill:hover { transform: translateY(-1px); }
.pill:active { transform: scale(.97); }
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--record); box-shadow: 0 0 0 4px color-mix(in srgb, var(--record) 22%, transparent); }
.pill.small { padding: 8px 14px 8px 12px; font-size: .875rem; }
.ghost { display: inline-flex; padding: 12px 6px; color: var(--ink-2); font-weight: 500; font-size: .9375rem; text-decoration: none; }
.ghost:hover { color: var(--ink); }

/* The story: one sticky stage, chapters scroll over it (beside it, on a phone). */
.story { position: relative; }
.stage {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  /* Where the device sits is decided here, in CSS. The poster, the flat fallback and the WebGL canvas all follow. */
  --phone-h: calc(100svh * .655);
  --cx: 72%;
  --cy: 50%;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .16s linear; }
.stage.live canvas { opacity: 1; }
.word { position: absolute; right: -2vw; bottom: 4vh; font-weight: 800; font-size: clamp(5rem, 17vw, 16rem); letter-spacing: -.06em; line-height: .8; color: var(--word); white-space: nowrap; pointer-events: none; user-select: none; transition: opacity .5s, transform .6s cubic-bezier(.2,.8,.2,1); }
.word.swap { opacity: 0; transform: translateY(6%); }

/* First frame: a render of the 3D scene at its opening pose, standing in until WebGL is up.
   Same box the canvas draws into, so the swap does not move anything. */
.poster {
  position: absolute; left: var(--cx); top: var(--cy); transform: translate(-50%, -50%);
  height: calc(var(--phone-h) * var(--poster-ratio, 1.619)); aspect-ratio: var(--poster-ar, 2.4 / 3.4);
  pointer-events: none; user-select: none;
}
.poster img { width: 100%; height: 100%; object-fit: contain; }
.poster.gone { visibility: hidden; }
.no-webgl .poster { display: none; }
.no-webgl canvas { display: none; }

/* No WebGL: a flat framed screenshot at the same spot. */
.fallback { position: absolute; display: none; left: var(--cx); top: var(--cy); transform: translate(-50%, -50%); height: var(--phone-h); aspect-ratio: 71.9 / 150; border-radius: calc(var(--phone-h) * .09); border: calc(var(--phone-h) * .018) solid #1C1C1E; background: #000; box-shadow: 0 30px 80px rgba(0,0,0,.25); overflow: hidden; }
.fallback img { width: 100%; height: 100%; object-fit: cover; }
.no-webgl .fallback { display: block; }

.chapters { position: relative; margin-top: -100vh; margin-top: -100svh; z-index: 2; }
.chapter { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; padding: 96px 16px 48px; }
.chapter .copy { width: min(480px, 42vw); margin-left: max(16px, calc((100vw - 1180px) / 2)); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .8125rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 18px; }
.eyebrow .num { font-variant-numeric: tabular-nums; color: var(--ink-3); }
h1 { font-size: clamp(2.25rem, min(6.4vw, 12vh), 5.75rem); line-height: .95; letter-spacing: -.045em; margin: 0 0 24px; font-weight: 800; }
h2 { font-size: clamp(1.75rem, min(3.8vw, 7vh), 3.375rem); line-height: 1; letter-spacing: -.04em; margin: 0 0 20px; font-weight: 750; }
.lede { font-size: 1.1875rem; color: var(--ink-2); margin: 0 0 28px; max-width: 34ch; }
.copy p { color: var(--ink-2); margin: 0 0 14px; max-width: 40ch; }
.copy .fine { font-size: .875rem; color: var(--ink-3); }
.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding: 0; list-style: none; }
.chips li { font-size: .8125rem; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.scrollhint { margin-top: 36px; font-size: .8125rem; color: var(--ink-3); display: flex; align-items: center; gap: 10px; }
.scrollhint::before { content: ""; width: 28px; height: 1px; background: var(--ink-3); }

.progress { position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 5; display: flex; flex-direction: column; gap: 10px; list-style: none; margin: 0; padding: 0; }
.progress li { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); opacity: .35; transition: opacity .3s, transform .3s, background .3s; }
.progress li.on { opacity: 1; background: var(--accent); transform: scale(1.5); }
.progress.hidden { opacity: 0; pointer-events: none; }

/* After the story */
.after { position: relative; z-index: 3; background: var(--bg); padding: 96px 16px 0; }
.wrap { max-width: 1180px; margin: 0 auto; }
.also h2 { max-width: 16ch; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-top: 36px; }
.cell { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.cell h3 { font-size: 1.0625rem; margin: 14px 0 6px; letter-spacing: -.01em; }
.cell p { margin: 0; font-size: .9375rem; color: var(--ink-2); }
.cell .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--tile); display: grid; place-items: center; }
.cell svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.cta { margin: 120px 0 0; padding: 72px 24px; border-radius: 36px; background: var(--pill); color: var(--pill-ink); text-align: center; position: relative; overflow: hidden; }
.cta h2 { color: inherit; margin: 18px auto 14px; max-width: 14ch; }
.cta p { margin: 0 auto 30px; max-width: 44ch; opacity: .72; }
.cta .pill { background: var(--bg); color: var(--ink); }
.cta img { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; }
.cta .fine { font-size: .8125rem; opacity: .55; margin: 18px auto 0; }

footer { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: 40px 0 max(40px, env(safe-area-inset-bottom)); color: var(--ink-3); font-size: .875rem; }
footer a { color: var(--ink-2); text-decoration: none; }
footer a:hover { color: var(--ink); }
footer .spacer { flex: 1; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
/* A window shorter than the copy (a phone on its side): start at the top instead of centring under the header. */
@media (min-width: 761px) and (max-height: 600px) {
  .chapter { align-items: flex-start; padding-top: calc(var(--hdr) + 24px); }
  .lede { margin-bottom: 18px; }
  .scrollhint { display: none; }
}

/* A phone: the device is pinned in the top part of the screen and the chapters read beneath it.
   Nothing overlaps, because the text scrolls under an opaque stage instead of over the device. */
@media (max-width: 760px) {
  :root { --zone: 44svh; }                 /* the device's room, below the header; the chapters need it too */
  body { font-size: 1rem; }
  .stage {
    height: calc(var(--hdr) + var(--zone));
    --phone-h: calc(var(--zone) * .86);
    --cx: 50%;
    --cy: calc(var(--hdr) + var(--zone) / 2);
    background: var(--bg);
    z-index: 4;
  }
  .stage::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); }
  .chapters { margin-top: 0; z-index: 2; }
  .chapter { align-items: flex-start; min-height: calc(100svh - var(--hdr) - var(--zone)); padding: 24px 16px 40px; }
  .chapter .copy { width: 100%; margin: 0; }
  .chapter.hero { min-height: calc(100svh - var(--hdr) - var(--zone)); padding-top: 20px; }
  h1 { font-size: 2.75rem; margin-bottom: 14px; }
  h2 { font-size: 1.75rem; margin-bottom: 10px; }
  .lede { font-size: 1.0625rem; margin-bottom: 18px; }
  .copy p { margin-bottom: 10px; }
  .chips { display: none; }
  .scrollhint { display: none; }
  .word { right: auto; left: 12px; top: calc(var(--hdr) + 4px); bottom: auto; font-size: 4.5rem; }
  .progress { display: none; }
  .grid { grid-template-columns: 1fr; }
  .cta { border-radius: 28px; padding: 56px 20px; margin-top: 80px; }
  .after { padding-top: 72px; }
}
@media (max-width: 360px) {
  .top { gap: 8px; padding-inline: 12px; }
  .pill.small .dot { display: none; }
  .pill.small { padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
