/* The kit (PHASE3_PLAN step 2, REDESIGN §5 and §8): the pieces every page is built from, one class
   family each, in tokens only (ops/site/rawcheck.py enforces colours, layers and spacing here).
   Components with behaviour live in src/kit/. Pages move onto these as phase 4 rebuilds them. */

/* ---- Icon: one from the sprite (src/kit: Icon). Lucide's 24 px grid; look B is a 2.1 px stroke
   with a tinted fill on the place icons (.tone). Sized by the text around it. ---- */
.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.tone { stroke-width: 2.1; fill: color-mix(in srgb, currentColor 18%, transparent); }
.k-icon-btn { display: inline-grid; place-items: center; min-width: 2.75rem; min-height: 2.75rem; margin: 0; padding: 0;
  background: transparent; border: 0; border-radius: var(--r-panel); color: var(--dim); cursor: pointer; }
.k-icon-btn:hover { background: var(--hover); color: var(--ink); }
.k-icon-btn .ic { width: 1.375rem; height: 1.375rem; }

/* ---- Buttons: main (the one action), plain, big (a full-width main step), icon above. ---- */
.k-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 2.75rem;
  margin: 0; padding: 0 var(--s4); border: 0; border-radius: var(--r-panel); font: inherit; font-weight: var(--w-bold);
  background: var(--panel3); color: var(--ink); cursor: pointer; text-decoration: none; }
.k-btn:hover { background: var(--hover); }
.k-btn.main { background: var(--accent); color: var(--on-accent);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, var(--black)); }
.k-btn.main:hover { background: color-mix(in srgb, var(--accent) 88%, var(--black)); }
.k-btn.big { width: 100%; min-height: 3.25rem; border-radius: var(--r-card); font-size: var(--fs-md); }
.k-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

/* ---- Sheet (src/kit: Sheet, SheetHead): from the bottom on a phone, a panel at the corner from
   600 px; its head stays in view. ---- */
.k-scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: transparent; }

.k-sheet { position: fixed; z-index: var(--z-sheet); left: 0; right: 0; bottom: 0; max-height: 85dvh; overflow-y: auto;
  background: var(--panel); color: var(--ink); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: 0 -8px 24px var(--shade);
  padding: 0 var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); }
@media (min-width: 600px) {
  .k-sheet { left: auto; right: var(--s4); bottom: var(--s4); width: 26rem; border-radius: var(--r-sheet);
    box-shadow: 0 8px 24px var(--shade); }
}
.k-sheet-head { position: sticky; top: 0; z-index: var(--z-page); display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2); margin: 0 calc(-1 * var(--s4)) var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s4);
  background: var(--panel); border-bottom: 1px solid var(--line); }
.k-sheet-head h2 { margin: 0; font-size: var(--fs-md); }
.k-sheet-head h2:focus { outline: none; }

/* ---- Toast: one at a time, above everything, at the foot. ---- */
.k-toast { position: fixed; z-index: var(--z-toast); left: var(--s4); right: var(--s4); bottom: calc(var(--s4) + var(--bottom-bar));
  display: flex; align-items: center; gap: var(--s3); max-width: 32rem; margin: 0 auto; padding: var(--s3) var(--s4);
  background: var(--ink); color: var(--bg); border-radius: var(--r-card); box-shadow: 0 4px 12px var(--shade-deep); }

/* ---- Seg: a segmented control (one choice of a few). ---- */
.k-seg { display: inline-flex; gap: var(--s1); padding: var(--s1); background: var(--panel2); border-radius: var(--r-panel); }
.k-seg button { margin: 0; padding: var(--s2) var(--s3); border: 0; border-radius: var(--r-control); background: transparent;
  color: var(--dim); font: inherit; font-weight: var(--w-bold); cursor: pointer; }
.k-seg button[aria-pressed=true], .k-seg button[aria-selected=true] { background: var(--knob); color: var(--ink); box-shadow: var(--shadow); }

/* ---- Card and Tile (Home): a card leads with a tinted head; tiles are equal and small. ---- */
.k-card { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); background: var(--panel);
  border-radius: var(--r-card); box-shadow: var(--shadow); min-width: 0; }
.k-tile { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); background: var(--panel);
  border-radius: var(--r-card); box-shadow: var(--shadow); min-width: 0; color: inherit; text-decoration: none; }
.k-card h3, .k-tile h3 { margin: 0; font-size: var(--fs-sm); }

/* ---- AreaMark: an area's icon on its colour tile (D-AR.17). ---- */
.k-area { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--r-control);
  background: var(--ink); color: var(--bg); }
.k-area.pz { background: var(--pz); color: var(--on-area); }
.k-area.gs { background: var(--gs); color: var(--on-area); }
.k-area.rp { background: var(--rp); color: var(--on-area); }
.k-area.an { background: var(--accent); color: var(--on-accent); }
.k-area .ic { width: 1.125rem; height: 1.125rem; }

/* ---- PageHead: Back, the title, an action at the end. ---- */
.k-pagehead { display: flex; align-items: center; gap: var(--s2); min-height: 3rem; margin: 0 0 var(--s3); }
.k-pagehead h1 { flex: 1; margin: 0; font-size: var(--fs-lg); min-width: 0; }

