/* chrome.css — the OS furniture: taskbar, start menu, system tray, clock,
 * context menus, the hover peek and the focused-window indicator.
 *
 * The visual grammar is the printed desktop the rest of the OS already uses —
 * ink outlines, offset paper shadow, paper surfaces, one violet accent — but
 * the *behaviour* is a literal operating system: chrome pinned to the edges,
 * always above the windows, task buttons mirroring the open windows, a clock
 * that runs. A desktop drawn by a printer, not a printer pretending to be a
 * grey corporate shell.
 *
 * This file owns no state and moves no DOM. Every piece degrades: without
 * `.is-focused` no indicator paints, without `.is-peeking` no peek exists,
 * without `.is-open` the panel is not there, without a window there is no
 * button and no dot.
 *
 * ── naming ────────────────────────────────────────────────────────────────
 * Two names once existed for the same parts. Every rule below carries BOTH,
 * grouped into one selector list, so there is one property per part whichever
 * spelling ships:
 *
 *   earlier spelling      canonical BEM (CONTRACTS.md)
 *   .taskbar__items   +   .taskbar__tasks
 *   .task-btn         +   .taskbar__task
 *   .task-btn__icon   +   .taskbar__task-icon
 *   .task-btn__label  +   .taskbar__task-label
 *   (mark as ::after) +   .taskbar__task-bar
 *   .task-btn__peek   +   .taskbar__peek (+ __peek-title / __peek-name)
 *   .tray             +   .taskbar__tray
 *   .tray__clock      +   .taskbar__clock
 *
 * The BEM column is canonical; the left column is a temporary alias kept until
 * the shell is declared stable. Dropping it is one selector per rule and never
 * a visual change.
 *
 * `.startmenu*`, `.start-item`, `.ctxmenu*`, `.os-root`, `.os-chrome` and
 * `.os-sr` are single-spelled and shared by everyone.
 *
 * ── layering ──────────────────────────────────────────────────────────────
 * One scale, pinned in CONTRACTS.md (windows 10–100): chrome 500, hover peek
 * 600, search panel 700, mobile switch 700, start menu 800, context menu 900.
 * ────────────────────────────────────────────────────────────────────────── */


/* ══ chrome layer ═══════════════════════════════════════════════════════════
 * One fixed layer holds the whole furniture. Its own height is the taskbar's
 * and nothing else — the peek, the start menu and the context menu are all out
 * of flow — which is what lets the start menu anchor itself to the bar's top
 * edge with a percentage and land correctly whether the bar is one row or
 * three. */

.os-chrome {
  position: fixed;
  inset: auto 0 0 0;
  /* Read from the shared scale css/os/desktop.css declares on .os, with the
     pinned number as the fallback. Two files that each hardcode "800" are two
     files that disagree the day the scale changes; one source cannot. The
     fallback keeps the chrome correct if that sheet is ever loaded alone. */
  z-index: var(--z-chrome, 500);
  /* The layer spans the bar and nothing else; the menus that live in it
     overhang the top, so nothing here may clip. */
  pointer-events: none;
}
/* Chrome is furniture, so it takes clicks — but each piece opts in, so an empty
   corner of the layer never eats a click meant for the desktop behind it. */
.os-chrome > * { pointer-events: auto; }

/* ── hidden means gone, not transparent ────────────────────────────────────
 * Every panel in this file sets `display`, and a class selector beats the user
 * agent's `[hidden] { display: none }`. So an author-`display`ed element with
 * `hidden` on it stays in the hit-test tree at full size: invisible at
 * opacity 0, still eating every pointer event aimed at what is underneath.
 * The start menu alone was a 640x543 block over the top-left of the desktop —
 * an open window could not be dragged because the titlebar was not the top
 * element at its own centre point.
 *
 * `!important` is the correct tool, not a smell: this is a rule about the
 * author's own `display` declarations, and it has to outrank every one of them
 * in this file and in any future rule here. Works/os-entry.css carries the same
 * line as its base; keeping it here too means this sheet is correct loaded on
 * its own, and the two agree rather than one rescuing the other. */
