/* ==========================================================================
   owhile — design system
   Built from knowledge/brand/owhile-design.md
   Governing rule (§27): the metaphor informs interaction and disappears when
   it gets in the way. This is not a website pretending to be a train station.
   ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */

:root {
  /* Shell palette. §9: restrained — "the content universe supplies the colour". */
  --midnight: #0F172A;
  --ink:      #1F2937;
  --cloud:    #F8F5EE;   /* warm off-white */
  --sand:     #EADFCF;   /* muted ticket tone */

  /* Content accents. §9 — for windows and worlds ONLY, never shell chrome.
     "Calm outside. Anything inside." */
  --sunset: #FF9F66;
  --mint:   #7EC8A9;
  --sky:    #5B9BD5;
  --lilac:  #A78BFA;

  /* Semantic surface tokens — light. Every colour is defined HERE first, so
     nothing depends on a media query having matched. */
  --bg:            var(--cloud);
  --bg-raised:     #FFFFFF;
  --bg-sunken:     #F1EBE0;
  --fg:            var(--midnight);
  --fg-muted:      #5A6472;
  --fg-faint:      #8B939E;
  --rule:          #E2D9CA;
  --rule-strong:   #CFC3AF;
  --accent:        #8A6A3B;   /* muted gold, for ticket + signage detail */
  --focus:         #3B6EA5;

  /* Type. §8: editorial sophistication + friendliness + curiosity.
     Explicitly NOT corporate grotesk, not futuristic, not rounded-childish,
     not academic serif. Fraunces carries a distinctive lowercase; Instrument
     Sans stays extremely readable; DM Mono is the signage/ticket voice. */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Instrument Sans", system-ui, -apple-system, sans-serif;
  --font-signage: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --step--1: clamp(0.83rem, 0.80rem + 0.15vw, 0.92rem);
  --step-0:  clamp(1rem, 0.96rem + 0.20vw, 1.12rem);
  --step-1:  clamp(1.25rem, 1.15rem + 0.45vw, 1.55rem);
  --step-2:  clamp(1.60rem, 1.40rem + 0.95vw, 2.30rem);
  --step-3:  clamp(2.10rem, 1.65rem + 2.10vw, 3.60rem);
  --step-4:  clamp(2.60rem, 1.90rem + 3.20vw, 4.80rem);

  /* Space */
  --s-1: 0.5rem;  --s-2: 0.875rem; --s-3: 1.5rem;
  --s-4: 2.5rem;  --s-5: 4rem;     --s-6: 5rem;

  --radius:    14px;
  --radius-lg: 24px;

  /* Motion. §10: unhurried, physical (weight), directional, anticipatory.
     Long durations and a gentle overshoot-free ease read as mass, not snap. */
  --ease-physical: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-quick: 320ms;
  --dur-calm:  680ms;
  --dur-slow:  1400ms;
  --dur-approach: 2600ms;
}

/* Dark. §9: "particularly natural, because the metaphor is travel at
   dusk/night" — near-black ground, warm white type, muted gold accents.
   Guarded so an explicit light choice still wins over a dark OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          var(--midnight);
    --bg-raised:   #16202F;
    --bg-sunken:   #0A1119;
    --fg:          #F5EFE4;    /* warm white, never pure #fff */
    --fg-muted:    #A8B0BC;
    --fg-faint:    #6E7684;
    --rule:        #26303F;
    --rule-strong: #3A4658;
    --accent:      #D9B87C;    /* muted gold */
    --focus:       #8FB8E8;
  }
}
:root[data-theme="dark"] {
  --bg:          var(--midnight);
  --bg-raised:   #16202F;
  --bg-sunken:   #0A1119;
  --fg:          #F5EFE4;
  --fg-muted:    #A8B0BC;
  --fg-faint:    #6E7684;
  --rule:        #26303F;
  --rule-strong: #3A4658;
  --accent:      #D9B87C;
  --focus:       #8FB8E8;
}