/* ---- Quiet list and table: the dense panes (D-AR.23): thin lines, no shadows. ---- */
.k-quiet { margin: 0; padding: 0; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); }
.k-quiet > li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-top: 1px solid var(--line); }
.k-quiet > li:first-child { border-top: 0; }
.k-quiet > li[aria-current=true], .k-quiet > li.chosen { background: var(--acc-soft); }
.k-quiet-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.k-quiet-table th { text-align: left; font-weight: var(--w-bold); color: var(--dim); padding: var(--s2); border-bottom: 1px solid var(--line); }
.k-quiet-table td { padding: var(--s2); border-bottom: 1px solid var(--line); }
.k-quiet-table tr[aria-selected=true] td { background: var(--acc-soft); }

/* ---- Loading and Empty: what a block shows before and without its content. ---- */
.k-loading { padding: var(--s5) var(--s4); color: var(--dim); text-align: center; }
.k-empty { display: grid; justify-items: center; gap: var(--s2); padding: var(--s6) var(--s4); color: var(--dim); text-align: center; }
.k-empty .ic { width: 2rem; height: 2rem; }

/* ---- BoardStage: one board-sizing rule for every board page (D-AR.19, D-AR.23): as big as the
   width allows, never taller than the screen leaves after the page's own bars (--stage-chrome). ---- */
.k-stage { --stage-chrome: var(--board-chrome); width: min(100%, calc(var(--vh) - var(--stage-chrome))); margin: 0 auto; }
.k-stage > * { width: 100%; aspect-ratio: 1; }

/* ---- Frame (src/shell, PHASE3_PLAN step 3; D-AR.16-19, D-AR.24): the places, one nav drawn per
   format. Phone: tabs along the foot, the current one's icon in a colour tile; a board screen
   (data-screen="board") has its own bar instead. iPad: a rail down the left with labels under
   the icons. Desktop: the same as a slimmer side bar. Both a step darker than the page (D-AR.21),
   the brand tile on top, You at the foot. --frame-l is the room it takes on the left: every
   board-sizing rule takes it off the screen's width (--vw). ---- */
:root { --frame-l: 0px; --frame-t: 0px; --tabbar-h: 3.5rem; --vw: calc(100vw - var(--frame-l));
  --vh: calc(100dvh - var(--frame-t)); --svh: calc(100svh - var(--frame-t)); }