.os-chrome [hidden],
.os-chrome [hidden] * { display: none !important; }

/* The visually hidden live region the shell reads window and time changes back
 * to a screen reader. Present, sized to nothing, never focusable. */
.os-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* One focus ring for every interactive control in the chrome: three ink pixels
 * with a paper halo, so it survives on ink surfaces (the bar) and on paper
 * surfaces (the menus) without a second colour scheme. */
.os-chrome :focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}
/* On the ink bar itself the ring is paper with an ink collar, so it reads as
   drawn on top of the dark strip rather than vanishing into it. */
.taskbar :focus-visible,
.tray :focus-visible,
.taskbar__tray :focus-visible {
  outline-color: var(--paper);
  box-shadow: 0 0 0 2px var(--ink);
}


/* ══ taskbar ════════════════════════════════════════════════════════════════
 * A strip of the same paper the frame is printed on, pinned to the bottom edge
 * under an ink rule — the frame's own title bar, moved down. */

.taskbar {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  min-width: 0;
  padding: .38rem clamp(.45rem, 1.6vw, .9rem);
  border-top: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  box-shadow: 0 -8px 22px -12px rgba(23, 21, 31, .5);
}

/* ── start button ─────────────────────────────────────────────────────────── */

.taskbar__start {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .34rem .7rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.taskbar__start:hover { background: var(--paper-2); }
.taskbar__start:active { translate: 0 1px; }
/* While the panel is open the button stays lit, so the way back to the desktop
   is visible from the panel's own edge. */
.taskbar__start[aria-expanded="true"],
.taskbar__start.is-open {
  background: var(--ink);
  color: var(--paper);
}

/* ── window buttons ───────────────────────────────────────────────────────── */

.taskbar__items,
.taskbar__tasks {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .1rem;
  margin: 0;
  list-style: none;
  /* NOT a scroll container. The peek rises out of a task button, so any
     `overflow` here — x-scroll included — would clip the one thing that has to
     escape upward out of the bar. Ten windows therefore wrap to a second row:
     a two-row taskbar is honest, a clipped peek is broken. */
  overflow: visible;
}

.task-btn,
.taskbar__task {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .6rem .42rem;
  border: 2px solid var(--ink);
  border-radius: 9px 9px 3px 3px;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .16s ease, translate .16s ease;
}
.task-btn:hover,
.taskbar__task:hover { background: #fff; translate: 0 -1px; }
.task-btn:active,
.taskbar__task:active { translate: 0 1px; }

.task-btn__icon,
.taskbar__task-icon {
  flex: none;
  display: block;
  width: 18px; height: 18px;
}
.task-btn__icon svg,
.task-btn__icon img,
.taskbar__task-icon svg,
.taskbar__task-icon img { width: 100%; height: 100%; display: block; object-fit: contain; }

.task-btn__label,
.taskbar__task-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 13ch;
}

/* A minimised window keeps its button but goes flat, so the bar still tells the
   truth about what is open and what is only remembered. */
.task-btn.is-minimized,
.taskbar__task.is-minimized { background: var(--paper); opacity: .72; }

/* ── the focused-window indicator ───────────────────────────────────────────
 * The one thing a taskbar must answer without being asked: which window am I
 * actually looking at. Two marks, because one is too quiet at ten buttons and
 * two would be noise — the button takes the violet, and a hand-drawn white rule
 * grows beneath it. */

.task-btn.is-focused,
.taskbar__task.is-focused {
  background: var(--accent, var(--violet));
  border-color: var(--ink);
  color: #fff;
}
.task-btn.is-focused :is(.task-btn__label, .taskbar__task-label),
.taskbar__task.is-focused :is(.task-btn__label, .taskbar__task-label) { font-weight: 700; }

/* When the builder emits its own indicator element, style that. */
.taskbar__task-bar {
  position: absolute;
  left: 12%; right: 12%; bottom: 3px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  opacity: 0;
  transition: opacity .16s ease;
}
.taskbar__task.is-focused > .taskbar__task-bar { opacity: 1; }

/* Otherwise the mark is drawn: a short ink rule under the focused button. */
.task-btn.is-focused::after,
.taskbar__task.is-focused:not(:has(> .taskbar__task-bar))::after {
  content: "";
  position: absolute;
  left: 12%; right: 12%; bottom: 3px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
}


/* ══ system tray ════════════════════════════════════════════════════════════ */

.tray,
.taskbar__tray {
  flex: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-left: .55rem;
  border-left: 1.5px solid var(--line);
}

.tray__indicator {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 1.5px solid var(--ink);
}
/* The dot only exists when a window has focus — an empty ring is the honest
   state, and it keeps the tray's rhythm when nothing is open. */
.tray__indicator::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent, var(--violet));
  scale: 0;
  transition: scale .18s cubic-bezier(.2, .9, .25, 1);
}
/* ONE convention for "a window has focus", pinned in CONTRACTS.md. Three
   spellings of the same idea is three sources of truth for one boolean. */
