/* ── the header as a floating glass pill (2026-11-20, lab copy) ──────────────────────────────────────────────
   html[data-bar=a|b|c] (set before first paint by the inline line in index.html; ?bar=0 is the old solid header).
   The header's own box does not change: .top stays fixed, full width, --top-h tall, so everything that measures
   it (deck.js, live.js, notes.js, conn/a1, hero.js, matrix.js, landing.js) reads what it always read. The pill
   is .top-glass, a layer inside that box; topbar.js writes --p (0 the bar at the page's top, 1 the pill),
   --v (scroll speed, -1..1) and --sy (scrollY) on .top, and data-tone=dark|light for what lies under it.
   The glass is drawn from plain layers (see "the material" below): backdrop-filter is only an extra on top
   (his browser reports it supported and paints nothing). */
html[data-bar] .top,html[data-bar] .top.is-stuck,html[data-bar].is-dusk .top.is-stuck,html[data-bar][data-head=dark] .top.is-stuck{background:transparent;box-shadow:none}
html[data-bar] .top{--p:0;--o:0;--v:0;--sy:0;pointer-events:none;
  --pw:min(1080px,100% - 24px);--ph:50px;--gy:calc((var(--top-h) - var(--ph)) / 2);--gx:calc((100% - var(--pw)) / 2)}
html[data-bar] .top .top-in>*{pointer-events:auto}
@media (max-width:1180px){html[data-bar] .top{--pw:min(480px,100% - 20px)}}

/* the contents draw in with the glass: the row narrows to the pill, the mark a little smaller */
html[data-bar] .top .top-in{--w0:min(1180px,100% - 2*var(--gut));--w1:calc(var(--pw) - 10px);
  width:calc(var(--w0) + (var(--w1) - var(--w0)) * var(--p))}
html[data-bar] .top .brand{transform-origin:0 50%;transform:translateX(calc(var(--p) * 14px)) scale(calc(1 - .17 * var(--p)))}
html[data-bar] .top .top-tabs,html[data-bar] .top.is-stuck .top-tabs{opacity:1;transition:color .5s var(--ease);
  gap:clamp(12px,1.55vw,26px);margin-right:clamp(8px,1.2vw,20px)}
html[data-bar] .top .btn-top{box-shadow:none}

/* the glass */
.top-glass{display:none}
html[data-bar] .top-glass{display:block;position:absolute;z-index:-1;pointer-events:none;overflow:hidden;
  top:calc(var(--p) * var(--gy) + var(--o) * 10px);bottom:calc(var(--p) * var(--gy) + var(--o) * 10px);
  left:calc(var(--p) * var(--gx) + var(--o) * 3%);right:calc(var(--p) * var(--gx) + var(--o) * 3%);
  border-radius:calc(var(--p) * 30px);opacity:calc(var(--p) * 3);
  transition:background-color .5s var(--ease),box-shadow .5s var(--ease)}
html[data-bar] .top:not([style*="--p"]) .top-glass{visibility:hidden}
html[data-bar] .top-glass::before{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none}

/* ── the material (2026-11-22, his "not liquid glass ... basically a white slab ... it should be the same material,
   whatever is behind it"). ONE glass on every ground: one fill, one alpha, one rim, one sheen, one blur per strength.
   No tone swaps the glass; what lies under it shows through and tints it. Only the mark, the words and the button
   turn light over dark grounds (below), as a cross-fade.
   Built from plain layers, so it reads as glass where backdrop-filter paints nothing (his Mac):
   - fill: white at --ga, the only veil over what passes under
   - sheen (::before): light caught along the top edge, a faint return along the foot, a clearer middle
   - rim: a crisp 1px light edge inside (brighter on top, like a bevel) plus a 1px dark hairline outside; on a light
     ground the dark hairline draws the edge, on a dark one the light rim does. Both always there: one rim.
   Strengths: a clear, b balanced, c frosted. backdrop-filter (blur --gb) is only an extra on top. */
html[data-bar] .top-glass{--ga:.2;--gs:.5;--gr:.7;--gb:12px;
  background-color:rgba(255,255,255,var(--ga));
  box-shadow:inset 0 1px 0 rgba(255,255,255,var(--gr)),inset 0 -1px 0 rgba(255,255,255,calc(var(--gr) * .35)),
    inset 0 0 0 1px rgba(255,255,255,calc(var(--gr) * .4)),0 0 0 1px rgba(30,24,20,.13)}
