/* ============================================================
   base.css — KIC Mission Control reset + typography + layout
   ------------------------------------------------------------
   Loads after tokens.css. Everything in this file references
   tokens — no raw colour or size values.
   
   Owns:
     • CSS reset
     • Web font loading (Inter, Material Symbols)
     • Body baseline typography
     • Heading scale (.display-lg, .headline-md, etc.)
     • Layout primitives (.app-shell, .main, .container)
     • Material Symbols icon class
     • Generic utilities used across pages
   ============================================================ */

/* ----------------------------------------------------------
   WEB FONTS
   Loaded from Google Fonts. Both used by Stitch designs.
   No build step required.
   ---------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

/* ----------------------------------------------------------
   RESET
   Conservative — preserves user-agent defaults that matter
   (lists, form elements get re-styled in components.css).
   ---------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--on-background);
  font-family: var(--font-body);
  font-size: var(--font-body-base-size);
  line-height: var(--font-body-base-line);
  font-weight: var(--font-body-base-weight);
  overflow-x: hidden;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

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

a:hover {
  color: var(--primary);
}

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: inherit;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

p {
  margin: 0;
}

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

/* Focus ring — applied globally, components can override */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Scrollbar styling — Material 3 dark scheme */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--surface-container-low);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-container-highest);
  border-radius: var(--radius-pill);
  border: 2px solid var(--surface-container-low);
}

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

/* ----------------------------------------------------------
   TYPOGRAPHY SCALE
   Five Stitch-named scales. Apply by class, not by element.
   Page titles use .display-lg or .headline-md depending on
   density.
   ---------------------------------------------------------- */

.display-lg {
  font-family: var(--font-body);
  font-size: var(--font-display-lg-size);
  line-height: var(--font-display-lg-line);
  letter-spacing: var(--font-display-lg-track);
  font-weight: var(--font-display-lg-weight);
  color: var(--on-surface);
}

.headline-md {
  font-family: var(--font-body);
  font-size: var(--font-headline-md-size);
  line-height: var(--font-headline-md-line);
  letter-spacing: var(--font-headline-md-track);
  font-weight: var(--font-headline-md-weight);
  color: var(--on-surface);
}

.body-base {
  font-family: var(--font-body);
  font-size: var(--font-body-base-size);
  line-height: var(--font-body-base-line);
  letter-spacing: var(--font-body-base-track);
  font-weight: var(--font-body-base-weight);
}

.label-caps {
  font-family: var(--font-body);
  font-size: var(--font-label-caps-size);
  line-height: var(--font-label-caps-line);
  letter-spacing: var(--font-label-caps-track);
  font-weight: var(--font-label-caps-weight);
  text-transform: uppercase;
}

.data-mono {
  font-family: var(--font-mono);
  font-size: var(--font-data-mono-size);
  line-height: var(--font-data-mono-line);
  letter-spacing: var(--font-data-mono-track);
  font-weight: var(--font-data-mono-weight);
  font-variant-numeric: tabular-nums;
}

/* Page hero — combines display-lg with the standard subtitle below */
.page-title {
  font-family: var(--font-body);
  font-size: var(--font-display-lg-size);
  line-height: var(--font-display-lg-line);
  letter-spacing: var(--font-display-lg-track);
  font-weight: 800;
  color: var(--on-surface);
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  font-family: var(--font-body);
  font-size: var(--font-body-base-size);
  line-height: var(--font-body-base-line);
  color: var(--on-surface-variant);
}

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--font-label-caps-size);
  letter-spacing: var(--font-label-caps-track);
  font-weight: var(--font-label-caps-weight);
  text-transform: uppercase;
  color: var(--on-surface-variant);
  opacity: 0.7;
}

/* ----------------------------------------------------------
   COLOUR UTILITIES
   Use sparingly. Prefer semantic component classes.
   ---------------------------------------------------------- */

