/* flip.css — seamside.com/flip. One column of beats, each held on screen while the
   scroll turns it around; a running stack collects what flipped; the end is the stack
   as a poster. Dark on purpose (.os-dark on the body): c4 carries no text on white. */

body.flip { color-scheme: dark; font-size: 17px; line-height: 1.5;
  padding-block: 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
:focus-visible { outline: 2px solid var(--os-c1); outline-offset: 3px; border-radius: 4px; }
.flip .wrap { max-width: 68rem; padding: 0; }

/* ---- the opener ---- */
.open { min-height: 50svh; display: grid; align-content: center; padding-block: 12vh 4vh; }
.open h1 { font-family: var(--os-font-serif); font-weight: 700; letter-spacing: -0.025em; line-height: 1.02; margin: 0; max-width: 14ch; text-wrap: balance;
  font-size: clamp(44px, 3rem + 3vw, 92px); }
.open p { font-size: clamp(18px, 1rem + 0.4vw, 22px); line-height: 1.45; color: var(--os-text-secondary); margin: 28px 0 0; max-width: 44rem; text-wrap: balance; }
.open p b { color: var(--os-c2); }
.open p .turned { color: var(--os-c2); }
.open .hint { margin-top: 44px; font-family: var(--os-font-mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--os-text-muted); display: flex; align-items: center; gap: 12px; }
.open .hint i { display: block; width: 1px; height: 40px; background: var(--os-text-subtle); transform-origin: top; animation: reach 2.4s ease-in-out infinite; }
@keyframes reach { 0%, 100% { transform: scaleY(0.5); opacity: 0.5; } 50% { transform: scaleY(1); opacity: 1; } }

/* ---- a beat ----
   --p is the scroll progress through the beat (0..1); --g, --n, --t are its pieces:
   gray strokes fall away, colored strokes draw in, the new line fades in. With no script,
   every beat rests flipped. */
/* The hold is shorter than the screen and stuck a little below its top, so the first beat
   shows under the opener before anyone scrolls. */
.beat { --p: 1; --g: 1; --n: 1; --t: 1; --c: var(--os-text); min-height: 110svh; }
.beat .hold { position: sticky; top: 8svh; min-height: 70svh; display: grid; align-content: center;
  grid-template-columns: 1fr auto 1fr; grid-template-areas: 'cold fig flipped'; column-gap: 40px; align-items: center; }
.cold, .flipped { grid-area: cold; margin: 0; }
.flipped { grid-area: flipped; }
.cold p, .flipped p { margin: 0; text-wrap: balance; }
.cold .today { display: block; font-family: var(--os-font-mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--os-text-subtle); margin: 0 0 14px; }
.flipped .what { display: block; font-family: var(--os-font-mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c); margin: 0 0 14px;
  opacity: calc(var(--t) * 0.8); transform: translateY(calc((1 - var(--t)) * 8px)); }
.cold p { font-family: var(--os-font-mono); font-size: clamp(17px, 0.9rem + 0.6vw, 22px); line-height: 1.45; color: var(--os-text-secondary); max-width: 22ch;
  opacity: calc(1 - var(--t) * 0.2); }
.flipped p { font-family: var(--os-font-serif); font-weight: 700; letter-spacing: -0.02em; font-size: clamp(30px, 1.4rem + 2vw, 50px); line-height: 1.08; color: var(--c); max-width: 14ch;
  opacity: var(--t); transform: translateY(calc((1 - var(--t)) * 12px)); }
.fig { grid-area: fig; margin: 0; width: clamp(240px, 34vw, 400px); aspect-ratio: 1; justify-self: center; }
.fig svg { display: block; width: 100%; height: 100%; overflow: visible; fill: none; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.fig .g { stroke: var(--os-text-subtle); stroke-dasharray: 1; stroke-dashoffset: calc(-1 * var(--g)); opacity: clamp(0, (1 - var(--g)) * 30, 1); }
.fig .n { stroke: var(--c); stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--n)); opacity: clamp(0, var(--n) * 30, 1); }
.fig .n.late { stroke-dashoffset: calc(1 - clamp(0, (var(--n) - 0.5) * 2, 1)); opacity: clamp(0, (var(--n) - 0.5) * 30, 1); }
.fig .n.bold { stroke-width: 2.5; }
.fig .m { stroke: color-mix(in srgb, var(--os-text-subtle), var(--c) calc(var(--n) * 100%)); }
.fig .mv { transform: translate(calc(var(--n) * var(--dx, 0px)), calc(var(--n) * var(--dy, 0px))); }
/* The whole drawing turns over across the flip, from the fall of the gray to the last of the color. */
.fig.turns svg { transform: rotate(calc(clamp(0, (var(--p) - 0.1) / 0.58, 1) * 180deg)); }

