/* ky-mode — THE DUALITY LAW. Pairs with ky/ky-mode.js (which owns WHEN
   html.ky-wallmode is stamped; this file owns WHAT each state paints).

     html.ky-wallmode          chrome is GLASS  (liquid-glass material, accent-
                               tinted via --lg-warm, opacity on the --kyg-alpha
                               knob)
     html:not(.ky-wallmode)    chrome is INK    (the pure black-ink honey look:
                               no backdrop-filter anywhere, opaque theme-token
                               plates, ink borders, hard print shadows)

   THE STRIP IS PAINT-ONLY, NEVER GEOMETRY. Ink mode replaces background /
   border-COLOR / box-shadow / backdrop-filter and nothing else: padding,
   border-width, radius and margins are exactly what the glass lane set, so a
   mode flip repaints without a single reflow and the wave engine can flip the
   mode mid-frame if it ever wants to.

   TWO PLATE GRADES IN INK MODE, deliberately:
     floating chrome (music bar, booking panel — anything position:fixed over
     arbitrary scrolled content) gets an OPAQUE --color-background plate with
     an ink border and a hard-offset print shadow: it must be legible over
     whatever it happens to float above, and translucency is exactly what the
     ink state forbids.
     in-flow chrome (#ky-cal in the hero) goes BARE — numerals straight on the
     honey ground, which is what shipped in Honey & Ink. It sits ON the page,
     not over it; a plate there would be chrome for chrome's sake.

   CASCADE AUDIT — every rule below names what it out-guns and how. The two
   hard opponents:
     (1) ky/liquid-glass.js writes an INLINE  backdrop-filter:url(#lg2-f-…)…
         on every lensed .lg-surface. Inline beats any non-important author
         rule, so every backdrop-filter:none in the ink section carries
         !important (an author !important beats a non-important inline style).
     (2) ky/liquid-glass.css  [data-glass] .lg-surface[data-lg-inflow]
         { backdrop-filter:…!important }  — (0,3,0) WITH !important. Between
         two !importants, specificity decides, so every ink selector here is
         prefixed  html:not(.ky-wallmode)[data-glass]  ≥ (0,2,1), lifting the
         generic surface rule to (0,3,1) > (0,3,0).
   ID-specificity opponents ((1,…) — class-count can never beat an ID, which
   is why the generic rule alone is NOT enough) get their own ID-level
   overrides below: #ky-cal (ky-cal.css (1,0,0) + glassify (1,1,0)),
   #ky-cal-panel (ky-cal.css (1,0,0)), #ky-cal-scrim (1,0,0),
   #Contact (+ wells) (ky-glassify.css (1,1,0) / (1,2,2)), and the switcher
   row's dotpill vs  #ky-sw.nofx .ky-zine .dotpill  (1,3,0).

   Other lanes: use .ky-glass / .lg-surface and design both states. These
   rules are the BASELINE gate; a lane may out-specific them for its own
   chrome (the contact card's --kyg-alpha-hi below is exactly that hook).

   Exempt on purpose: #ky-sw / #ky-devwall (dev chrome, not the site),
   #ky-cinema-exit / #ky-cinema-hint (cinema implies wallmode — they can
   never be seen in ink mode).                                              */

/* ═══════════════════════════════════════════════════════════════════════
   0. THE KNOBS  (both modes — other lanes read these)
   --kyg-alpha     glass surface opacity. Defaults to the material's own
                   --lg-tint (14% light / 20% dark-lum / 6% on slide's
                   Apple-tuned pane), so declaring it changes NOTHING until a
                   lane overrides it on an element — then the wallmode mapping
                   in section 2 feeds it into both glass recipes.
   --kyg-alpha-hi  the "less transparent" plate the contact band uses over
                   its wallpaper (the owner's ask: same wallpaper behind the
                   contact card, but through a denser pane).
   ═══════════════════════════════════════════════════════════════════════ */
html[data-glass]{
  --kyg-alpha: var(--lg-tint, 14%);
  --kyg-alpha-hi: 55%;
}

/* ═══════════════════════════════════════════════════════════════════════
   1. INK MODE   html:not(.ky-wallmode) — the pure black-ink honey look
   ═══════════════════════════════════════════════════════════════════════ */

/* (1a) the generic strip + print plate — every glass surface at once.
   Out-guns: [data-glass] .ky-glass (ky-glassify.css, (0,2,0)) and
   [data-glass] .lg-surface (liquid-glass.css, (0,3,0) at its [data-lg-inflow]
   strongest) by specificity (0,3,1); the engine's inline lens by !important.
   border-COLOR only — the glass 1px border stays 1px (geometry law); the
   inset hairline in the shadow fattens the edge to read ~2px without moving
   a single box. The 6px/8px zero-blur offset is the print-register shadow:
   hard, like an off-register second pass, in the theme's own ink. */
