/* The top dock — the header as a floating, rounded dock, and the tab row as a
   tray that comes out from under it. Behaviour: renderer/top-dock.js.
   Notes: docs/claude/ui.md ("The top dock").

   Rober, 2026-11-24: "round the top header into a modern dock. The second bar
   should maybe only dynamically appear with a cool animation on hover of main
   dock."

   Direction: the house style (walnut plate, brass hairline, ember for what is
   lit), the same material as a lane's dock (media/dock.css .hdock) so the two
   read as one family: a rounded plate standing clear of the window's edges.

   What is a box and what is paint:
     header.topbar   still the full-width strip, in the flow. It keeps its
                     padding box, so topbar.js "Measured fit", chrome-fold.js
                     and the shell's drag region read it exactly as before.
     ::before        the dock itself: the rounded plate, drawn inside the strip.
     nav.view-tabs   the tray. Shown mode: a second rounded plate in the flow.
                     Tray mode (body.tabs-tray): out of the flow, under the
                     dock, on screen only while body.tabs-open.

   Loaded after topbar.css and chrome-fold.css. */

body {
  --tdock-gap: 6px;          /* air above and below a plate */
  --tdock-side: 14px;        /* air left and right of a plate */
  --tdock-pad: 7px;          /* a plate's edge to the 38px capsules in it */
  --tdock-r: 26px;           /* concentric with the capsules: 19px + the pad */
  --tabs-r: 20px;
  --tdock-brass: 198, 160, 94;
  --tdock-ember: 245, 158, 11;
  --tdock-ease: cubic-bezier(.16, 1, .3, 1);
  --tdock-spring: cubic-bezier(.3, 1.35, .45, 1);   /* the chip's icon only: nothing you aim at overshoots */
  /* Everything above a view: the strip, and the tray when it is in the flow.
     top-dock.js measures the real thing into this; these are what the measure
     comes to, so the first paint is already right. */
  --chrome-h: 110px;
}
body.tabs-tray { --chrome-h: 64px; }

/* ─── the dock ──────────────────────────────────────────────────────────── */

header.topbar {
  padding: calc(var(--tdock-gap) + var(--tdock-pad)) calc(var(--tdock-side) + 14px);
  border-bottom: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  /* The old bar's backdrop-filter made it the containing block of every
     fixed-position popover inside it, and their placement was written against
     that. The blur moved to the plate; this keeps the popovers where they were. */
  contain: layout;
}
header.topbar::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: var(--tdock-gap) var(--tdock-side);
  border: 1px solid rgba(var(--tdock-brass), .26);
  border-radius: var(--tdock-r);
  background:
    /* the hearth behind the mark */
    radial-gradient(360px 64px at 6% -18%, rgba(var(--tdock-ember), .13), transparent 72%),
    /* lamplight from above */
    linear-gradient(180deg, rgba(255, 236, 202, .065) 0%, transparent 46%),
    /* the plate */
    linear-gradient(180deg, rgba(46, 34, 25, .9) 0%, rgba(26, 19, 14, .93) 58%, rgba(15, 11, 9, .95) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 233, 196, .15),
    inset 0 -1px 0 rgba(0, 0, 0, .5),
    0 16px 30px -18px rgba(0, 0, 0, .9),
    0 2px 6px rgba(0, 0, 0, .3);
  pointer-events: none;
  /* No backdrop-filter and no transition here, on purpose. In the flow nothing
     passes behind the plate (the views start under the strip), so a blur would
     be re-run on every frame for a picture nobody can see; and a border or
     shadow that eases is a repaint of the whole plate per frame. Only the fold's
     overlay, which does come down over a lane, blurs (below). */
}
/* The seam the tray comes out of: an ember line along the plate's underside,
   drawn from the middle out while the tray is down. */
header.topbar::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: calc(var(--tdock-side) + var(--tdock-r));
  right: calc(var(--tdock-side) + var(--tdock-r));
  bottom: var(--tdock-gap);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--tdock-ember), .75) 30%, rgba(255, 205, 130, .95) 50%, rgba(var(--tdock-ember), .75) 70%, transparent);
  box-shadow: 0 0 12px 1px rgba(var(--tdock-ember), .45);
  opacity: 0;
  transform: scaleX(.2);
  pointer-events: none;
  will-change: transform, opacity;
  transition: opacity .1s ease-in, transform .1s ease-in;
}
body.tabs-tray.tabs-open > header.topbar::after {
  opacity: 1;
  transform: none;
  transition: opacity .12s ease-out, transform .26s var(--tdock-ease);
}

