/* Octinity — surfaces. A block stands on paper or on graphite, and the surface answers every role a component asks
   for: its ink, its muted and soft inks, its hairlines, the signal as text, its error and success. A component
   never names a hue; it says `var(--o-line)` and is right on both. Without a surface class the page reads as paper.

   Each role is written once, as `light-dark(paper, graphite)`; the surface only says which it is (`color-scheme`), and
   everything inside reads the side it stands on. `.o-light` and `.o-dark` are fixed — a page's rhythm of paper and
   graphite. `.o-theme` is the reader's: a service's ground that follows the theme they chose (`data-scheme` on the
   root, set by scripts/octinity/theme.ts) or their system's. What a colour function cannot switch — a drawn ground,
   a logo's file — is switched by `:is(.o-dark, [data-scheme='dark'] .o-theme)`.

   Then the grounds a surface may carry, each for its own job: the hero's vignette and the header's warm light on
   graphite, the column grid, the construction field of crosses, the signal hatch of a range and the quiet hatch
   under a curve, and the floor that fades a figure out. */
@layer theme, base, components, utilities;
@layer components {
:root {
  color-scheme: light;
  --o-bg: light-dark(var(--o-paper), var(--o-graphite));
  --o-raised: light-dark(var(--o-paper-raised), var(--o-panel));
  --o-ink: light-dark(var(--o-ink-on-paper), var(--o-ink-on-graphite));
  --o-ink-strong: light-dark(var(--o-ink-strong-on-paper), #ffffff);
  --o-ink-muted: light-dark(var(--o-ink-muted-on-paper), var(--o-ink-muted-on-graphite));
  --o-ink-soft: light-dark(var(--o-ink-soft-on-paper), var(--o-ink-soft-on-graphite));
  --o-line: light-dark(var(--o-line-on-paper), var(--o-line-on-graphite));
  --o-line-strong: light-dark(var(--o-line-strong-on-paper), var(--o-line-strong-on-graphite));
  --o-accent: light-dark(var(--o-signal-text), var(--o-signal));
  --o-band-ink: light-dark(#b9bdb0, #4f584c);
  --o-error: light-dark(var(--o-error-on-paper), var(--o-error-on-graphite));
  --o-success: light-dark(var(--o-success-on-paper), var(--o-success-on-graphite));
  --o-focus: var(--o-accent);    /* the focus ring: the signal's text role on paper (4.57:1), the signal on graphite (6.71:1) */
  --o-focus-w: 2px;
}
.o-light { color-scheme: light; background: var(--o-paper); color: var(--o-ink-on-paper); }
.o-dark { color-scheme: dark; background: var(--o-graphite); color: var(--o-ink-on-graphite); }
/* The reader's surface: paper or graphite as they chose (`data-scheme` on the root, scripts/octinity/theme.ts), or
   as their system is set before the script has said. */
.o-theme { color-scheme: light dark; background: var(--o-bg); color: var(--o-ink); }
[data-scheme='light'] .o-theme, .o-theme[data-scheme='light'] { color-scheme: light; }
[data-scheme='dark'] .o-theme, .o-theme[data-scheme='dark'] { color-scheme: dark; }
.o-raised { background: var(--o-raised); }
/* A band set back from the paper: its ground is darker, so it answers with a step darker inks of its own. */
.o-sunk { background: var(--o-paper-sunk); --o-ink-muted: #565f56; --o-ink-soft: #5d665f; --o-accent: #9c4f25; --o-focus: #9c4f25; }

/* ── Grounds ─────────────────────────────────────────────────────────────────────────────────────────────── */
/* The opening's ground: lighter where the figure stands, falling off to the edge — on graphite, and on paper as faintly. */
.o-vignette { background: radial-gradient(ellipse at var(--vignette-at, 52% 67%), light-dark(#fbf9f3, #333b34) 0%, light-dark(#f4f1e8, #232925) 32%, light-dark(var(--o-paper), var(--o-graphite)) 69%); }
/* A warm light over the action: under a header's request, behind a banner's figure. Layered over the surface. */
.o-glow { background-image: radial-gradient(var(--glow-size, 560px 130px) at var(--glow-at, 86% 0%), var(--o-signal-tint), transparent 72%); }
/* The plotting grid: a figure's field and a short opening, never under long text, a form or a screenshot. */
.o-grid { background-image: linear-gradient(var(--o-grid-ink) 1px, transparent 1px), linear-gradient(90deg, var(--o-grid-ink) 1px, transparent 1px); background-size: var(--o-grid-step, 38px) var(--o-grid-step, 38px); }
/* The columns of a plan: twelve faint hairlines across the measure. */
.o-columns { background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 12 - 1px), var(--o-grid-ink) 0 calc(100% / 12)); }
/* The construction field: a cross every step, as on the portraits' sheet. */
.o-crosses { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38'%3E%3Cpath d='M19 14v11M13.5 19.5h11' stroke='%239aa293' stroke-width='1'/%3E%3C/svg%3E"); background-size: var(--o-grid-step, 38px) var(--o-grid-step, 38px); }
:is(.o-dark, [data-scheme='dark'] .o-theme) .o-crosses, :is(.o-dark, [data-scheme='dark'] .o-theme).o-crosses { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38'%3E%3Cpath d='M19 14v11M13.5 19.5h11' stroke='%23525b53' stroke-width='1'/%3E%3C/svg%3E"); }
/* A range in the signal: a warranty, a window of time. Hatched in a frame of its own. */
.o-hatch { --hatch: var(--o-signal); border: 1px solid color-mix(in srgb, var(--hatch) 40%, transparent); background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--hatch) 20%, transparent) 0 1.5px, transparent 1.5px 5px); }
/* The quiet hatch under a curve or over a cut. */
.o-hatch-soft { background: repeating-linear-gradient(-45deg, var(--o-grid-ink) 0 1px, transparent 1px 7px); }
:root { --o-grid-ink: light-dark(rgb(95 103 89 / 8%), rgb(176 184 174 / 8%)); }
}