html:not(.ky-wallmode)[data-glass] :is(.ky-glass, .lg-surface){
  background: var(--color-background, #F7EDD3);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-color: color-mix(in srgb, var(--color-foreground, #14110A) 85%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--color-foreground, #14110A) 12%, transparent),
    0 1px 0 color-mix(in srgb, var(--color-foreground, #14110A) 22%, transparent),
    6px 8px 0 -5px color-mix(in srgb, var(--color-foreground, #14110A) 16%, transparent);
}

/* (1b) the engine's specular ring/glare span is glass furniture — a conic
   highlight on an opaque ink plate reads as a rendering error. display:none
   rather than opacity: the engine's pointer handlers keep writing its vars
   (deliberately left running so a flip back to wallmode is instant), and a
   hidden span costs none of that paint. */
html:not(.ky-wallmode)[data-glass] .lg2-spec{ display: none; }

/* (1c) header pills — defensive only (ky-glassify.js currently STRIPS these
   classes from the header on its guard, but a cached copy or a future lane
   may re-add them). Paint off, geometry kept: the nav <ul>'s margin-right is
   a collision fix for #ky-sw, not decoration, and zeroing the padding would
   shift the header between modes. Same (0,3,1), placed AFTER (1a) so source
   order wins the tie against the generic plate. */
html:not(.ky-wallmode)[data-glass] .ky-glass-pill{
  background: none;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* (1d) the hero calendar goes BARE — in-flow content, not floating chrome
   (see the header). Out-guns the generic plate above and glassify's desktop
   [data-glass] #ky-cal (1,1,0) at (1,2,1). Killing the background here also
   kills ky-cal.css's own hover/focus wash (#ky-cal:hover, (1,1,0)), so the
   affordance is re-declared one notch higher — same recipe, same tokens. */
html:not(.ky-wallmode)[data-glass] #ky-cal{
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
html:not(.ky-wallmode)[data-glass] #ky-cal:hover,
html:not(.ky-wallmode)[data-glass] #ky-cal:focus-visible{
  background: color-mix(in srgb, var(--color-foreground, #14110A) 7%, transparent);
}

/* (1e) the booking panel: floating chrome -> opaque print plate.
   Out-guns ky-cal.css #ky-cal-panel (1,0,0) frost recipe at (1,2,1); the
   panel is a lensed fixed .lg-surface, so the !important pair is load-bearing
   against the engine's inline filter. A slightly deeper print shadow than
   (1a): this surface floats over the whole page, not over one band. */
html:not(.ky-wallmode)[data-glass] #ky-cal-panel{
  background: var(--color-background, #F7EDD3);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-color: color-mix(in srgb, var(--color-foreground, #14110A) 85%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--color-foreground, #14110A) 12%, transparent),
    0 1px 0 color-mix(in srgb, var(--color-foreground, #14110A) 24%, transparent),
    10px 12px 0 -8px color-mix(in srgb, var(--color-foreground, #14110A) 18%, transparent);
}

/* (1f) the panel's scrim: a SHADE, not a pane — its translucent ink wash is
   how the page settles back while the panel is up, so the wash stays; only
   the blur is glass, and only the blur goes. Out-guns #ky-cal-scrim (1,0,0)
   at (1,2,1). */
html:not(.ky-wallmode)[data-glass] #ky-cal-scrim{
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* (1g) the contact card: opaque INK plate, not a cream one. The card's band
   is a hardcoded near-black gradient and every text rule inside it (including
   ky-glassify.css's !important input ink, which stays in force — it is
   [data-glass]-scoped, not mode-scoped) is tuned light-on-dark. The plate is
   therefore floored at BLACK and only warmed by the theme ground — NOT built
   from --color-foreground, which inverts to bright yellow on Noir and would
   put near-white text on it. Out-guns [data-glass] #Contact (1,1,0) at
   (1,2,1). */
html:not(.ky-wallmode)[data-glass] #Contact{
  background: color-mix(in srgb, #000 82%, var(--color-accent-200, #E3AC33));
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-color: color-mix(in srgb, #fff 14%, transparent);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent),
    0 24px 48px -28px rgba(0, 0, 0, .6);
}
/* the form wells: blur off (glass), and a real dark fill on. The fill needs
   !important because <style id="ky-switch"> ships a blanket
   `input,textarea{background:transparent !important}` — between importants
   this (1,3,3) beats its (0,0,1). Without a fill, deblurred wells on the ink
   plate would be border-only ghosts. */
html:not(.ky-wallmode)[data-glass] #Contact form.gform input,
html:not(.ky-wallmode)[data-glass] #Contact form.gform textarea{
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: color-mix(in srgb, #000 38%, transparent) !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   2. WALLMODE   html.ky-wallmode — glass ON, accent-tinted, knob-driven.
   The material itself still lives in liquid-glass.css / ky-glassify.css —
   nothing here re-declares frost, rim or blur (single-owner rule). This
   section only re-routes two of the material's existing inputs.
   ═══════════════════════════════════════════════════════════════════════ */

/* (2a) opacity knob mapping, declared ON the surfaces (not on :root) so a
   per-element --kyg-alpha override re-resolves — custom properties inherit
   as COMPUTED values, so a root-level `--lg-tint:var(--kyg-alpha)` would
   freeze at the root's alpha and the contact card's raise would be dead.
   Both spellings are fed because ky-glassify.css resolves its --kyg-tint
   from --lg-tint at the ROOT (already computed by the time it inherits).
   Out-guns nothing at rest: --kyg-alpha defaults to var(--lg-tint), so this
   is an identity mapping until a lane turns the knob — which also means
   slide.html's own 6% tune ((0,3,1) html[data-ky-slide][data-glass]) flows
   through unchanged.
   Usage (contact lane, per the brief):  set `--kyg-alpha: var(--kyg-alpha-hi)`
   on the card element or any ancestor — the recipes follow. */
html.ky-wallmode[data-glass] :is(.ky-glass, .lg-surface){
  --lg-tint: var(--kyg-alpha, 14%);
  --kyg-tint: var(--kyg-alpha, 14%);
}

/* (2b) accent tint: the pane's surface colour carries the current wallpaper's
   accent. --lg-warm is already the accent channel — slide.html's retint()
   stamps it inline per wallpaper and the index wave engine does the same on
   ky:wall-theme commit — so folding 16% of it into the tint colour makes
   every pane follow the plate with zero coupling. (0,3,1) vs
   liquid-glass.css's [data-glass] declaration at (0,1,0): specificity
   wins. Scoped :not([data-ky-slide]) because slide already folds the accent
   into --color-background itself (retint()'s surface mix) and doubling the
   fold measured as a visible cast on the clear 6% pane. */
html.ky-wallmode[data-glass]:not([data-ky-slide]){
  --lg-surface: color-mix(in srgb,
    var(--lg-warm, var(--color-accent-600, #C4901D)) 16%,
    var(--color-background, #F7EDD3));
  --kyg-surface: var(--lg-surface);
}

/* PERF LAW note: this section adds NO backdrop-filter anywhere — the only
   filters in wallmode are the ones the glass files already own, and their
   [data-lg-inflow] plain-blur demotion stays fully in force. Ink mode only
   ever REMOVES filters. Nothing in this file can put a lens in a scroller. */

/* ═══════════════════════════════════════════════════════════════════════
   3. THE FLIP  — html.ky-modeanim rides for ~480ms around a USER-driven
   mode change (ky-mode.js). Only the interpolable paint eases (the final
   background layer's color, the border, the shadow); the gradient image
   layers snap underneath the ease, which reads as the plate "developing"
   rather than as a fade. Never applied on the parse-time stamp.
   ═══════════════════════════════════════════════════════════════════════ */
html.ky-modeanim :is(.ky-glass, .lg-surface),
html.ky-modeanim #ky-cal-panel,
html.ky-modeanim #Contact{
  transition:
    background-color .32s cubic-bezier(.22,1,.36,1),
    border-color     .32s cubic-bezier(.22,1,.36,1),
    box-shadow       .32s cubic-bezier(.22,1,.36,1);
}

/* ═══════════════════════════════════════════════════════════════════════
   4. THE SWITCH ROW  (#ky-mode-row, built by ky-mode.js into #ky-sw-panel)
   Inherits the panel's own .ky-zine / .dotpill vocabulary from the inline
   #ky-sw styles — only the STATE rules live here, and they are armoured:
   the inline sheet keys the fx pill's off-state to #ky-sw.nofx .ky-zine
   .dotpill (1,3,0), which would drag THIS pill off whenever liquid type is
   off. Every rule below is (2,2,0) so this row's .off class — and only it —
   decides the knob.
   ═══════════════════════════════════════════════════════════════════════ */
#ky-sw #ky-mode-row:not(.off) .dotpill{ background: #3a7d44; }
#ky-sw #ky-mode-row:not(.off) .dotpill::after{ left: 14px; }
#ky-sw #ky-mode-row.off .dotpill{ background: #555; }
#ky-sw #ky-mode-row.off .dotpill::after{ left: 2px; }

/* ═══════════════════════════════════════════════════════════════════════
   5. A11Y
   ═══════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce){
  html.ky-modeanim :is(.ky-glass, .lg-surface),
  html.ky-modeanim #ky-cal-panel,
  html.ky-modeanim #Contact{ transition: none !important; }
  #ky-sw #ky-mode-row .dotpill,
  #ky-sw #ky-mode-row .dotpill::after{ transition: none !important; }
}
/* prefers-reduced-transparency needs nothing new: ink mode is ALREADY the
   most opaque state, and in wallmode the glass files' own reduce rules
   (liquid-glass.css / ky-glassify.css) force their near-opaque fallbacks. */
