/* Global base styles — typography, layout primitives, body */

/* @layer order — declared once, before any layered rules in the cascade.
   reset.css remains un-layered (loaded first, lowest priority by default).
   Components can opt into the `components` layer to keep specificity flat. */
@layer reset, base, components, utilities;

/* TODO: Self-host Inter post-launch (see backlog). */
/* For now: rsms.me CDN — consider adding <link rel="preconnect" href="https://rsms.me"> in HTML head. */
@import url("https://rsms.me/inter/inter.css");

@layer base {

  body {
    background: var(--mt-bg);
    color: var(--mt-text);
    font-family: var(--mt-font-body);
    font-size: var(--mt-fs-body);
    line-height: var(--mt-lh-normal);
    letter-spacing: var(--mt-tracking-normal);
    font-feature-settings: "ss01", "cv11";
  }

  /* === Typography === */

  h1, h2, h3, h4, h5, h6, .display {
    font-family: var(--mt-font-display);
    font-weight: var(--mt-fw-black);
    line-height: var(--mt-lh-tight);
    letter-spacing: var(--mt-tracking-tight);
    color: var(--mt-text);
  }

  .display--hero { font-size: var(--mt-fs-hero); }
  h1, .display--h1 { font-size: var(--mt-fs-h1); }
  h2, .display--h2 { font-size: var(--mt-fs-h2); }
  h3, .display--h3 { font-size: var(--mt-fs-h3); font-weight: var(--mt-fw-semibold); }
  h4, .display--h4 { font-size: var(--mt-fs-h4); font-weight: var(--mt-fw-semibold); line-height: var(--mt-lh-snug); }
  h5, .display--h5 { font-size: var(--mt-fs-h5); font-weight: var(--mt-fw-semibold); line-height: var(--mt-lh-snug); }
  h6, .display--h6 { font-size: var(--mt-fs-h6); font-weight: var(--mt-fw-semibold); line-height: var(--mt-lh-snug); text-transform: uppercase; letter-spacing: var(--mt-tracking-wide); }

  .mono { font-family: var(--mt-font-mono); font-feature-settings: "tnum"; }

  .muted { color: var(--mt-text-muted); }
  .upper-micro { font-size: var(--mt-fs-micro); text-transform: uppercase; letter-spacing: var(--mt-tracking-wide); font-weight: var(--mt-fw-semibold); }

  /* === Focus management ===
     Brand-tinted focus ring; defined here (NOT in reset) because it depends on tokens. */
  :where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--mt-pitch);
    outline-offset: 2px;
    border-radius: 2px;
  }

  /* === Layout primitives === */

  .container { max-width: var(--mt-container); margin-inline: auto; padding-inline: var(--mt-sp-3); }
  .container--md { max-width: var(--mt-container-md); }

  .section { padding-block: var(--mt-sp-7); }
  .section--hero { padding-block: var(--mt-sp-8) var(--mt-sp-6); }

  .stack > * + * { margin-block-start: var(--mt-sp-3); }
  .stack--lg > * + * { margin-block-start: var(--mt-sp-5); }

  /* === Visibility utilities === */

  .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;
  }

  /* Visible-on-keyboard-focus override for skip-links and similar
     focusable but visually-hidden affordances. Must reset both legacy
     `clip` and modern `clip-path` to undo the `.sr-only` masking. */
  .sr-only--focusable:focus,
  .sr-only--focusable:focus-visible {
    position: fixed;
    top: var(--mt-sp-2);
    left: var(--mt-sp-2);
    z-index: var(--mt-z-overlay);
    width: auto;
    height: auto;
    padding: var(--mt-sp-2) var(--mt-sp-3);
    margin: 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
    background: var(--mt-bg-elevated);
    color: var(--mt-text);
    border: 2px solid var(--mt-pitch);
    border-radius: var(--mt-sp-1);
    font-weight: 600;
    text-decoration: none;
  }

} /* end @layer base */

/* === Dark-mode token overrides ===
   Minimal: override only surface/text/border tokens. Accent colors (pitch,
   live, gold) keep their brand identity. Status colors retain enough
   contrast at WCAG AA on the dark surfaces below. */
@media (prefers-color-scheme: dark) {
  :root {
    --mt-bg:          #0E0F12;
    --mt-bg-elevated: #181A1F;
    --mt-text:        #F0F2F5;
    --mt-text-muted:  #B8BDC7;
    --mt-border:      #2A2D33;
  }
}
