/* Shared design tokens (FE-4). The neutral palette both static pages build on;
   previously copy-pasted into each page's :root. Page-specific tokens (admin's
   --card/--text/--side/--ok/--bad, gallery's --ink/--surface/--box-bg and the
   font stacks) and admin's dark-mode overrides stay in each page's own \3c style>. */
:root {
  color-scheme: light;
  --bg: #fafaf8;
  --muted: #6f6e68;
  --line: #e8e6e0;
  --accent: #8a5a2b;
  --accent-hover: #74491f;

  /* --- Editorial-futurism foundation (shared vocabulary; the console mirrors
     these in console/src/styles.css). Surfaces compose the helper classes
     below instead of re-declaring the recipe. Radii, glow and the glass fill
     are theme-neutral — glow/fill re-derive from --accent/--surface so they
     re-tint per theme. Only the two polarity-dependent pieces (drop-shadow
     strength and the hairline edge/top-sheen colour) are overridden in the
     dark blocks: on a light surface the top light must be near-white and the
     edge a faint dark hairline; on a dark surface both invert. */
  --radius-card: 14px;
  --radius-ctl: 9px;
  --glow-accent: 0 0 30px -4px color-mix(in srgb, var(--accent) 55%, transparent);
  --glass-fill: color-mix(in srgb, var(--surface, var(--bg)) 62%, transparent);
  --glass-edge: rgba(0, 0, 0, 0.08);
  --glass-blur: 12px;
  /* Light surface: soft diffused drop + a bright inset top sheen. */
  --elev-1: 0 8px 20px -8px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --elev-2: 0 20px 45px -18px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.8);

  /* --- Prism design language, foundation layer (PR 0) ----------------------
     The refracted warm band. Five stops derived to sit against the charcoal
     ground and to read as one spectrum, not five hues — they are the shared
     vocabulary the beam (PR 1), spectral text fills, and edge-light draw from.
     The palette itself is unchanged; this is light passing through it. */
  --spec-1: #e9b978;
  --spec-2: #e59a5b;
  --spec-3: #d97b6b;
  --spec-4: #c76b86;
  --spec-5: #a9739e;
  /* The spectrum as a ready-made linear band (135deg), for background-clip text
     fills and edge-light gradients. */
  --spectrum: linear-gradient(100deg, var(--spec-1), var(--spec-2), var(--spec-3), var(--spec-4), var(--spec-5));

  /* Optics/spring easing curves — the app's two motion signatures. --ease-optic
     is the camera settle (rack-focus, reveals); --ease-spring is weighted
     momentum (hover lifts, magnetism). */
  --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-optic: cubic-bezier(0.16, 1, 0.3, 1);

  /* Filmic finish. Grain is texture, not a filter — kept subtle. Halation is a
     warm bloom around bright/accent elements. */
  --grain-opacity: 0.035;
  /* The noise tile itself, shared by the app-wide grain below and the landing
     hero's own blended grain layer. */
  --grain-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --halation-size: 22px;
  --halation-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Registered so the masthead's variable-weight axes can be animated/transitioned
   as numbers (PR 0 Living Masthead). Where @property is unsupported the vars
   still apply, they just won't tween — a graceful, static degrade. */
@property --fp-wght {
  syntax: "<number>";
  inherits: false;
  initial-value: 600;
}
@property --fp-opsz {
  syntax: "<number>";
  inherits: false;
  initial-value: 40;
}