/* ---- the running stack and the orb that fills with it ---- */
.stack { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(24px, env(safe-area-inset-bottom, 0px)); z-index: 5;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none; transition: opacity 0.4s; }
.stack magic-orb { width: 36px; height: 36px; border-radius: 50%; margin-bottom: 10px; display: block; }
.stack span { font-family: var(--os-font-serif); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; color: var(--c); opacity: 0; transform: translateX(8px); transition: opacity 0.5s, transform 0.5s; }
.stack span.in { opacity: 1; transform: none; }
body.ending .stack { opacity: 0; }

/* ---- the stance, the closer and the end ---- */
/* The stance is always whole; it only pauses at the center of the screen for about a third
   of a scroll, so a fast thumb does not pass it. */
.stance { min-height: 85svh; }
.stance .hold { position: sticky; top: 25svh; min-height: 50svh; display: grid; align-content: center; }
.stance p { font-family: var(--os-font-serif); font-size: clamp(22px, 1.1rem + 1.2vw, 34px); line-height: 1.3; letter-spacing: -0.01em; margin: 0; max-width: 30ch; text-wrap: pretty; }
.stance p b { font-weight: 700; color: var(--os-c1); }
.end { padding-block: 12vh 14vh; display: grid; justify-items: center; text-align: center; gap: 0; }
.end magic-orb { display: block; width: 176px; height: 176px; border-radius: 50%; margin-top: 72px; }
.end ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.end ol li { font-family: var(--os-font-serif); font-weight: 700; font-size: clamp(22px, 1.1rem + 1.3vw, 36px); letter-spacing: -0.02em; line-height: 1.15; color: var(--c); text-wrap: balance; }
.end ol li.terms { color: var(--os-text); margin-top: 10px; }
.end .what-end { font-family: var(--os-font-mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--os-c1); margin: 56px 0 0; }
.end h2 { font-family: var(--os-font-serif); font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; font-size: clamp(34px, 1.8rem + 2vw, 64px); margin: 14px 0 0; text-wrap: balance; }
.end .lede { font-size: clamp(18px, 1rem + 0.4vw, 22px); color: var(--os-text-secondary); margin: 18px 0 0; max-width: 32rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 56px; padding: 0 32px; margin-top: 40px; border-radius: 6px;
  background: var(--os-c1); color: var(--os-c1-fg); font-weight: 600; font-size: 18px; text-decoration: none; letter-spacing: -0.01em; }
.btn:hover { background: color-mix(in srgb, var(--os-c1), var(--os-text) 12%); }
.btn:active { background: color-mix(in srgb, var(--os-c1), var(--os-text) 24%); }
.fine { font-size: 14px; color: var(--os-text-muted); margin: 18px 0 0; }
.more { margin-top: 48px; font-size: 15px; }
.more a { color: var(--os-text-secondary); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--os-border-color); }
.more a:hover { color: var(--os-text); }

/* ---- a phone: the two lines stack, the drawing above them ---- */
@media (max-width: 760px) {
  .beat { min-height: 110svh; }
  /* Stacked, a beat's text ends right above the next drawing; the gap keeps them apart. */
  .beat + .beat, .beat + .stance, .stance + .beat { margin-top: 18svh; }
  .beat .hold { grid-template-columns: 1fr; grid-template-areas: 'fig' 'cold' 'flipped'; row-gap: 22px; justify-items: start; }
  .fig { width: min(62vw, 260px); justify-self: start; }
  .stack { display: none; }
}
@media (max-width: 1100px) { .stack span { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .beat { --p: 1 !important; --g: 1 !important; --n: 1 !important; --t: 1 !important; }
  .flipped p, .stack span, .stack { transition: none; transform: none; }
  .open .hint i { animation: none; }
}
