/* os-entry.css — the entry stylesheet for works/os.html.
 *
 * This file is the base layer, and it is deliberately narrow. It owns exactly
 * three things nobody else owns:
 *
 *   1. The design tokens. css/os/desktop.css, wm.css, chrome.css and
 *      explorer.css all read --ink, --paper, --violet, --accent and the three
 *      type stacks. Those tokens used to live in css/os.css, which also carries
 *      the previous shell's .grid / .icon / .frame / .app rules — the same
 *      class names, a different layout. Linking it here would put two live
 *      conventions for one set of classes on one page. So os.html links the
 *      four OS stylesheets and this one, and the tokens live here.
 *
 *   2. The reset and the page frame around the desktop: the site header, the
 *      plain-list fallback, and the skip link.
 *
 *   3. The diagnostics panel. Every module is loaded defensively, so the
 *      normal state of this element is `hidden`. When a module fails to load it
 *      becomes the visible answer to "why is half my desktop missing" — a
 *      white screen is the one outcome the boot contract rules out.
 *
 * Load order: this file, then desktop.css, then wm.css, then chrome.css, then
 * explorer.css. Every OS stylesheet is written to be read in that order.
 */


/* `[hidden]` must beat any `display` a component sets on itself. This is the
   base layer's job, once, for the whole OS: the closed start menu carries
   `hidden` and `display: grid` at the same time, and without this it stays in
   the hit-test tree — invisible at opacity 0, still eating every click aimed
   at a window titlebar underneath it. Several modules ship their own guarded
   copy; this is the one that covers the modules that do not. */
[hidden] { display: none !important; }
/* ══ tokens ════════════════════════════════════════════════════════════════
 * The printed-desktop palette, unchanged from the previous shell so the ten
 * business sites keep the same relationship to the OS that frames them.
 * --accent is the live one: the theme module re-tints the whole environment
 * when a different business opens, and a hardcoded violet anywhere would
 * defeat that. */

:root {
  --ink: #17151F;
  --paper: #F6F1E7;
  --paper-2: #EFE7D9;
  --violet: #6D5BD0;
  --plum: #3A2F63;
  --accent: #6B5B8E;
  --line: rgba(23, 21, 31, .16);
  --sans: ui-sans-serif, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 10px 0 -4px rgba(23, 21, 31, .18);

  --os-head-h: 5.2rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  /* Zero horizontal overflow at 390 and 1440 is a hard floor, so the page box
   * is clipped rather than scrolled sideways by a single wide descendant. The
   * desktop itself clips inside .os; this is the last line of defence. */
  overflow-x: clip;
}

