/* ==========================================================================
   base.css — reset, typography, chrome (scrollbars, focus, selection) and
   the tiny utility layer.

   WHY a hand-rolled reset instead of normalize: this is an app shell, not a
   document. Margins, list bullets and native form typography are all noise
   here, and the page itself must never scroll — layout.css owns a fixed
   grid whose regions scroll internally (.scroll-area).

   Everything below reads from tokens.css. No literal colours.
   Contract: ARCHITECTURE.md §13.
   ========================================================================== */

/* ---- Reset ----------------------------------------------------------- */

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

* {
  margin: 0;
  /* Own the hairline colour globally so a component only sets border-width. */
  border-color: var(--border);
}

html {
  height: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 2;
}

body {
  height: 100%;
  overflow: hidden; /* app shell: only .scroll-area regions scroll */
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-synthesis-weight: none;
  color: var(--text-0);
  background-color: var(--bg-0);
  /* Two very wide, very low-alpha accent washes keep the near-black canvas
     from reading as flat grey without ever showing a visible gradient band. */
  background-image:
    radial-gradient(1200px 620px at 78% -12%, var(--accent-soft), transparent 62%),
    radial-gradient(900px 520px at -8% 108%, var(--info-soft), transparent 66%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.011em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

ul, ol, menu {
  list-style: none;
  padding: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

img, svg, video, canvas, picture {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
  image-rendering: high-quality;
  /* Broken/loading images must not paint an alt-text box over the stage. */
  color: transparent;
}

/* Deliberately no global fill/stroke: CSS beats SVG presentation attributes,
   so forcing either here would break whichever icon style the component
   authors chose. Icons must carry their own fill/stroke attributes. */
svg {
  flex: none;
}

button, input, select, textarea, optgroup {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

textarea {
  resize: vertical;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th {
  text-align: left;
  font-weight: 600;
}

code, pre, samp, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
}

dialog {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  max-width: none;
  max-height: none;
}

[hidden] {
  display: none !important;
}

[inert] {
  pointer-events: none;
  user-select: none;
}

/* ---- Selection & placeholder ----------------------------------------- */

::selection {
  background: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--text-0);
  text-shadow: none;
}

::placeholder {
  color: var(--text-2);
  opacity: 1;
}

/* ---- Focus ------------------------------------------------------------
   Keyboard-only ring. Mouse clicks never draw it (:focus-visible), but every
   interactive element in the app is reachable and legible from the keyboard.
   ---------------------------------------------------------------------- */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  /* Soft halo so the ring survives on top of a bright image or accent fill. */
  box-shadow: var(--ring);
}

/* Inputs sit inside wells where an offset ring would clip; hug the field. */
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.search input:focus-visible {
  outline-offset: 0;
}

/* ---- Scrollbars -------------------------------------------------------
   Thin, unobtrusive, theme-aware. Firefox gets the standard properties,
   WebKit/Blink the pseudo-elements; both read the same tokens.
   ---------------------------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius-full);
  transition: background-color var(--dur) var(--ease);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ==========================================================================
   Utilities (ARCHITECTURE.md §13)
   ========================================================================== */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Visible again when focused — for skip links. */
.sr-only:focus-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
  font-variant-ligatures: none;
  word-break: break-all;
}

.muted {
  color: var(--text-2);
}

.row {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.col {
  display: flex;
  flex-direction: column;
}

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-7 { gap: var(--space-7); }
.gap-8 { gap: var(--space-8); }

/* Scrollable region inside a fixed grid cell. min-height:0 is what actually
   makes overflow work for a flex/grid child — without it the child grows
   instead of scrolling. */
.scroll-area {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  user-select: none;
}

/* Hairline that eats the remaining width after the label. */
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 180px;
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--text-2);
}

.empty-state > svg,
.empty-state__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-size: 26px;
  line-height: 1;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-1);
}

.empty-state__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.empty-state__text {
  max-width: 44ch;
  font-size: 13px;
  line-height: 1.65;
}