.tray__indicator[data-active="true"]::after { scale: 1; }

.tray__clock,
.taskbar__clock {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  padding: .18rem .5rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  /* A clock that reflows sideways once a minute is worse than no clock: the
     digits get tabular figures and the box never changes width. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
  color: var(--ink);
}

/* ── the bar's own search trigger ─────────────────────────────────────────── */

.taskbar__search {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .32rem .6rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.taskbar__search:hover { background: var(--paper-2); }
.taskbar__search[aria-expanded="true"],
.taskbar__search.is-open { background: var(--ink); color: var(--paper); }

/* ── search panel ─────────────────────────────────────────────────────────── */

.taskbar__search-panel {
  position: absolute;
  right: clamp(.35rem, 1.4vw, .9rem);
  bottom: calc(100% + .55rem);
  z-index: var(--z-search, 700);
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 1.2rem));
  max-height: min(440px, calc(100vh - 7rem));
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 16px 0 -7px rgba(23, 21, 31, .26), 0 26px 50px -22px rgba(23, 21, 31, .6);
  overflow: hidden;
  animation: chrome-in .16s cubic-bezier(.2, .9, .25, 1) both;
}

.taskbar__search-input {
  flex: none;
  width: 100%;
  padding: .6rem .75rem;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
}
.taskbar__search-input::placeholder { color: rgba(23, 21, 31, .5); }

.taskbar__search-results {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: .4rem;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.taskbar__search-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .42rem .55rem;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: .82rem;
  text-align: left;
  cursor: pointer;
}
.taskbar__search-row:hover { background: var(--paper-2); border-color: var(--ink); }
/* the arrow-key cursor is the same state as a hover, so the keyboard and the
   pointer can never disagree about what is under the eye */
.taskbar__search-row.is-active {
  background: var(--accent, var(--violet));
  border-color: var(--ink);
  color: #fff;
  font-weight: 700;
}
.taskbar__search-row svg,
.taskbar__search-row img {
  flex: none;
  width: 20px; height: 20px;
  display: block;
  object-fit: contain;
}

.taskbar__search-empty {
  margin: 0;
  padding: 1.1rem .75rem;
  font-size: .82rem;
  text-align: center;
  color: rgba(23, 21, 31, .66);
}


/* ══ hover peek ════════════════════════════════════════════════════════════
 * Pointer AND keyboard reach this one: the shell opens it on focus-visible as
 * well as hover, and the surface is a real element so it can hold a preview
 * and a caption without either being asked to.
 *
 * Two markups, one look. When the peek is a child of the task button it is
 * centred over that button; when it is a sibling of the bar (a single card the
 * shell slides along under the pointer) it is centred over the bar and the
 * shell slides it sideways — either way the card itself is drawn once. */