/* The Mac's traffic lights sit on the plate's left end. */
body.shell-mac header.topbar { padding-left: calc(var(--tdock-side) + 78px); }
/* The frameless shell's – □ ✕ end the row inside the plate: closer to its edge. */
body.shell-frameless header.topbar { padding-right: calc(var(--tdock-side) + 8px); }
body.shell-frameless header.topbar .window-controls .winbtn { border-radius: 50%; }

/* Measured fit (topbar.js) tightens the old bar's gutters at steps 2 and 5;
   here the gutter is the plate's own inset, so only the inner part gives. */
header.topbar[data-tb-fit~="2"] { padding-left: calc(var(--tdock-side) + 10px); padding-right: calc(var(--tdock-side) + 10px); }
header.topbar[data-tb-fit~="5"] { padding-left: calc(var(--tdock-side) + 8px); padding-right: calc(var(--tdock-side) + 8px); }
body.shell-mac header.topbar[data-tb-fit] { padding-left: calc(var(--tdock-side) + 78px); }

/* Tucked by the chrome fold, the strip is fixed: same plate, a touch more
   solid over whatever it comes down across. */
body.chrome-fold > header.topbar { background: none; }
body.chrome-fold > header.topbar::before {
  background:
    radial-gradient(360px 64px at 6% -18%, rgba(var(--tdock-ember), .13), transparent 72%),
    linear-gradient(180deg, rgba(255, 236, 202, .065) 0%, transparent 46%),
    linear-gradient(180deg, rgba(46, 34, 25, .9) 0%, rgba(26, 19, 14, .93) 58%, rgba(15, 11, 9, .95) 100%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
/* The row as the fold's second bar (the dock's `shown` mode), down over a lane. */
body.chrome-fold:not(.tabs-tray) > nav.view-tabs {
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}

/* ─── where you are: the chip that stands for the tray ──────────────────── */

/* Only while the tabs are a tray: the row itself says it otherwise. It wears
   the open tab's painted icon and name, and opens the tray on a press — the
   way in for a touch screen and the keyboard, where there is no hover. */
.tb-where { display: none; }
body.tabs-tray .tb-where { display: inline-flex; }
.topbar .tb-where .tb-trigger.tb-btn.btn.icon-pill { position: relative; padding: 0 9px 0 6px; }
.tb-where .tb-ico { transition: transform .32s var(--tdock-spring), filter .2s; }
.tb-where .tb-trigger-text { margin-right: 4px; }
.tb-where .tb-trigger-value { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }
.topbar .tb-where .tb-trigger[aria-expanded="true"] { background: rgba(var(--tdock-ember), .14); color: #fde7c0; }
.topbar .tb-where .tb-trigger[aria-expanded="true"] .tb-ico {
  transform: translateY(-1px) scale(1.1);
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .55)) drop-shadow(0 0 6px rgba(var(--tdock-ember), .4));
}
/* A new tab's icon arrives: it rises into the chip. */
.tb-where .tb-ico.is-swapping { animation: tdock-swap .34s var(--tdock-spring); }
@keyframes tdock-swap {
  from { opacity: 0; transform: translateY(7px) scale(.8); }
  to   { opacity: 1; transform: none; }
}
/* What the tucked tabs would have told you: a rip in flight, one landed, one
   failed (the same three states, and colours, as .view-tab-badge). */
.tb-where-news {
  position: absolute;
  top: 1px; left: 21px;
  display: none;
  width: 11px; height: 11px;
  border-radius: 6px;
  background: var(--grad-warm);
  box-shadow: 0 1px 5px rgba(245, 158, 11, .4), 0 0 0 2px #1d1610;
  pointer-events: none;
}
.tb-where.is-working .tb-where-news,
.tb-where.is-new .tb-where-news,
.tb-where.is-error .tb-where-news { display: block; }
.tb-where.is-working .tb-where-news { animation: tab-badge-breathe 1.9s ease-in-out infinite; }
.tb-where.is-new .tb-where-news { background: linear-gradient(135deg, var(--accent-good) 0%, var(--accent-2) 100%); box-shadow: 0 1px 5px rgba(16, 185, 129, .45), 0 0 0 2px #1d1610; }
.tb-where.is-error .tb-where-news { background: var(--accent-hot); box-shadow: 0 1px 5px rgba(239, 68, 68, .5), 0 0 0 2px #1d1610; }
/* Measured fit: the name goes with Play's read-out, the caret with the others. */
.topbar[data-tb-fit~="3"] .tb-where .tb-trigger-text { display: none; }

/* ─── the tray ──────────────────────────────────────────────────────────── */

nav.view-tabs {
  margin: 0 var(--tdock-side) var(--tdock-gap);
  padding: 0 10px;
  height: 40px;
  box-sizing: border-box;
  align-items: stretch;
  gap: 2px;
  border: 1px solid rgba(var(--tdock-brass), .2);
  border-radius: var(--tabs-r);
  background:
    linear-gradient(180deg, rgba(255, 236, 202, .045) 0%, transparent 50%),
    linear-gradient(180deg, rgba(38, 28, 21, .9) 0%, rgba(20, 15, 11, .94) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 233, 196, .1),
    inset 0 -1px 0 rgba(0, 0, 0, .45),
    0 14px 26px -18px rgba(0, 0, 0, .9);
  /* A narrow window scrolls the row instead of losing its last tabs. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
nav.view-tabs::-webkit-scrollbar { display: none; }
/* The old bar's full-width brass hairline belonged to a bar with square ends. */
nav.view-tabs::before { display: none; }
nav.view-tabs .view-tab {
  flex: none;
  padding: 0 15px;
  border-radius: 13px;
}
nav.view-tabs .view-tab::before { inset: 5px 2px; border-radius: 12px; }
nav.view-tabs .view-tab::after { bottom: 3px; border-radius: 2px; }
nav.view-tabs .view-tab:focus-visible::before { inset: 5px 2px; border-radius: 12px; }
nav.view-tabs .view-tabs-ember { bottom: 3px; border-radius: 2px; }
nav.view-tabs .view-tab-badge { top: 4px; box-shadow: 0 1px 5px rgba(245, 158, 11, .4), 0 0 0 2px #1b140f; }

/* ── tray mode: under the dock, out of the flow ── */
body.tabs-tray > nav.view-tabs {
  position: fixed;
  z-index: 9;                               /* under the dock (10): it comes out from beneath it */
  top: calc(var(--cfold-y0, 0px) + var(--cfold-top-h, 64px) - 1px);
  left: 0; right: 0;
  width: fit-content;
  max-width: calc(100vw - 2 * var(--tdock-side) - 2 * var(--tdock-r));
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 236, 202, .05) 0%, transparent 50%),
    linear-gradient(180deg, rgba(40, 30, 22, .95) 0%, rgba(20, 15, 11, .97) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 233, 196, .12),
    inset 0 -1px 0 rgba(0, 0, 0, .45),
    0 22px 40px -16px rgba(0, 0, 0, .95),
    0 0 0 1px rgba(0, 0, 0, .35);
  /* Shut: drawn up under the dock.
     THE MOTION IS TRANSFORM AND OPACITY ONLY, on a solid plate with a layer of
     its own (will-change), so every frame of it is the compositor's: no blur
     behind a moving box, no scale (text re-rasters at each size and reads as a
     wobble), nothing that lays out or repaints. Out in ~160 ms, away in 100. */
  will-change: transform, opacity;
  transform: translateY(-9px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform .1s cubic-bezier(.4, 0, 1, 1),
    opacity .09s linear,
    visibility 0s linear .1s;
}
body.tabs-tray.tabs-open > nav.view-tabs {
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    transform .16s cubic-bezier(.2, .9, .25, 1),
    opacity .08s linear,
    visibility 0s;
}
/* The tabs follow, one a hundredth of a second after another: a ripple across
   the row, over before the pointer has reached it. A tab is a target from the
   first frame — it only rises 4px into place. */
body.tabs-tray > nav.view-tabs > :is(.view-tab, .view-tabs-pin) {
  opacity: 0;
  transform: translateY(-4px);
  transition: color .18s, opacity .08s linear, transform .08s linear;
}
body.tabs-tray.tabs-open > nav.view-tabs > :is(.view-tab, .view-tabs-pin) {
  opacity: 1;
  transform: none;
  transition:
    color .18s,
    opacity .1s ease-out calc(var(--tab-i, 0) * 9ms),
    transform .16s cubic-bezier(.2, .9, .25, 1) calc(var(--tab-i, 0) * 9ms);
}
body.tabs-tray > nav.view-tabs > .view-tabs-ember { opacity: 0; }
body.tabs-tray.tabs-open > nav.view-tabs > .view-tabs-ember:not(.is-gone) { opacity: 1; transition-delay: 0s, 0s, .06s; }

/* The fold has the header up and away: so is the tray, whatever else is true. */
body.tabs-tray.chrome-fold:not(.chrome-open) > nav.view-tabs {
  transform: translateY(-9px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  header.topbar::before,
  header.topbar::after,
  body.tabs-tray > nav.view-tabs,
  body.tabs-tray.tabs-open > nav.view-tabs,
  body.tabs-tray > nav.view-tabs > :is(.view-tab, .view-tabs-pin),
  body.tabs-tray.tabs-open > nav.view-tabs > :is(.view-tab, .view-tabs-pin),
  .view-tabs-pin, .view-tabs-pin img,
  .tb-where .tb-ico { transition: none; }
  body.tabs-tray > nav.view-tabs { transform: none; }
  body.tabs-tray > nav.view-tabs > :is(.view-tab, .view-tabs-pin) { transform: none; }
  .tb-where .tb-ico.is-swapping { animation: none; }
  .tb-where.is-working .tb-where-news { animation: none; }
}

/* A touch screen: proper targets in the tray. */
@media (pointer: coarse) {
  nav.view-tabs { height: 48px; }
  .view-tabs-pin { width: 44px; height: 44px; }
  body { --chrome-h: 118px; }
  body.tabs-tray { --chrome-h: 64px; }
}

/* In the flow the row runs the whole width of its plate: the tabs share it, so
   it never ends on an empty stretch. (As a tray it is only as wide as its tabs.) */
body:not(.tabs-tray) > nav.view-tabs > .view-tab { flex: 1 0 auto; justify-content: center; }

/* A row wider than its plate (a narrow window): the tabs fade out toward the
   side there are more of (top-dock.js hint()). */
nav.view-tabs[data-more="right"] { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); }
nav.view-tabs[data-more="left"] { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 44px), transparent); }
nav.view-tabs[data-more="both"] { -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); }

/* The boot stagger (arrive.css) animates the tabs in; a shut tray has none on screen. */
html.hearth-boot body.tabs-tray > nav.view-tabs > .view-tab { animation: none; }

/* A stream docked in Hearth's frame (moonlight/hearthstream.css) lifts both
   bars over everything else on the page, and whatever is open under them
   showed through any gap as a strip (2026-11-05). So there the strip is solid
   behind the dock, and the row is a solid strip too: no air for a page to
   show through. (The row is always in the flow there: top-dock.js nativeUnder.) */
body.has-hs-stage:not(.locked):not(.privacy-covered) header.topbar { background: #0c0a08; }
body.has-hs-stage:not(.locked):not(.privacy-covered) nav.view-tabs {
  margin: 0;
  padding: 0 calc(var(--tdock-side) + 10px) var(--tdock-gap);
  height: calc(40px + var(--tdock-gap));
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* ─── the pin ───────────────────────────────────────────────────────────── */

/* Rober, 2026-11-24: "some people might want it to always show, maybe a small
   pin icon?" At the row's end, after a hairline: the lane shelves' own painted
   pin. Let go it leans, the way a pin lies on a desk; pressed it stands
   upright in an ember ring and the row stays on screen (top-dock.js setMode). */
.view-tabs-pin {
  position: relative;
  flex: none;
  align-self: center;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: 11px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-app-region: no-drag;
  transition: background .14s, box-shadow .14s;
}
.view-tabs-pin::before {
  content: '';
  position: absolute;
  left: -6px; top: 5px; bottom: 5px;
  width: 1px;
  background: rgba(var(--tdock-brass), .22);
  pointer-events: none;
}
.view-tabs-pin img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  opacity: .88;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .7));
  transform: rotate(32deg);
  transition: transform .18s var(--tdock-ease), opacity .14s, filter .14s;
  pointer-events: none;
  user-select: none;
}
@media (hover: hover) {
  .view-tabs-pin:hover { background: rgba(var(--tdock-ember), .12); }
  .view-tabs-pin:hover img { opacity: 1; transform: rotate(12deg) scale(1.08); }
  .view-tabs-pin[aria-pressed="true"]:hover img { transform: translateY(-1px); }
}
.view-tabs-pin[aria-pressed="true"] {
  background: rgba(var(--tdock-ember), .15);
  box-shadow: inset 0 0 0 1px rgba(var(--tdock-ember), .5);
}
.view-tabs-pin[aria-pressed="true"] img {
  opacity: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .7)) drop-shadow(0 0 5px rgba(var(--tdock-ember), .45));
  transform: none;
}
.view-tabs-pin:active img { transform: translateY(2px) rotate(0deg); transition-duration: .06s; }
.view-tabs-pin:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(242, 165, 65, .75); }