html[data-bar] .top-glass::before{background:linear-gradient(180deg,
    rgba(255,255,255,var(--gs)) 0,rgba(255,255,255,calc(var(--gs) * .3)) 14%,rgba(255,255,255,0) 40%,
    rgba(255,255,255,0) 78%,rgba(255,255,255,calc(var(--gs) * .35)) 100%)}

/* ── A: clear. The ground passes under almost untouched; the glass is its edge and its light. ── */
html[data-bar=a] .top-glass{--ga:.14;--gs:.4;--gr:.8;--gb:4px}
/* ── B: balanced. A thin milk over what passes; it springs into shape and stretches with the scroll's speed
   (topbar.js). ── */
html[data-bar=b] .top-glass{--ga:.28;--gs:.4;--gr:.75;--gb:12px;
  transform:scale(calc(1 + .012 * max(var(--v),-1 * var(--v))),calc(1 - .07 * max(var(--v),-1 * var(--v))))}
/* ── C: frosted. Half milk: what passes under is there at half strength, so a black headline passing under the
   words is dimmed enough for them to stay on top. ── */
html[data-bar=c] .top-glass{--ga:.5;--gs:.4;--gr:.7;--gb:22px}

/* the extra, where it paints: the same layers over a blurred backdrop. Nothing above depends on it.
   html[data-nobf] (?nobf=1) switches it off, to see what his browser shows. */
@supports ((backdrop-filter:blur(2px)) or (-webkit-backdrop-filter:blur(2px))){
  html[data-bar]:not([data-nobf]) .top-glass{-webkit-backdrop-filter:blur(var(--gb)) saturate(1.5);backdrop-filter:blur(var(--gb)) saturate(1.5)}
}

/* what is on the glass follows what is under it (topbar.js: data-tone), whatever the page's own dusk says */
html[data-bar] .top:is([data-tone=dark],[data-tone=black]) .mark-dusk{opacity:1}
html[data-bar] .top:is([data-tone=dark],[data-tone=black]) .brand img:first-child{opacity:0}
html[data-bar] .top:is([data-tone=dark],[data-tone=black]) .btn-top{background:var(--cream);color:var(--ink)}
html[data-bar] .top:is([data-tone=dark],[data-tone=black]) .top-tabs{color:var(--cream)}
html[data-bar] .top[data-tone=light] .mark-dusk{opacity:0}
html[data-bar] .top[data-tone=light] .brand img:first-child{opacity:1}
html[data-bar] .top[data-tone=light] .btn-top{background:var(--ink);color:var(--cream)}
html[data-bar] .top[data-tone=light] .top-tabs{color:var(--ink)}
/* C's milk is thick enough that over a dark ground the glass itself reads light (dusk at half white is a warm
   grey): the light words would sink into it, so on C the mark, words and button stay dark on every ground. A and B
   are clear enough that the ground stays dark through them: there they turn light, as above. */
html[data-bar=c] .top:is([data-tone=dark],[data-tone=black]) .mark-dusk{opacity:0}
html[data-bar=c] .top:is([data-tone=dark],[data-tone=black]) .brand img:first-child{opacity:1}
html[data-bar=c] .top:is([data-tone=dark],[data-tone=black]) .btn-top{background:var(--ink);color:var(--cream)}
html[data-bar=c] .top:is([data-tone=dark],[data-tone=black]) .top-tabs{color:var(--ink)}
html[data-bar] .top .brand img,html[data-bar] .top .mark-dusk{transition:opacity .5s var(--ease)}
html[data-bar] .top .btn-top{transition:background-color .5s var(--ease),color .5s var(--ease),transform .2s var(--ease)}

@media (prefers-reduced-motion:reduce){
  html[data-bar] .top-glass,html[data-bar] .top .brand img,html[data-bar] .top .mark-dusk,html[data-bar] .top .btn-top,html[data-bar] .top .top-tabs{transition:none}
  html[data-bar=b] .top-glass{transform:none}
}