.task-btn__peek,
.taskbar__peek {
  position: absolute;
  left: 50%;
  bottom: calc(100% + .55rem);
  translate: -50% 8px;
  z-index: var(--z-peek, 600);
  width: min(260px, 78vw);
  padding: .5rem;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 14px 0 -6px rgba(23, 21, 31, .28), 0 20px 34px -18px rgba(23, 21, 31, .6);
  opacity: 0;
  scale: .94;
  pointer-events: none;
  transition: opacity .16s ease, scale .16s cubic-bezier(.2, .9, .25, 1), translate .16s ease;
}
/* As a sibling of the bar it needs the bar, not the button, as its anchor. */
.taskbar__peek { bottom: calc(100% - 0px); }

.task-btn__peek.is-peeking,
.taskbar__peek.is-peeking,
.taskbar.is-peeking > .taskbar__peek {
  opacity: 1;
  scale: 1;
  translate: -50% 0;
}

/* The tail: the same ink rule the bar is drawn with, so the peek reads as
   coming off the button rather than floating near it. */
.task-btn__peek::after,
.taskbar__peek::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  width: 12px; height: 12px;
  translate: -50% -7px;
  rotate: 45deg;
  background: var(--paper);
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  border-radius: 0 0 4px 0;
}

/* Whatever preview markup goes inside — an image of the window, a title, a
   line of status — lays out without needing a class for each. */
.task-btn__peek img,
.task-btn__peek svg,
.taskbar__peek img,
.taskbar__peek svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--paper-2);
}
.task-btn__peek :is(h3, h4, strong, b, p, span),
.taskbar__peek :is(h3, h4, strong, b, p, span) { display: block; }
.task-btn__peek :is(h3, h4),
.taskbar__peek :is(h3, h4) {
  margin: .5rem 0 0;
  font-family: var(--serif);
  font-size: .95rem;
  letter-spacing: -.01em;
}
.taskbar__peek-title {
  margin-top: .5rem;
}
.taskbar__peek-name {
  display: block;
  font-family: var(--serif);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.task-btn__peek p,
.taskbar__peek p {
  margin: .15rem 0 0;
  font-size: .76rem;
  line-height: 1.4;
  color: rgba(23, 21, 31, .7);
}


/* ══ start menu ════════════════════════════════════════════════════════════
 * A panel hanging off the top of the chrome layer, over the start button, with
 * a paper body and an ink frame — the same rectangle as a window, hung off the
 * bar.
 *
 * The anchor is chosen by INVERTING the question. Instead of listing the hosts
 * the panel might be mounted into — a list that silently rots the moment a
 * module picks a fourth parent, which is exactly how the first version of this
 * rule shipped dead and left the menu 481px above the fold — the DEFAULT is
 * the one that is always correct, and the exception is the one narrow case
 * that is measurably better.
 *
 *   default (any host)      fixed to the viewport, one taskbar's room reserved
 *   .os-chrome > .startmenu absolute to the layer, flush above the bar
 *
 * The exception is worth it: inside .os-chrome the layer's height IS the
 * taskbar's (its other children are out of flow), so `bottom: calc(100% + …)`
 * lands the panel flush above a bar of ANY height — one row or three — with no
 * measuring in JS. The default is viewport-anchored instead, which cannot
 * depend on a containing block it knows nothing about. */

/* Paint first, then the anchor: the two `.startmenu` blocks that split these
   properties apart are merged here so a later edit cannot move one without
   seeing the other. */
.startmenu {
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 0 -8px rgba(23, 21, 31, .26), 0 30px 60px -24px rgba(23, 21, 31, .65);
  overflow: hidden;
  opacity: 0;
  scale: .97;
  translate: 0 10px;
  transition: opacity .18s ease, scale .18s cubic-bezier(.2, .9, .25, 1), translate .18s ease;

  /* ── the anchor, and the one case where it differs ── */
  position: fixed;
  left: clamp(.35rem, 1.4vw, .9rem);
  bottom: clamp(4rem, 16vh, 9rem);
  z-index: var(--z-start, 800);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  width: min(660px, calc(100vw - clamp(.7rem, 2.8vw, 1.8rem)));
  max-height: min(560px, calc(100vh - 7rem));
}

.os-chrome > .startmenu {
  position: absolute;
  bottom: calc(100% + .55rem);
}


/* ── the spotlight layer ───────────────────────────────────────────────────
 * The shell paints a radial-gradient here and moves it with the pointer. It
 * sits UNDER the panel's content (z 0 against the grid's own stacking) and
 * takes no clicks, and it deliberately carries NO transition — a spotlight that
 * eases into place lags the cursor by exactly the easing duration. */
.startmenu__glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  /* Stated as a rule rather than left to the initial value, so nobody adds a
     shorthand transition to this selector later without noticing what it
     would cost the pointer. */
  transition: none;
}

