/* ─────────────────────────────────────────────────────────────
   Cotrugli — Base
   Resets, root element setup, semantic element helpers, layout
   containers. Loaded after tokens.css.
   ───────────────────────────────────────────────────────────── */

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

/* UA chrome (scrollbars, form controls, system colors) follows the theme. */
:root { color-scheme: dark; }
:root.light { color-scheme: light; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  font: var(--t-body);
  font-feature-settings: "tnum" 1;   /* tabular numerals, always */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;  /* taps show our own states */
  -webkit-text-size-adjust: 100%;            /* no iOS landscape inflation */
  text-size-adjust: 100%;
}

/* Theme swaps crossfade via startViewTransition (theme.js) or land instantly;
   a body-level transition would fight the snapshot fade, so there is none. */

h1, h2, h3, h4, p, figure, blockquote, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font-family: inherit; color: inherit; }
table { border-collapse: collapse; }
em { font-style: normal; }            /* italics are deliberate, opt-in only */
/* Selection is a HUMAN act: neutral inverse, never the agent's chartreuse. */
::selection { background: rgba(250, 250, 250, 0.16); color: var(--text); }
.light ::selection { background: rgba(10, 10, 10, 0.12); color: var(--text); }

/* Thin, theme-true scrollbars on a scroll-everywhere console. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong); border: 3px solid transparent;
  background-clip: padding-box; border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }

/* Reduced motion: movement collapses to instant; opacity fades may stay.
   Delay zeroes too — a staggered arrival must not hold rows invisible. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Links — underline, never the signal color. Hover slightly muted. */
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; transition: color var(--t-quick) var(--easing); }
a:hover { color: var(--text-muted); }

/* Visible focus ring for keyboard users — the one neutral ring, square.
   (Chartreuse focus would claim the agent's voice; signal borders on inputs
   are the only sanctioned exception.) */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Visually hidden but available to AT / focusable (used by CSS-tab radios). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Keyboard users skip the sidebar on every navigation; visible only on focus. */
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: var(--z-chrome);
  font-family: var(--font-mono); font-size: 12px; padding: 8px 12px;
  background: var(--surface-elev); color: var(--text);
  border: 1px solid var(--surface-rule); border-radius: var(--r-2);
  text-decoration: none;
}
.skip-link:focus { left: 8px; }

/* ── Layout containers ── */
.container          { max-width: 1080px; margin: 0 auto; padding-left: var(--sp-8); padding-right: var(--sp-8); }
.container--reading { max-width: 720px;  margin: 0 auto; padding-left: var(--sp-8); padding-right: var(--sp-8); }
.container--wide    { max-width: 1280px; margin: 0 auto; }

/* ─────────────────────────────────────────────
   Semantic element helpers (shipped .cot-* set).
   Use directly, or as a reference for component CSS.
   ───────────────────────────────────────────── */
.cot-body    { font: var(--t-body); color: var(--text); background: var(--surface); font-feature-settings: "tnum" 1; }
.cot-display { font: var(--t-display); letter-spacing: var(--tr-display); color: var(--text); }
.cot-h1      { font: var(--t-h1);   letter-spacing: var(--tr-h1);   color: var(--text); }
.cot-h2      { font: var(--t-h2);   letter-spacing: var(--tr-h2);   color: var(--text); }
.cot-h3      { font: var(--t-h3);   letter-spacing: var(--tr-h3);   color: var(--text); }
.cot-p       { font: var(--t-body); color: var(--text-muted); }
.cot-p-sm    { font: var(--t-body-sm); color: var(--text-muted); }
.cot-mono    { font: var(--t-mono-data); color: var(--text); font-variant-numeric: tabular-nums; }
.cot-label   { font: var(--t-mono-label); letter-spacing: var(--tr-label); text-transform: uppercase; color: var(--text-subtle); }
.cot-micro   { font: var(--t-micro); color: var(--text-subtle); }
/* Code is machine voice, not agent action: neutral ink, never the signal. */
.cot-code    { font-family: var(--font-mono); font-size: 0.88em; color: var(--text); background: var(--surface-elev); padding: 1px 6px; border-radius: var(--r-1); }