/* Semantic dark theme shared by the platform landing page AND client galleries
   (UI-8.5 — the fixed-light constraint on galleries has been lifted). Admin
   carries its own richer palette in admin.css. It applies two ways:

     • Explicit override — an ancestor carries `data-theme="dark"`, set by each
       page's before-paint script from `localStorage.fp_theme`. The selector
       `:root[data-theme="dark"]` (specificity 0,2,0) wins over any plain `:root`
       light block regardless of stylesheet order.
     • System preference — with no stored override the page leaves `data-theme`
       unset, so the `prefers-color-scheme` block below drives the theme and
       follows live OS changes. It is scoped to `:not([data-theme="light"])` so
       an explicit light override always wins. The landing always sets
       `data-theme`, and admin.css (loaded after this file) redefines every one
       of these tokens, so neither page's appearance changes.

   The warm palette (Direction B): a deep warm black, never blue-black, with the
   contrast widened — brighter ink, a brighter amber accent, and a more saturated
   spectrum that reads as light against the dark ground. The light theme keeps
   the base ramp above: the brighter stops would glare on near-white. Measured
   (WCAG): ink 18.2:1 on --bg and 17.1:1 on --surface, muted 6.7 / 6.3, accent
   9.6 / 9.0, --on-accent 9.4:1 on the accent fill. --on-accent is the text laid
   over the accent fill: white reads on the light-theme accent, near-black on the
   dark one. console/src/styles.css mirrors this dark spectrum (it's always dark). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0a09;
    --ink: #f8f5ef;
    --muted: #9c9587;
    --line: #26231f;
    --surface: #151210;
    --accent: #e7a860;
    --accent-hover: #f4c98c;
    --on-accent: #120c05;
    --spec-1: #f6c983;
    --spec-2: #ee9f5a;
    --spec-3: #e1705f;
    --spec-4: #ce5f84;
    --spec-5: #9e63b0;
    /* Dark surface: deeper drop shadow + a faint white top sheen and edge. */
    --glass-edge: rgba(255, 255, 255, 0.14);
    --elev-1: 0 8px 20px -8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --elev-2: 0 20px 45px -18px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0a09;
  --ink: #f8f5ef;
  --muted: #9c9587;
  --line: #26231f;
  --surface: #151210;
  --accent: #e7a860;
  --accent-hover: #f4c98c;
  --on-accent: #120c05;
  --spec-1: #f6c983;
  --spec-2: #ee9f5a;
  --spec-3: #e1705f;
  --spec-4: #ce5f84;
  --spec-5: #9e63b0;
  --glass-edge: rgba(255, 255, 255, 0.14);
  --elev-1: 0 8px 20px -8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --elev-2: 0 20px 45px -18px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Reset/utility rules shared verbatim by both static pages (admin.html and
   gallery.html), previously copy-pasted into each page's \3c style>. Same spirit
   as the token block above: only rules identical across both pages live here;
   anything page-specific stays in each file. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* --- Composable surface helpers (editorial-futurism foundation) ------------
   Frosted panels, layered elevation and the one-accent glow, so each surface
   pulls the recipe from here instead of restating it. The gradient border uses
   the masked padding-box technique so it renders on translucent cards: a 1px
   pseudo-element painted with the gradient, then masked to a ring by XOR-ing a
   content-box fill against a full fill. Motion added by consumers (hover lifts,
   glow pulses) is covered by the reduced-motion kill-switch above. */
.glass {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-edge);
}
.elev-1 { box-shadow: var(--elev-1); }
.elev-2 { box-shadow: var(--elev-2); }
.glow { box-shadow: var(--glow-accent); }
.grad-border { position: relative; }
.grad-border::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 75%, transparent),
    color-mix(in srgb, var(--accent) 10%, transparent) 55%,
    transparent 80%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* --- Filmic finish (Prism PR 0) --------------------------------------------
   App-wide grain skin, shared by every page that loads tokens.css (landing,
   admin, gallery). A single fixed, non-interactive overlay carrying a static
   SVG feTurbulence noise tile as a data-URI background — the browser rasterises
   the turbulence once when it decodes the image, then tiles it, so there is no
   per-frame filter cost. Deliberately shipped with plain low opacity and NO
   mix-blend-mode: a full-viewport, always-on-top blend would put a compositing
   pass over every page's scrolling content, which we won't spend app-wide. The
   landing hero, a single static stage, carries its own blended grain instead
   (landing.css .stage-grain). Purely static, so it is inherently reduced-motion
   safe (nothing to freeze). */
html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: var(--grain-tile);
  background-repeat: repeat;
}
@media print {
  html::after { display: none; }
}

/* Halation: a warm bloom around bright/accent elements, the darkroom glow. Uses
   drop-shadow (composited, not layout) so it blooms around the element's actual
   shape, not its box. Consumers add it to at most a couple of hero elements. */