/* ── panel head ───────────────────────────────────────────────────────────
 * The title is an <h2>: the weight and the size are reset here so it reads as
 * a heading to a screen reader and as a line of running text to the eye. */
.startmenu__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem .1rem;
}
.startmenu__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Icon-only, so it carries the chrome's focus ring and nothing else — no text
   to give it a width, and an aria-label to name it. */
.startmenu__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  line-height: 1;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.startmenu__close:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.startmenu__close svg { width: 14px; height: 14px; display: block; }

/* The head and close button live on the paper, so their focus ring stays ink
   (the bar's paper ring would vanish against the panel). */
.startmenu :focus-visible { outline-color: var(--ink); box-shadow: none; }

/* The panel's own content sits above the spotlight whatever order the markup
   declares it in — the glow is decoration, and decoration never wins a z-index
   fight with the ten business names. */
.startmenu__sidebar,
.startmenu__head,
.startmenu__main,
.startmenu__search { position: relative; z-index: 1; }
.startmenu.is-open {
  opacity: 1;
  scale: 1;
  translate: 0 0;
}

/* ── the expandable sidebar ─────────────────────────────────────────────────
 * Collapsed it is a rail of glyphs; expanding slides the captions out rather
 * than reflowing the grid, so the panel never changes width under the pointer
 * that opened it. */

.startmenu__sidebar {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .55rem;
  border-right: 1.5px solid var(--line);
  background: var(--paper-2);
  min-width: 0;
}
.startmenu__sidebar > *,
.startmenu__sidebar button { min-width: 0; }