:root[data-format=ipad] { --frame-l: 5.5rem; }
:root[data-format=desk] { --frame-l: 4.75rem; }
:root[data-format=phone]:not([data-screen=board]) body { --bottom-bar: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
body { padding-left: var(--frame-l); }

.frame { position: fixed; z-index: var(--z-bar); left: 0; right: 0; bottom: 0; display: flex; background: var(--rail);
  box-shadow: 0 -1px 0 var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
:root[data-format=phone][data-screen=board] .frame { display: none; }
.frame-place { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s1); min-height: var(--tabbar-h); color: var(--dim); text-decoration: none;
  font-size: var(--fs-xs); letter-spacing: var(--ls-xs); font-weight: var(--w-bold); }
.frame-tile { display: grid; place-items: center; width: 3rem; height: 1.75rem; border-radius: var(--r-panel); }
.frame-tile .ic { width: 1.375rem; height: 1.375rem; stroke-width: 2.1; fill: color-mix(in srgb, currentColor 18%, transparent); }
.frame-place[aria-current=page] { color: var(--ink); }
.frame-place[aria-current=page] .frame-tile { background: var(--accent); color: var(--on-accent); }
.frame-place[aria-current=page] .frame-tile .ic { fill: color-mix(in srgb, currentColor 25%, transparent); }
@media (hover: hover) {
  .frame-place:hover { color: var(--ink); }
  .frame-place:not([aria-current=page]):hover .frame-tile { background: var(--hover); }
}
.frame-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* On a phone, no brand tile. A visitor: Home, Analyse, Puzzles, Guess, Sign in (D-AR.24). A member:
   six slimmer tabs, Home, Analyse, Players, Puzzles, Repertoire, Library (DOSSIER D-DM.1, frame XL3);
   Guess from its Home tile, You from Home's button (owner, 2026-11-20-4). */
.frame-brand, .frame-gap { display: none; }
.frame-you.unknown { visibility: hidden; }
:root[data-format=phone] .frame-theme,
:root[data-format=phone] .frame:not(.member) :is(.frame-library, .frame-players),
:root[data-format=phone] .frame.member :is(.frame-guess, .frame-you) { display: none; }
:root[data-format=phone] .frame.member .frame-place { font-size: 0.66rem; letter-spacing: 0; padding-inline: 0; }
:root[data-format=phone] .frame.member .frame-tile { width: 2.6rem; }
/* The colours button (D-OF.3 A) is a button sized as the rail's links. */
button.frame-theme { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; font-family: inherit; cursor: pointer; }

/* iPad and desktop: down the left edge. */
:root:not([data-format=phone]) .frame { top: 0; right: auto; width: var(--frame-l); flex-direction: column; align-items: stretch;
  gap: var(--s1); padding: var(--s3) 0 calc(var(--s3) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  box-shadow: 1px 0 0 var(--line); overflow-y: auto; scrollbar-width: none; }
:root:not([data-format=phone]) .frame-place { flex: none; min-height: 3.75rem; }
:root:not([data-format=phone]) .frame-tile { width: 2.75rem; height: 2.25rem; }
:root:not([data-format=phone]) .frame-gap { display: block; flex: 1; }
:root:not([data-format=phone]) .frame-brand { display: grid; place-items: center; margin-bottom: var(--s2); }
.frame-brand .frame-tile { width: 2.5rem; height: 2.5rem; background: var(--accent); color: var(--on-accent); border-radius: var(--r-panel);
  box-shadow: var(--shadow); }
.frame-brand .frame-tile .ic { fill: currentColor; width: 1.5rem; height: 1.5rem; }
/* The desktop's is slimmer: smaller tiles and labels. */
:root[data-format=desk] .frame-place { min-height: 3.25rem; font-weight: var(--w-text); }
:root[data-format=desk] .frame-tile { width: 2.5rem; height: 2rem; }
/* A short screen (a phone on its side counts as an iPad by the format rule): icons only. */
@media (max-height: 520px) {
  :root:not([data-format=phone]) .frame { gap: 0; padding-top: var(--s2); }
  :root:not([data-format=phone]) .frame-label { display: none; }
  :root:not([data-format=phone]) .frame-place { min-height: 2.75rem; }
  :root:not([data-format=phone]) .frame-brand { margin-bottom: 0; }
}

/* ---- Menu bar (src/shell/menus.rs; D-AR.19): the desktop's, across the top beside the side bar;
   menus follow the place; search on the right. The focus key (.) hides it and the side bar. ---- */
.menubar-wrap { display: none; }
:root[data-format=desk] { --frame-t: 2.5rem; }
:root[data-format=desk] body { padding-top: var(--frame-t); }
:root[data-format=desk] .menubar-wrap { display: block; position: fixed; z-index: var(--z-bar); top: 0; right: 0; left: var(--frame-l);
  height: var(--frame-t); background: var(--rail); box-shadow: 0 1px 0 var(--line); }
.menubar { display: flex; align-items: center; height: 100%; padding: 0 var(--s2); gap: 0; font-size: var(--fs-sm); }
.mb-menu { position: relative; }
.mb-name { margin: 0; min-height: 0; height: 1.875rem; padding: 0 var(--s3); border: 0; border-radius: var(--r-control);
  background: transparent; color: var(--ink); font: inherit; cursor: default; }
.mb-name:hover, .mb-name[aria-expanded=true] { background: var(--acc-soft); }
.mb-drop { position: absolute; z-index: var(--z-sheet); top: calc(100% + var(--s1)); left: 0; min-width: 16rem; display: grid;
  padding: var(--s1); background: var(--panel); border-radius: var(--r-panel); box-shadow: 0 8px 24px var(--shade); }
.mb-item { display: flex; align-items: center; gap: var(--s5); width: 100%; margin: 0; min-height: 0; padding: var(--s1) var(--s3);
  border: 0; border-radius: var(--r-control); background: transparent; color: var(--ink); font: inherit; text-align: left;
  text-decoration: none; white-space: nowrap; cursor: default; }
.mb-item:hover, .mb-item:focus-visible { background: var(--accent); color: var(--on-accent); outline: none; }
.mb-key { margin-left: auto; border: 0; background: none; padding: 0; color: inherit; opacity: 0.7; }
.mb-key.none { display: none; }
.mb-sep { margin: var(--s1) var(--s2); border: 0; border-top: 1px solid var(--line); }
.mb-gap { flex: 1; }
.mb-search { display: inline-flex; align-items: center; gap: var(--s2); margin: 0; min-height: 0; height: 1.875rem; width: 20rem;
  padding: 0 var(--s2) 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-control); background: var(--panel);
  color: var(--dim); font: inherit; cursor: text; }
.mb-search span { flex: 1; text-align: left; }
.mb-search kbd { font-size: var(--fs-xs); }
/* Focus (.): the side bar and menus step aside; Esc brings them back. */
:root[data-focus] { --frame-l: 0px; --frame-t: 0px; }
:root[data-focus] .frame, :root[data-focus] .menubar-wrap { display: none; }
/* You holds the small print and colours itself. */
body:has(.you-list) footer { display: none; }
/* The Analyse icon's count of open tabs (D-AR.19). */
.frame-tile { position: relative; }
.frame-count { position: absolute; top: calc(-1 * var(--s1)); right: calc(-1 * var(--s1)); min-width: 1.125rem; height: 1.125rem;
  padding: 0 var(--s1); border-radius: 999px; background: var(--ink); color: var(--bg); font-size: var(--fs-xs); line-height: 1.125rem;
  text-align: center; font-weight: var(--w-bold); letter-spacing: 0; }
