/* =========================================================================
   Main Street Automation — Design tokens & base styles
   ========================================================================= */

:root,
[data-theme="light"] {
  /* Type scale (fluid) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);
  --text-hero: clamp(2.75rem, 0.8rem + 5.5vw, 5.5rem);

  /* 4px spacing system */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 999px;

  /* Transitions */
  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 720px;
  --content-default: 1100px;
  --content-wide: 1240px;

  /* Fonts */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---------- LIGHT MODE: Ivory paper + ink navy + signal amber ---------- */
  --color-bg: #F7F4EC;            /* warm ivory paper */
  --color-surface: #FFFDF7;       /* card / lifted */
  --color-surface-2: #EFEADD;     /* offset / banded */
  --color-surface-dark: #0F1B2D;  /* inverted dark section */
  --color-border: #E0D9C6;
  --color-border-strong: #C9C0A8;
  --color-divider: #ECE5D2;

  --color-text: #16223A;          /* near-ink */
  --color-text-muted: #5B6376;
  --color-text-faint: #94989F;
  --color-text-inverse: #F7F4EC;

  --color-accent: #E27D2A;        /* signal amber */
  --color-accent-hover: #C5651A;
  --color-accent-soft: #FBE7D3;

  --color-deep: #0F1B2D;          /* deep ink navy */
  --color-deep-2: #1A2840;
  --color-teal: #2A6F77;          /* supporting operational teal */

  --color-success: #2F7A4D;
  --color-danger: #B0394C;

  /* Shadows tuned to warm bg */
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(15, 27, 45, 0.14);
  --shadow-lg: 0 24px 48px -16px rgba(15, 27, 45, 0.22);
}

/* ---------- DARK MODE ---------- */
[data-theme="dark"] {
  --color-bg: #0E1726;
  --color-surface: #16223A;
  --color-surface-2: #1B2942;
  --color-surface-dark: #060B16;
  --color-border: #2A3954;
  --color-border-strong: #3A4A6A;
  --color-divider: #1F2E48;

  --color-text: #EDE7D6;
  --color-text-muted: #A3ADC2;
  --color-text-faint: #6C7591;
  --color-text-inverse: #0E1726;

  --color-accent: #F39148;
  --color-accent-hover: #FFAA66;
  --color-accent-soft: rgba(243, 145, 72, 0.16);

  --color-deep: #060B16;
  --color-deep-2: #11192A;
  --color-teal: #5BB0B8;

  --color-success: #65C290;
  --color-danger: #E2728A;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0E1726;
    --color-surface: #16223A;
    --color-surface-2: #1B2942;
    --color-surface-dark: #060B16;
    --color-border: #2A3954;
    --color-text: #EDE7D6;
    --color-text-muted: #A3ADC2;
    --color-accent: #F39148;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  hanging-punctuation: first last;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-feature-settings: "ss01", "cv11";
  transition: background-color 300ms ease, color 300ms ease;
}

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

ul[role="list"], ol[role="list"] {
  list-style: none;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  text-wrap: balance;
  line-height: 1.1;
  letter-spacing: -0.012em;
}

p, li, figcaption {
  text-wrap: pretty;
}

p { max-width: 70ch; }

::selection {
  background: var(--color-accent);
  color: #fff;
}

:focus-visible {
  outline: 2.5px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a, button, [role="button"], input, textarea, select {
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    box-shadow var(--transition-interactive),
    transform var(--transition-interactive);
}

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

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--color-deep);
  color: var(--color-text-inverse);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  z-index: 200;
}
.skip-link:focus { top: 12px; }

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum", "lnum";
  letter-spacing: 0;
}