:where(a, button, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Visually hidden, still announced. Used for the OS live region and for the
 * heading that names the desktop. */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* The skip link is the first thing in the tab order on every page in this
 * project: the OS is a keyboard surface, so the way past it has to be too. */
.skip {
  position: fixed; top: 8px; left: 8px; z-index: 1000;
  transform: translateY(-180%);
  padding: .7rem 1rem; border-radius: 8px;
  background: var(--ink); color: var(--paper);
  font: inherit; font-size: .85rem; font-weight: 700; text-decoration: none;
}
.skip:focus-visible { transform: none; }

/* ══ the page frame ═══════════════════════════════════════════════════════
 * A slim header above the screen. The desktop measures itself against
 * `100dvh - 6rem` in desktop.css, so the header is sized to keep that
 * arithmetic honest instead of surprising the window manager with a taller
 * bar than it budgeted for. */

.os-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem clamp(.8rem, 3vw, 1.6rem);
  min-height: var(--os-head-h);
  padding: .8rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.os-shell__brand {
  display: inline-flex; align-items: center; gap: .45rem;
  color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.02em;
}
.os-shell__brand-mark {
  width: 15px; height: 15px; flex: none;
  border: 2px solid var(--ink); border-radius: 4px;
  background: linear-gradient(140deg, var(--violet), var(--plum));
}

.os-shell__title {
  margin: 0; flex: 1 1 auto; min-width: 0;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 700; letter-spacing: -.02em;
}

.os-shell__links {
  display: flex; flex-wrap: wrap; gap: .35rem .5rem;
  font-size: .78rem; font-weight: 700;
}
.os-shell__links a {
  padding: .3rem .7rem;
  border: 2px solid var(--ink); border-radius: 999px;
  color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
.os-shell__links a:hover { background: var(--ink); color: var(--paper); }

/* The live region the composition root writes window and error messages into.
 * chrome.css owns `.os-sr`; this is the belt to its braces for the one region
 * that must exist before any module has mounted. */
.os-shell__live {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ══ diagnostics ══════════════════════════════════════════════════════════
 * Hidden on a clean load. Not decorative: this is where a failed module is
 * reported to the person using the page, in the page, where they can act on
 * it — and where the plain list is always one control away. */

.os-diag {
  position: relative; z-index: 6;
  margin: .6rem clamp(.7rem, 2.5vw, 1.4rem);
  padding: .7rem .9rem;
  border: 3px solid #A3243B; border-radius: 10px;
  background: #FFF3F6; color: #A3243B;
  font-size: .82rem;
}
.os-diag[hidden] { display: none; }

.os-diag__head {
  margin: 0 0 .35rem;
  font-family: var(--mono); font-size: .68rem;
  letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
}
.os-diag__body { margin: 0; color: var(--ink); }
.os-diag__body a { color: #A3243B; }

.os-diag__list { margin: .5rem 0 0; padding: 0; list-style: none; display: grid; gap: .3rem; }
.os-diag__list li { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: baseline; }
.os-diag__mod {
  padding: .05rem .45rem;
  border: 1.5px solid #A3243B; border-radius: 999px;
  font-family: var(--mono); font-size: .66rem; font-weight: 700; white-space: nowrap;
}
.os-diag__why { color: rgba(23, 21, 31, .72); }

.os-diag__foot { margin: .6rem 0 0; font-size: .78rem; }

/* ══ the plain list ════════════════════════════════════════════════════════
 * The floor under the whole OS. Present in the markup, not built by script,
 * so it survives a module that never loads, a script that never runs, and a
 * visitor who would rather read a list than drive a desktop. */

.os-plain {
  max-width: 74ch;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 2.6rem) clamp(1rem, 4vw, 2rem) 4rem;
}
.os-plain[hidden] { display: none; }

.os-plain__lede {
  margin: 0 0 clamp(1rem, 3vw, 1.6rem);
  font-family: var(--serif); font-size: clamp(1rem, 2.4vw, 1.2rem); line-height: 1.5;
}

.os-plain__list {
  margin: 0; padding: 0; list-style: none;
  border-top: 2px solid var(--ink);
  counter-reset: plain;
}
.os-plain__item { border-bottom: 1.5px solid var(--line); }

.os-plain__link {
  display: grid; gap: .1rem .9rem;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
  grid-template-areas: "num name trade" "num line trade";
  padding: .7rem .2rem;
  color: inherit; text-decoration: none;
}
.os-plain__link:hover { background: var(--paper-2); }
.os-plain__link:focus-visible { outline-offset: -3px; }

.os-plain__num {
  grid-area: num; align-self: start;
  font-family: var(--mono); font-size: .74rem; letter-spacing: .1em;
  color: rgba(23, 21, 31, .5);
}
.os-plain__name {
  grid-area: name;
  font-family: var(--serif); font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 700; letter-spacing: -.015em;
}
.os-plain__trade {
  grid-area: trade; text-align: right;
  font-size: .8rem; color: rgba(23, 21, 31, .66);
}
.os-plain__line {
  grid-area: line; font-size: .86rem; color: rgba(23, 21, 31, .72);
}
.os-plain__link:hover .os-plain__name { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 560px) {
  .os-plain__link {
    grid-template-columns: 2.2rem minmax(0, 1fr);
    grid-template-areas: "num name" "num line" "num trade";
  }
  .os-plain__trade { text-align: left; }
}

/* The media query below is the mechanism for the real user preference, and it
   works whether or not any script ran. [data-reduce-motion] is the in-OS
   manual override — a settings toggle, and how a test forces the state without
   changing the OS preference. Additive, never a replacement. */
[data-reduce-motion] *,
[data-reduce-motion] *::before,
[data-reduce-motion] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

.os-plain__foot {
  margin: clamp(1.4rem, 4vw, 2.4rem) 0 0;
  padding-top: 1.2rem; border-top: 1.5px dashed var(--line);
  font-size: .85rem; color: rgba(23, 21, 31, .7);
}
.os-plain__foot a { color: var(--violet); font-weight: 700; }

/* ══ reduced motion ═══════════════════════════════════════════════════════
 * A preference, honoured here rather than negotiated in script: the boot
 * sequence reads the same query and skips its own animation. */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}