/* --- 2. Base ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; }
img, svg { max-inline-size: 100%; }

body {
  margin: 0;
  background: var(--bg);          /* explicit — never inherit the host ground */
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur-calm) var(--ease-physical);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0;
  font-variation-settings: "SOFT" 30, "WONK" 1;   /* Fraunces: warm, not stiff */
}

p { margin: 0; max-width: 62ch; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { width: min(100% - 2.5rem, 1140px); margin-inline: auto; }
.stack > * + * { margin-top: var(--flow, var(--s-3)); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Signage voice — §18. Used sparingly, as the design system insists. */
.signage {
  font-family: var(--font-signage);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* --- 3. The O ----------------------------------------------------------- */
/* §6: window, portal, destination, loop. One shape, many jobs. */

.o {
  display: inline-block;
  inline-size: 1em; block-size: 1em;
  border: 0.115em solid currentColor;
  border-radius: 50%;
  position: relative;
  vertical-align: -0.09em;
}
/* The nick that makes it a window frame rather than a ring — the detail that
   lets the O be recognised without the wordmark (§7). */
.o::after {
  content: "";
  position: absolute;
  inset-block: 22%; right: -0.055em;
  inline-size: 0.115em;
  background: var(--bg);
}

.wordmark {
  display: inline-flex; align-items: center; gap: 0.42em;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-variation-settings: "SOFT" 40, "WONK" 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--fg);
}
.wordmark .o { font-size: 0.92em; }

/* --- 4. Header ---------------------------------------------------------- */

.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--rule);
}
.site-head .wrap {
  display: flex; align-items: center; gap: var(--s-2) var(--s-3);
  flex-wrap: wrap;                      /* the row itself must wrap, not just the nav */
  padding-block: var(--s-2);
}
.site-nav { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; }
.site-nav a {
  text-decoration: none; color: var(--fg-muted);
  font-size: var(--step--1);
  transition: color var(--dur-quick) var(--ease-physical);
}
.site-nav a:hover { color: var(--fg); }

/* On the home page the header sits OVER the station. A light bar butted against
   a dark scene read as a seam. */