.halation {
  filter:
    drop-shadow(0 0 var(--halation-size) var(--halation-color))
    drop-shadow(0 0 calc(var(--halation-size) * 2) color-mix(in srgb, var(--accent) 22%, transparent));
}

/* --- Bokeh (Prism PR 2, shared by the landing hero and the gallery entry): idle
   out-of-focus light points drifting behind the subject — the camera's
   depth-of-field made ambient. Transform-only drift on a slow loop (frozen by
   the reduced-motion kill-switch above), colours drawn from the warm spectrum at
   low opacity. lib/prism.js sets :root[data-prism="lite"] on weak/coarse/low-
   memory devices, which removes it entirely. Each page positions the layer
   (z-index) for its own stacking. --- */
.bokeh { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.bokeh span {
  position: absolute; border-radius: 50%; filter: blur(16px); opacity: 0.5;
  animation: bokeh-drift 26s ease-in-out infinite alternate;
}
.bokeh span:nth-child(1) { width: 92px; height: 92px; left: 12%; top: 24%; animation-duration: 24s;
  background: radial-gradient(circle, color-mix(in srgb, var(--spec-1) 55%, transparent), transparent 70%); }
.bokeh span:nth-child(2) { width: 58px; height: 58px; left: 67%; top: 15%; animation-duration: 31s; animation-direction: alternate-reverse;
  background: radial-gradient(circle, color-mix(in srgb, var(--spec-3) 50%, transparent), transparent 70%); }
.bokeh span:nth-child(3) { width: 124px; height: 124px; left: 79%; top: 54%; animation-duration: 35s;
  background: radial-gradient(circle, color-mix(in srgb, var(--spec-4) 45%, transparent), transparent 70%); }
.bokeh span:nth-child(4) { width: 46px; height: 46px; left: 28%; top: 64%; animation-duration: 28s; animation-direction: alternate-reverse;
  background: radial-gradient(circle, color-mix(in srgb, var(--spec-5) 50%, transparent), transparent 70%); }
.bokeh span:nth-child(5) { width: 76px; height: 76px; left: 48%; top: 40%; animation-duration: 39s;
  background: radial-gradient(circle, color-mix(in srgb, var(--spec-2) 42%, transparent), transparent 70%); }
@keyframes bokeh-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(16px, -22px, 0); }
}
:root[data-prism="lite"] .bokeh { display: none; }

/* focal-crop:start — identical copy in portfolio-base.css (the public
   portfolio); tests/focal-crop-css.test.js keeps them in step. */
/* Focal-point crops (plan 04 §5.2). A .crop frame cover-crops its <img> so
   the image's focal point (--fx, --fy: 0–1, set per frame by a nonce'd fp-*
   rule or, in the JS pages, through the CSSOM) sits at the frame centre,
   clamped so no empty edge shows. --ar is the image's width / height. Only
   the frame's own image (directly, or in a display:contents <picture>).

   Fallback (no container units): object-position f% keeps the point inside
   the frame, though not centred. */
.crop > img, .crop > picture > img { object-fit: cover; object-position: calc(var(--fx, 0.5) * 100%) calc(var(--fy, 0.5) * 100%); }

/* Exact: the covering image is --w × --h; offset it so the point is centred,
   clamped to [frame − image, 0]. The frame is a size container, so its own
   box is the only input — the crop is right at every breakpoint. A .crop
   frame must be sized without its image (explicit height, aspect-ratio, or
   stretch): size containment ignores content. No --ar (dimensions unknown)
   makes the declaration invalid, and the image falls back to a centred crop
   rather than a guessed offset that could expose an edge. The overflow is
   taken 1px short: a tier's integer size makes its real shape differ from
   --ar by up to half a pixel per edge, and erring short can't open a gap. */
@supports (width: 1cqw) {
  .crop { container-type: size; }
  .crop > img, .crop > picture > img {
    --w: max(100cqw, 100cqh * var(--ar) - 1px);
    --h: max(100cqh, 100cqw / var(--ar) - 1px);

    object-position:
      clamp(100cqw - var(--w), 50cqw - var(--fx, 0.5) * var(--w), 0px)
      clamp(100cqh - var(--h), 50cqh - var(--fy, 0.5) * var(--h), 0px);
  }
}
/* focal-crop:end */