.startmenu__sidebar button {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .4rem .5rem;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.startmenu__sidebar button:hover { background: #fff; border-color: var(--ink); }
.startmenu__sidebar button[aria-current="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* Collapsed, the rail is a column of square icon buttons; expanding slides the
   captions out rather than swapping elements, so the caption is never
   `display:none` and the screen reader keeps it either way.
   The caption span is clipped to zero ONLY when the button also carries a
   glyph — clip a caption with no glyph beside it and the rail becomes a
   column of empty pills. */
.startmenu__sidebar svg,
.startmenu__sidebar img {
  flex: none;
  width: 20px; height: 20px;
  display: block;
  object-fit: contain;
}

.startmenu__sidebar:not(.is-expanded) button {
  justify-content: center;
  min-width: 2.4rem;
  padding-inline: .45rem;
}
.startmenu__sidebar:not(.is-expanded) button:has(svg, img) :is(span, .startmenu__label) {
  min-width: 0;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width .22s ease, opacity .18s ease;
}
.startmenu__sidebar.is-expanded :is(span, .startmenu__label) {
  max-width: 14ch;
  opacity: 1;
}

/* ── main column ──────────────────────────────────────────────────────────── */

.startmenu__main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.startmenu__search {
  flex: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .75rem;
  border-bottom: 1.5px solid var(--line);
}
.startmenu__search input,
.startmenu__search [type="search"] {
  width: 100%;
  min-width: 0;
  padding: .42rem .6rem;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .85rem;
}
.startmenu__search input::placeholder { color: rgba(23, 21, 31, .5); }

/* The app list scrolls inside the panel; the panel itself does not, so the
   search field and the sidebar stay put while the ten worlds move. */
.startmenu__main > :is(ul, ol, .startmenu__list) {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: .7rem;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.startmenu__group { margin: 0 0 .5rem; }
.startmenu__group > :is(h2, h3, [role="heading"]) {
  position: sticky;
  top: 0;
  margin: 0 0 .35rem;
  padding: .1rem .25rem;
  background: var(--paper);
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(23, 21, 31, .6);
}

/* ── one launchable app ───────────────────────────────────────────────────── */

.start-item { margin: 0 0 .3rem; }

.start-item > button,
.start-item[role="button"] {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .45rem .55rem;
  border: 1.5px solid transparent;
  border-radius: 11px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, translate .14s ease;
}
.start-item > button:hover,
.start-item[role="button"]:hover {
  background: var(--paper-2);
  border-color: var(--ink);
  translate: 2px 0;
}
/* A pinned app the user may not launch goes flat, it does not vanish — the row
   keeps its place in the grid. */
.start-item [aria-disabled="true"],
.start-item button:disabled { opacity: .45; cursor: not-allowed; }
.start-item [aria-disabled="true"]:hover,
.start-item button:disabled:hover {
  background: none;
  border-color: transparent;
  translate: 0 0;
}

/* Each app carries its own accent (set by the app registry as --accent), so
   the icon is the one piece of colour in the list. */
.start-item img,
.start-item svg {
  flex: none;
  width: 30px; height: 30px;
  display: block;
  object-fit: contain;
}
.start-item span { min-width: 0; }
.start-item :is(h3, strong, b) {
  display: block;
  font-family: var(--serif);
  font-size: .92rem;
  letter-spacing: -.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.start-item small,
.start-item p {
  display: block;
  margin: 0;
  font-size: .72rem;
  color: rgba(23, 21, 31, .66);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ══ context menu ═══════════════════════════════════════════════════════════
 * Positioned by the shell from the pointer or the keyboard, so nothing here
 * sets a coordinate: it is anchored top-left and clamped by whoever places it.
 * Ink on paper, one accent row for anything that changes the machine. */

.ctxmenu {
  position: fixed;
  z-index: var(--z-menu, 900);
  min-width: 190px;
  max-width: min(280px, calc(100vw - 1rem));
  padding: .35rem;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 0 -6px rgba(23, 21, 31, .26), 0 22px 40px -20px rgba(23, 21, 31, .6);
  animation: chrome-in .13s cubic-bezier(.2, .9, .25, 1) both;
}
@keyframes chrome-in {
  from { opacity: 0; scale: .96; translate: -4px -2px; }
  to { opacity: 1; scale: 1; translate: 0 0; }
}

.ctxmenu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .4rem .5rem;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.ctxmenu__item:hover,
.ctxmenu__item:focus-visible { background: var(--ink); color: var(--paper); }
/* Any child of the row inverts with it — icons, shortcuts, submenu arrows. */
.ctxmenu__item:hover :is(small, kbd, span),
.ctxmenu__item:focus-visible :is(small, kbd, span) { color: var(--paper); }

/* The row is icon, label, shortcut hint. The label takes the slack so the hint
   always sits hard against the right edge, whatever the text is. */
.ctxmenu__label { margin-right: auto; min-width: 0; }

.ctxmenu__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 16px; height: 16px;
}
.ctxmenu__icon svg,
.ctxmenu__icon img { width: 100%; height: 100%; display: block; object-fit: contain; }

.ctxmenu__item kbd,
.ctxmenu__item small {
  margin-left: auto;
  padding-left: 1rem;
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(23, 21, 31, .55);
}

.ctxmenu__item[aria-disabled="true"],
.ctxmenu__item:disabled { opacity: .42; cursor: not-allowed; }
.ctxmenu__item[aria-disabled="true"]:hover,
.ctxmenu__item:disabled:hover { background: none; color: var(--ink); }

/* Destructive rows never rely on red alone — the weight change and the ‼ mark
   carry the meaning for anyone who cannot see the hue. */
.ctxmenu__item.is-danger { color: #A3243B; }
.ctxmenu__item.is-danger::after {
  content: "‼";
  margin-left: auto;
  padding-left: 1rem;
  font-weight: 700;
}
.ctxmenu__item.is-danger:hover { background: #A3243B; color: #fff; }

.ctxmenu__sep {
  height: 0;
  margin: .3rem .35rem;
  border-top: 1.5px dashed var(--line);
}


/* ══ narrow screens ═════════════════════════════════════════════════════════
 * At 390 the bar keeps its start button and its clock and gives everything else
 * up: titles go, the tray's rule goes, the start menu loses its sidebar column.
 * The two things a person cannot work without stay. */

/* Phone layout: js/os/mobile.js sets `is-phone-os` on <html> on mount and REMOVES
 * it on destroy, and destroy fires the moment the viewport crosses 760px — so
 * the flag is a truthful, always-current signal and not a one-way latch.
 *
 * On a phone the desktop bar is not a degraded version of the phone UI, it is
 * a second one: the mobile rail and switcher (css/os/mobile.css) already own
 * window switching at that size. So the bar and tray step aside entirely and
 * the layer collapses to nothing rather than leaving a dead strip on screen.
 *
 * Selector shape matters here. `is-phone-os` is ON <html> and the bar is a
 * DESCENDANT of it, so the descendant form is correct; the compound
 * `[data-reduce-motion].is-phone-os` shape is ALSO emitted by mobile.js for the
 * case where both flags land on <html> at once — never write that as
 * `[data-reduce-motion] .is-phone-os …`, which asks for <html> inside itself
 * and silently matches nothing. */

:root:has(.is-phone-os) .taskbar,
:root.is-phone-os .taskbar,
:root:has(.is-phone-os) .tray,
:root.is-phone-os .tray,
:root:has(.is-phone-os) .taskbar__tray,
:root.is-phone-os .taskbar__tray { display: none; }

/* …and the layer itself stops reserving a viewport strip for furniture that is
 * no longer painted. Without this the fixed layer keeps its taskbar-height box
 * and the phone's own bottom rail sits on top of an empty band. */
:root:has(.is-phone-os) .os-chrome,
:root.is-phone-os .os-chrome { height: 0; }

/* The panel follows: with the chrome layer collapsed to zero height, the
 * layer-relative `bottom: 100%` would park it over the phone's own bottom
 * rail. Anchor it to the viewport instead, clear of that rail. */
:root:has(.is-phone-os) .os-chrome > .startmenu,
:root.is-phone-os .os-chrome > .startmenu {
  position: fixed;
  bottom: clamp(4rem, 16vh, 9rem);
}

@media (max-width: 620px) {
  .task-btn__label,
  .taskbar__task-label { max-width: 8ch; }
  .tray,
  .taskbar__tray { padding-left: .4rem; gap: .4rem; }
}

@media (max-width: 460px) {
  .taskbar { gap: .4rem; padding: .34rem .4rem; }
  .taskbar__start { padding: .32rem .55rem; font-size: .74rem; }
  /* The name is in the button's accessible name already; the glyph alone keeps
     the bar from wrapping to three rows with ten windows open. */
  .task-btn__label,
  .taskbar__task-label { display: none; }
  .task-btn,
  .taskbar__task { padding: .28rem .38rem .4rem; }
  .task-btn__icon,
  .taskbar__task-icon { width: 20px; height: 20px; }

  .tray__indicator { display: none; }
  .tray__clock,
  .taskbar__clock { font-size: .72rem; padding: .16rem .4rem; }

  .taskbar__search-panel {
    right: .4rem;
    width: calc(100vw - .8rem);
  }

  .startmenu {
    grid-template-columns: minmax(0, 1fr);
    left: .4rem;
    width: calc(100vw - .8rem);
    max-height: min(70vh, calc(100vh - 6.5rem));
  }
  /* The rail becomes a horizontal strip of glyphs above the app list rather
     than a column eating half the panel's width. */
  .startmenu__sidebar {
    grid-column: 1;
    flex-direction: row;
    gap: .35rem;
    padding: .4rem .5rem;
    border-right: 0;
    border-bottom: 1.5px solid var(--line);
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
  .startmenu__sidebar button { padding: .35rem .45rem; }
  .startmenu__sidebar :is(span, .startmenu__label) { display: none; }
  .startmenu__main { grid-column: 1; }
}


/* ══ reduced motion ═════════════════════════════════════════════════════════
 * Two mechanisms, ADDITIVE, and the order between them matters:
 *
 *   @media (prefers-reduced-motion: reduce)
 *       the REAL OS preference. This one must always work — reduced-motion
 *       correctness cannot depend on a script having executed, or a visitor
 *       whose module throws silently loses the setting they asked for.
 *
 *   [data-reduce-motion] on <html>
 *       a MANUAL override: the test hook, and the future in-OS settings toggle
 *       ("reduce motion" as a preference inside the OS). It is NOT a bridge
 *       for the OS preference and must never be described as one.
 *
 * The attribute selectors are a literal repeat of the media query's, not a
 * shorthand for it — so both paths below cannot drift apart.
 *
 * What must survive EITHER way: the OPEN states. A user who asked for less
 * motion still gets the start menu and the peek fully visible at full size.
 * Only the tween between closed and open goes away, never the open itself. */

@media (prefers-reduced-motion: reduce) {
  .startmenu,
  .startmenu__sidebar :is(span, .startmenu__label),
  .task-btn__peek,
  .taskbar__peek,
  .taskbar__search-panel,
  .ctxmenu,
  .task-btn,
  .taskbar__task,
  .taskbar__start,
  .taskbar__search,
  .taskbar__task-bar,
  .tray__indicator,
  .startmenu__close {
    transition: none !important;
    animation: none !important;
  }
  /* Closed states stay closed; open states land immediately at full size. */
  .startmenu:not(.is-open) { opacity: 0; scale: 1; translate: 0 0; }
  .task-btn__peek:not(.is-peeking),
  .taskbar__peek:not(.is-peeking) { opacity: 0; scale: 1; translate: -50% 0; }
}

/* The manual override. Identical rules, unconditional — this path fires
   whether or not the visitor's OS asked for reduced motion. */

:root[data-reduce-motion] .startmenu,
:root[data-reduce-motion] .startmenu__sidebar :is(span, .startmenu__label),
:root[data-reduce-motion] .task-btn__peek,
:root[data-reduce-motion] .taskbar__peek,
:root[data-reduce-motion] .taskbar__search-panel,
:root[data-reduce-motion] .ctxmenu,
:root[data-reduce-motion] .task-btn,
:root[data-reduce-motion] .taskbar__task,
:root[data-reduce-motion] .taskbar__start,
:root[data-reduce-motion] .taskbar__search,
:root[data-reduce-motion] .taskbar__task-bar,
:root[data-reduce-motion] .tray__indicator,
:root[data-reduce-motion] .startmenu__close {
  transition: none !important;
  animation: none !important;
}
:root[data-reduce-motion] .startmenu:not(.is-open) { opacity: 0; scale: 1; translate: 0 0; }
:root[data-reduce-motion] .task-btn__peek:not(.is-peeking),
:root[data-reduce-motion] .taskbar__peek:not(.is-peeking) { opacity: 0; scale: 1; translate: -50% 0; }