.site-head--over {
  position: absolute; inset-inline: 0; top: 0;
  background: transparent; backdrop-filter: none; border: 0;
}
.site-head--over .wordmark { color: #F5EFE4; }
.site-head--over .site-nav a { color: #C6BEB2; }
.site-head--over .site-nav a:hover { color: #FFFFFF; }

/* --- 5. The station ----------------------------------------------------- */
/* §4. A quiet station at dusk, with a train waiting and its windows lit.
   The scene is real drawn art (assets/station.svg). The first attempt used
   three positioned divs for "depth" and rendered as a dark box with text on
   it — no platform, no canopy, no train. Always dark regardless of theme:
   it is a scene, not a surface, the same way a photograph does not invert. */

.station {
  position: relative;
  min-block-size: min(94vh, 820px);
  display: grid; align-items: center;
  overflow: hidden;
  background: #0B1220;
  color: #F5EFE4;
  isolation: isolate;
}

/* The source is an in-gallery photograph of an oil painting: green-cast and
   flat. Graded on its own layer so the type above is untouched. */
.station__art {
  position: absolute; inset: 0; z-index: 0;
  background: url("/assets/img/station.jpg") center 38% / cover no-repeat;
  filter: saturate(1.12) contrast(1.1) brightness(1.06) hue-rotate(-8deg);
}

/* Legibility scrim behind the copy only. The right half stays clear so the
   train and its lit windows are unobstructed — §5, they are the whole image. */
.station::before {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background:
    linear-gradient(96deg, #04070Efa 0%, #04070Eef 30%, #04070Ec9 46%, #04070E70 60%, #04070E12 76%, transparent 88%),
    linear-gradient(#05080F55 0%, transparent 26%, transparent 62%, #05080Fcc 100%);
}

.station__inner {
  position: relative; z-index: 2;
  padding-block: var(--s-5);
}
/* The scrim is darkest at the left, so the type lives there and the painting's
   lit station stays visible on the right. Cap the children, not the wrap —
   capping the wrap re-centres it into the brightest part of the image. */
.station__inner > * { max-inline-size: 30rem; }

.hero-title {
  font-size: var(--step-4);
  font-variation-settings: "SOFT" 50, "WONK" 1;
  max-inline-size: 12ch;
  text-shadow: 0 2px 30px #05080Faa;
}
.hero-sub {
  color: #D9D0C2; max-inline-size: 29ch;
  margin-top: var(--s-3); font-size: var(--step-1); line-height: 1.5;
}

/* The departure board (§4, §18): real signage carrying real navigation. */
.board {
  margin-top: var(--s-4);
  border: 1px solid #3B475C; border-radius: var(--radius);
  background: #070C16D9; backdrop-filter: blur(8px);
  padding: var(--s-3); max-inline-size: min(420px, 100%);
  box-shadow: 0 20px 60px -30px #000;
}
.board__head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-block-end: 1px solid #38455A; padding-block-end: var(--s-2);
}
.board__head .signage { color: #C9A96A; }
.board__row {
  display: grid; grid-template-columns: 1fr auto; gap: var(--s-2);
  padding-block: .7rem; border-block-end: 1px solid #1E2837;
  font-family: var(--font-signage); font-size: var(--step--1);
}
.board__row:last-child { border: 0; padding-block-end: 0; }
.board__row b { font-weight: 500; color: #F0E4CC; letter-spacing: .04em; }
.board__row span { color: #93A0B2; }

.hero-actions { margin-top: var(--s-4); display: flex; gap: .75rem; flex-wrap: wrap; }

/* A tall narrow box would squash a 1440x800 scene. Crop toward the train
   instead of distorting it, and let the scrim cover more of the frame. */
@media (max-width: 720px) {
  .wordmark { font-size: var(--step-0); }
  .site-nav { gap: var(--s-2); font-size: var(--step--1); }
  .site-nav a[href="#formats"] { display: none; }   /* three items do not fit; two do */
  .board__row { font-size: 0.78rem; }
  .board__head .signage { font-size: 0.7rem; letter-spacing: .1em; }

  .station {
    min-block-size: min(88vh, 640px);
    background: url("/assets/img/station.jpg") 58% center / cover no-repeat, #0B1220;
  }
  .station::before {
    background: linear-gradient(180deg, #060A12E8 0%, #060A129E 44%, #060A12DD 100%);
  }
  .station__inner > * { max-inline-size: 100%; }
  .hero-sub { max-inline-size: 30ch; }
}

/* --- 6. Buttons --------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 0.6em;
  padding: 0.78em 1.4em;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: transparent; color: inherit;
  font: inherit; font-size: var(--step--1);
  text-decoration: none; cursor: pointer;
  transition: transform var(--dur-quick) var(--ease-physical),
              background var(--dur-quick) var(--ease-physical),
              border-color var(--dur-quick) var(--ease-physical);
}
.btn:hover { transform: translateX(3px); }        /* directional — §10 */
.btn--solid {
  background: var(--fg); color: var(--bg); border-color: transparent;
}
.station .btn { border-color: #4A576B; color: #F5EFE4; }
.station .btn--solid { background: #F5EFE4; color: #101A2C; }

/* --- 7. Sections -------------------------------------------------------- */

section { padding-block: var(--s-6); }
.section-head { margin-block-end: var(--s-4); }
.section-head h2 { font-size: var(--step-3); }
.section-head p { color: var(--fg-muted); margin-top: var(--s-2); }

/* --- 8. Time chooser ---------------------------------------------------- */
/* §13: time is a product primitive. "How long is your while?" */

.whiles { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.while {
  padding: 0.7em 1.25em; border-radius: 999px;
  border: 1px solid var(--rule-strong); background: transparent;
  font: inherit; font-size: var(--step--1); color: var(--fg); cursor: pointer;
  transition: background var(--dur-quick) var(--ease-physical),
              color var(--dur-quick) var(--ease-physical),
              transform var(--dur-quick) var(--ease-physical);
}
.while:hover { transform: translateY(-2px); }
.while[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: transparent; }

/* --- 9. Windows --------------------------------------------------------- */
/* §15: a card is a portal. The image dominates; metadata stays quiet. */

.windows {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
}
.window {
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  background: var(--bg-raised); overflow: hidden;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
  transition: transform var(--dur-calm) var(--ease-physical),
              border-color var(--dur-calm) var(--ease-physical);
}
.window:hover { transform: translateY(-4px); border-color: var(--rule-strong); }
.window__view {
  aspect-ratio: 4 / 3; position: relative;
  background: var(--world, linear-gradient(140deg, var(--sky), var(--lilac)));
}
.window__view::after {           /* the O, as the frame the world sits behind */
  content: ""; position: absolute; inset: 12%;
  border: 1px solid #FFFFFF2E; border-radius: 50%;
}
.window__meta { padding: var(--s-3); }
.window__meta h3 { font-size: var(--step-1); }
.window__meta .signage { margin-top: var(--s-1); display: block; }

/* --- 10. Empty state ---------------------------------------------------- */
/* §26: even empty states belong to the world. This one is load-bearing —
   there is no catalogue yet, and the honest thing is to say so in voice. */

.platform-quiet {
  border: 1px dashed var(--rule-strong); border-radius: var(--radius-lg);
  padding: var(--s-5) var(--s-4); text-align: center;
  background: var(--bg-sunken);
}
.platform-quiet .o { font-size: 2.2rem; color: var(--fg-faint); }
.platform-quiet h3 { font-size: var(--step-2); margin-top: var(--s-3); }
.platform-quiet p { margin-inline: auto; margin-top: var(--s-2); color: var(--fg-muted); }

/* --- 11. Formats -------------------------------------------------------- */
/* §16: formats, not subjects. */

.formats { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); }
.format {
  font-family: var(--font-signage); font-size: var(--step--1);
  letter-spacing: 0.08em;
  padding: 0.45em 0.95em; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--fg-muted);
}

/* --- 12. Creator invitation --------------------------------------------- */
/* §17: makers of experiences. Never a SaaS panel. */

.invitation {
  border-block: 1px solid var(--rule);
  background: var(--bg-sunken);
}
.invitation .wrap {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: center;
}

/* --- 13. Footer --------------------------------------------------------- */

.site-foot {
  border-block-start: 1px solid var(--rule);
  padding-block: var(--s-4);
  color: var(--fg-muted); font-size: var(--step--1);
}
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.site-foot nav { margin-inline-start: auto; display: flex; gap: var(--s-3); }
.site-foot a { color: var(--fg-muted); }

/* --- 14. Docs (creator pages) ------------------------------------------- */

.doc { max-inline-size: 72ch; }
.doc h2 { font-size: var(--step-2); margin-top: var(--s-5); }
.doc h3 { font-size: var(--step-1); margin-top: var(--s-4); font-family: var(--font-body); font-weight: 600; }
.doc p, .doc li { color: var(--fg-muted); }
.doc code {
  font-family: var(--font-signage); font-size: 0.88em;
  background: var(--bg-sunken); padding: 0.15em 0.4em; border-radius: 5px;
  color: var(--fg);
}
.doc pre {
  background: var(--bg-sunken); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: var(--s-3);
  overflow-x: auto; font-size: var(--step--1);
}
.doc pre code { background: none; padding: 0; }

/* --- 15. Reduced motion ------------------------------------------------- */
/* §10 is built on motion, so honouring this properly matters: the scene must
   still READ as a station with everything held still. */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