.text-primary       { color: var(--primary); }
.text-on-surface    { color: var(--on-surface); }
.text-muted         { color: var(--on-surface-variant); }
.text-faint         { color: var(--text-faint); }
.text-secondary     { color: var(--secondary); }
.text-tertiary      { color: var(--tertiary); }
.text-error         { color: var(--error); }

.bg-surface              { background: var(--surface); }
.bg-surface-container    { background: var(--surface-container); }
.bg-surface-high         { background: var(--surface-container-high); }
.bg-surface-highest      { background: var(--surface-container-highest); }

/* ----------------------------------------------------------
   APP SHELL LAYOUT
   The fundamental structure: fixed sidebar (left), fixed
   topbar (top, offset by sidebar width), scrollable main
   content (offset by both).
   ---------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  background: var(--background);
}

.app-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
}

.app-content {
  padding: var(--space-md);
  max-width: var(--content-max);
}

.page-wrap {
  padding: var(--space-xl) var(--space-lg);
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ----------------------------------------------------------
   MOBILE SHELL
   Below 768px: sidebar collapses to overlay, topbar shrinks.
   ---------------------------------------------------------- */

@media (max-width: 768px) {
  .app-main {
    margin-left: 0;
    margin-top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    padding-bottom: 80px;
  }

  .app-content {
    padding: var(--space-sm);
  }

  .page-wrap {
    padding: var(--space-md) var(--space-sm);
  }
}

/* ----------------------------------------------------------
   MATERIAL SYMBOLS
   Single icon class. Stitch screens set FILL=1 inline for
   active/highlighted icons; that pattern is preserved.
   ---------------------------------------------------------- */

.material-symbols-outlined,
.icon {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  vertical-align: middle;
}

.icon--filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.icon--sm    { font-size: 16px; }
.icon--md    { font-size: 20px; }
.icon--lg    { font-size: 24px; }
.icon--xl    { font-size: 32px; }

/* ----------------------------------------------------------
   GENERIC UTILITIES
   Layout helpers used across components and pages.
   Kept minimal — most layout lives in components.css.
   ---------------------------------------------------------- */

.flex          { display: flex; }
.inline-flex   { display: inline-flex; }
.grid          { display: grid; }
.hidden        { display: none !important; }

.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }

.gap-xs        { gap: var(--space-xs); }
.gap-sm        { gap: var(--space-sm); }
.gap-md        { gap: var(--space-md); }
.gap-lg        { gap: var(--space-lg); }

.mt-xs   { margin-top: var(--space-xs); }
.mt-sm   { margin-top: var(--space-sm); }
.mt-md   { margin-top: var(--space-md); }
.mt-lg   { margin-top: var(--space-lg); }
.mt-xl   { margin-top: var(--space-xl); }
.mb-xs   { margin-bottom: var(--space-xs); }
.mb-sm   { margin-bottom: var(--space-sm); }
.mb-md   { margin-bottom: var(--space-md); }
.mb-lg   { margin-bottom: var(--space-lg); }
.mb-xl   { margin-bottom: var(--space-xl); }

.flex-1        { flex: 1 1 0; }
.flex-wrap     { flex-wrap: wrap; }
.flex-col      { flex-direction: column; }

.text-left     { text-align: left; }
.text-center   { text-align: center; }
.text-right    { text-align: right; }

.relative      { position: relative; }
.absolute      { position: absolute; }
.sticky        { position: sticky; }
.fixed         { position: fixed; }

.w-full        { width: 100%; }
.h-full        { height: 100%; }

.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }

.opacity-60    { opacity: 0.6; }
.opacity-70    { opacity: 0.7; }
.opacity-80    { opacity: 0.8; }

.uppercase     { text-transform: uppercase; }
.font-bold     { font-weight: 700; }
.font-black    { font-weight: 900; }
.font-semi     { font-weight: 600; }
.font-medium   { font-weight: 500; }
.font-normal   { font-weight: 400; }

.tracking-tight   { letter-spacing: -0.02em; }
.tracking-normal  { letter-spacing: 0; }
.tracking-wide    { letter-spacing: 0.06em; }

/* Visually hidden but accessible to screen readers */
.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;
}
