/* Base layer: the reset and nothing else foundational.
   Order: tokens.css, then this file, then the page's own <style>. Headings and `a` differ per page.
   `:focus-visible`, `::placeholder` and the disabled-control rule stay out of this file: they must
   load last (sys_design-system.md §2); a file loaded FIRST would invert that and un-style disabled controls. */

*{ box-sizing:border-box; }

/* The base layer's answer to `[hidden]` — sys_design-system.md §2. `!important` is the
   point rather than a shortcut: the whole problem is an author `display` winning, and
   nothing else outranks one. Do not add a per-component `[hidden]` rule beside this one. */
[hidden]{ display:none !important; }

html,body{ margin:0; padding:0; }

/* Every button and field STATES its font (DS-17): buttons 13px/600, fields 13px/400 in the page face. Element selectors, so any component class wins;
   `--a-fs-ctl` resolves under `.alt-app` and mobile.html declares none, so 13px is the answer there. */
button{ cursor:pointer; font-family:inherit; font-size:var(--a-fs-ctl); font-weight:var(--a-fw-ctl); }

/* Form controls, same reason and same place — sys_design-system.md §2. `optgroup` is
   listed because a grouped <select> draws its headings from its OWN font, not the
   select's. */
input, select, textarea, optgroup{ font-family:inherit; }
input, select, textarea{ font-size:var(--a-fs-ctl); font-weight:400; }

/* The scrollbar, once, for every page with this palette — sys_design-system.md §2.
   Deliberately unscoped so a new scroll area inherits it automatically. `--border` and
   `--border-strong` keep both themes in step; `scrollbar-color` answers Firefox, the
   WebKit rules answer Chrome/Safari — one appearance, two mechanisms. */
*{scrollbar-width:thin; scrollbar-color:var(--border) transparent;}
::-webkit-scrollbar{width:9px;height:9px;}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--a-r-sm, 6px);}
/* Visible on hover without becoming a second colour scheme: the same token one tier up. */
::-webkit-scrollbar-thumb:hover{background:var(--border-strong);}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-corner{background:transparent;}


/* Native date/time controls follow `color-scheme`, not our tokens — sys_design-system.md
   §2. The glyph and the popup are the browser's own; a `filter:invert` fixes only the
   glyph and double-inverts wherever the platform already matched. The class sits on
   :root as well as body because the boot script sets it on <html> before <body> exists. */
input[type=date], input[type=time], input[type=datetime-local], input[type=month]{
  color-scheme: dark;
}
:root.theme-light input[type=date], :root.theme-light input[type=time],
:root.theme-light input[type=datetime-local], :root.theme-light input[type=month],
body.theme-light input[type=date], body.theme-light input[type=time],
body.theme-light input[type=datetime-local], body.theme-light input[type=month]{
  color-scheme: light;
}

/* Native radios and checkboxes follow `color-scheme` too: with the default (light) scheme an unchecked
   radio paints a white disc on a dark card whatever `accent-color` says. Declared here once, for every
   choice card and settings row (`.sx-choice`, `.a-dyk-choice`, the org/system AI choices), never per surface. */
input[type=radio], input[type=checkbox]{ color-scheme: dark; }
:root.theme-light input[type=radio], :root.theme-light input[type=checkbox],
body.theme-light input[type=radio], body.theme-light input[type=checkbox]{ color-scheme: light; }

/* Native select popups — sys_design-system.md §2. `optgroup` needs its own colours or a
   grouped heading draws as the browser's bare default. `--text-dim` on `--panel` is the
   quieter tier this app already uses for a label over its own rows; weight carries the
   grouping, since the indent is already the browser's. */
select option{ background:var(--panel-2); color:var(--text); }
select optgroup{ background:var(--panel); color:var(--text-dim); font-weight:600; font-style:normal; }

/* Number inputs never show the browser's native up/down spinner — sys_design-system.md
   §2. It is a light-grey system control that ignores the theme (it sat on a dark input in
   the OKR Check in dialog), and every number field here is a typed value that the
   keyboard's ArrowUp/ArrowDown still steps. Declared once, in the sheet every page loads;
   `number-input-spinner-check.py` fails a page that renders one without it. */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button{ -webkit-appearance:none; margin:0; }
input[type=number]{ -moz-appearance:textfield; appearance:textfield; }

/* A long link in a comment (or any body that carries `a.rich-link`) is shortened by CSS, on every
   surface, instead of wrapping its raw address across the card. The stored text is unchanged and the
   full address stays in the title and the href (decision D4). Bare `a.rich-link`, not
   `.comment-body a.rich-link`: the OKR and Message Center bodies have no `.comment-body` container. */
a.rich-link, .a-comment-b a, .okr-history-row p a{
  display:inline-block; max-width:100%; overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap; vertical-align:bottom;
}

/* Search clear button — sys_design-system.md "Search fields". JS/components/popover.js adds one `.sx-clear` after every
   `input[type=search]` and positions it over the field's right end. The browser's own x is hidden (it is faint, and
   drawn only on hover), so there is never a double x; the field pads to make room and a keycap hint steps aside. */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration{ -webkit-appearance:none; appearance:none; display:none; }
input.sx-clearable.sx-has-text{ padding-right:34px; }
input.sx-clearable.sx-has-text ~ .a-kbd{ display:none; }
.sx-clear{
  position:absolute; z-index:2; width:24px; height:24px; padding:0; margin:0;
  display:inline-flex; align-items:center; justify-content:center; border:0; border-radius:50%;
  background:var(--border); background:color-mix(in srgb, var(--text) 16%, transparent); color:var(--text); cursor:pointer;
}
.sx-clear:hover{ background:var(--border-strong); background:color-mix(in srgb, var(--text) 30%, transparent); }
