/* ==========================================================================
   TechTrails design system  (v2: light + dark, framing, columns, readability)
   All color pairings are contrast-verified. Ratios recorded in
   /brand/brand-sheet.md. Because both founders are blind, color is judged by
   measured WCAG contrast, not by eye. Every text pairing here clears AA,
   and most clear AAA.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens
   Light is the default in :root. Dark applies when the OS prefers dark
   (unless the visitor forced light) OR when the visitor forces dark.
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #ffffff;            /* page background */
  --surface-alt: #f7f5ef;   /* alternating section background (sand) */
  --card: #ffffff;          /* cards / panels */
  --band-bg: #12263a;       /* dark feature bands + footer */
  --band-text: #ffffff;     /* text on bands */
  --band-muted: #c7d2de;    /* secondary text on bands */

  /* Text */
  --text: #12263a;          /* 15.4:1 on bg */
  --text-muted: #3a4a5c;    /* 9.08:1 on bg */

  /* Brand + accent */
  --brand: #0f5c3e;         /* links / brand      8.01:1 on bg */
  --brand-strong: #0b4a31;  /* hover / focus */
  --accent: #f59e0b;        /* CTA background (dark text on top) */
  --accent-hover: #e08e00;
  --accent-text: #12263a;   /* text on accent button   7.17:1 */
  --accent-ink: #b45309;    /* amber used AS text on bg */

  /* Lines */
  --border: #d9d5cb;        /* decorative borders */
  --field-border: #6b7280;  /* form controls    4.83:1 (WCAG 1.4.11) */
  --focus: #0b4a31;

  /* Tags */
  --tag-a-bg: #e4f0ea;  --tag-a-text: #0b4a31;  /* accessibility  8.81:1 */
  --tag-b-bg: #fdf0d9;  --tag-b-text: #9c4708;  /* platform       5.62:1 */

  /* Elevation (light only; dark uses borders instead of shadow) */
  --shadow: 0 1px 3px rgba(18, 38, 58, 0.08), 0 4px 16px rgba(18, 38, 58, 0.05);

  /* Typography: system stack, no web fonts (fast, private, no CSP issues) */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Type scale */
  --step--1: 0.9rem;
  --step-0: 1.125rem;       /* 18px base for comfortable reading */
  --step-1: 1.35rem;
  --step-2: 1.7rem;
  --step-3: 2.15rem;
  --step-4: 2.75rem;

  /* Spacing scale */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;

  /* Layout */
  --maxw: 72rem;
  --measure: 40rem;         /* ~66 characters: the readable line length for prose */
  --radius: 12px;
  --radius-sm: 8px;
}

/* Dark tokens, shared by "OS prefers dark (and not forced light)" and "forced dark" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1b29;
    --surface-alt: #14202f;
    --card: #1c2e42;
    --band-bg: #16304a;
    --band-text: #e9eff5;
    --band-muted: #aab8c7;
    --text: #e9eff5;          /* 14.99:1 on bg */
    --text-muted: #aab8c7;    /* 8.59:1 on bg */
    --brand: #5fc08c;         /* 7.78:1 on bg */
    --brand-strong: #83d3a8;
    --accent: #f59e0b;
    --accent-hover: #ffb020;
    --accent-text: #0f1b29;
    --accent-ink: #f6b23d;    /* 9.39:1 on bg */
    --border: #2c3e50;
    --field-border: #6e8093;  /* 4.28:1 on bg */
    --focus: #5fc08c;
    --tag-a-bg: #163a2c; --tag-a-text: #9fe3be;   /* 8.48:1 */
    --tag-b-bg: #3a2c12; --tag-b-text: #f6c77a;   /* 8.63:1 */
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1b29;
  --surface-alt: #14202f;
  --card: #1c2e42;
  --band-bg: #16304a;
  --band-text: #e9eff5;
  --band-muted: #aab8c7;
  --text: #e9eff5;
  --text-muted: #aab8c7;
  --brand: #5fc08c;
  --brand-strong: #83d3a8;
  --accent: #f59e0b;
  --accent-hover: #ffb020;
  --accent-text: #0f1b29;
  --accent-ink: #f6b23d;
  --border: #2c3e50;
  --field-border: #6e8093;
  --focus: #5fc08c;
  --tag-a-bg: #163a2c; --tag-a-text: #9fe3be;
  --tag-b-bg: #3a2c12; --tag-b-text: #f6c77a;
  --shadow: none;
}

/* --------------------------------------------------------------------------
   Base + readability
   -------------------------------------------------------------------------- */

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

html { scroll-behavior: smooth; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  color: var(--text);
  margin: 0 0 var(--space-2);
  text-wrap: balance;         /* nicer headline wrapping */
}
h1 { font-size: var(--step-4); letter-spacing: -0.01em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

/* Cap the width of running text for readability, wherever it appears */
p, li { text-wrap: pretty; }
p { margin: 0 0 var(--space-2); max-width: var(--measure); }
ul, ol { margin: 0 0 var(--space-2); }

a { color: var(--brand); text-underline-offset: 0.15em; }
a:hover { color: var(--brand-strong); }

img, svg { max-width: 100%; height: auto; }

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

/* --------------------------------------------------------------------------
   Skip link
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 100;
  background: var(--band-bg);
  color: var(--band-text);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--space-2); color: var(--band-text); }

/* --------------------------------------------------------------------------
   Layout helpers + columns
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

.section { padding-block: var(--space-5); }
.section--sand { background: var(--surface-alt); }
.section--ink { background: var(--band-bg); color: var(--band-text); }
.section--ink h2, .section--ink h3 { color: var(--band-text); }
.section--ink p { color: var(--band-text); }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--space-2); }
.prose h2, .prose h3 { margin-top: var(--space-3); }

.lede { font-size: var(--step-1); color: var(--text-muted); max-width: 46ch; }
.section--ink .lede { color: var(--band-muted); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--accent-ink);
  margin-bottom: var(--space-1);
}

/* Auto-fit card grids */
.grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }

/* Two-up split: main text beside a supporting panel. Collapses on narrow. */
.split {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 52rem) {
  .split { grid-template-columns: 1.3fr 1fr; align-items: start; }
}

/* Flow a list of SHORT items into 2 columns on wide screens. Reading order
   (DOM order) is preserved for screen readers regardless of visual columns. */
.list-cols { columns: 2 16rem; column-gap: var(--space-4); }
.list-cols li { break-inside: avoid; margin-bottom: var(--space-1); }

.measure { max-width: var(--measure); }

/* --------------------------------------------------------------------------
   Header + navigation + theme toggle
   -------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding-block: var(--space-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--brand);
  text-decoration: none;
  font-weight: 800;
  font-size: var(--step-1);
  margin-right: auto;
}
.brand:hover { color: var(--brand-strong); }
.brand-mark { flex: none; }
.brand-name { color: var(--text); letter-spacing: -0.01em; }
.brand-name-alt { color: var(--brand); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-alt); }
.theme-toggle-icon {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block; width: 20px; height: 2px; background: currentColor; position: relative;
}
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

.nav-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
}
.nav-list a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.nav-list a:hover { background: var(--surface-alt); color: var(--brand-strong); }
.nav-list a[aria-current="page"] {
  color: var(--brand-strong);
  box-shadow: inset 0 -3px 0 var(--accent);
}

@media (max-width: 52rem) {
  .js .nav-toggle { display: inline-flex; }
  .js .site-nav { display: none; flex-basis: 100%; }
  .js .site-nav.is-open { display: block; }
  .js .site-nav .nav-list { flex-direction: column; }
  .js .site-nav .nav-list a { padding: 0.75rem; }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  line-height: 1.2;
}
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-secondary { background: transparent; color: var(--brand-strong); border-color: var(--brand); }
.btn-secondary:hover { background: var(--surface-alt); color: var(--brand-strong); }
.section--ink .btn-secondary { color: var(--band-text); border-color: var(--band-text); }
.section--ink .btn-secondary:hover { background: rgba(255, 255, 255, 0.12); color: var(--band-text); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  padding-block: var(--space-6) var(--space-5);
  background: linear-gradient(180deg, var(--surface-alt), var(--bg));
}
.hero h1 { max-width: 22ch; }

/* --------------------------------------------------------------------------
   Cards + framed panels
   -------------------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card h3 { margin-bottom: var(--space-1); }
.card .card-link { margin-top: auto; font-weight: 700; }

.arm-card {
  border-radius: var(--radius);
  padding: var(--space-4);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}
.arm-card--a { border-top: 6px solid var(--brand); }
.arm-card--b { border-top: 6px solid var(--accent); }

.entry-card {
  display: block;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}
.entry-card:hover { border-color: var(--brand); color: var(--text); background: var(--surface-alt); }
.entry-card h3 { color: var(--brand-strong); }
.entry-card .entry-go { font-weight: 800; color: var(--accent-ink); }

/* --------------------------------------------------------------------------
   Service list
   -------------------------------------------------------------------------- */

.service {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: var(--card);
  box-shadow: var(--shadow);
  scroll-margin-top: 6rem;
}
.service + .service { margin-top: var(--space-3); }
.service .tag {
  display: inline-block;
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  margin-bottom: var(--space-1);
}
.tag--accessibility { background: var(--tag-a-bg); color: var(--tag-a-text); }
.tag--platform { background: var(--tag-b-bg); color: var(--tag-b-text); }
.service ul { padding-left: 1.25rem; }
.service .who { color: var(--text-muted); font-size: var(--step--1); }

/* Optional: show service cards two-up on very wide screens */
.service-grid { display: grid; gap: var(--space-3); }
@media (min-width: 62rem) {
  .service-grid { grid-template-columns: 1fr 1fr; }
  .service-grid .service + .service { margin-top: 0; }
}

/* Callout box */
.callout {
  border-left: 6px solid var(--accent);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}
.callout h3 { margin-top: 0; }

/* Numbered process steps */
.steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: var(--space-2); }
.steps li { counter-increment: step; padding-left: 3rem; position: relative; max-width: var(--measure); }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  background: var(--brand); color: #ffffff;
  border-radius: 50%; font-weight: 800;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form { max-width: 40rem; }
.field { margin-bottom: var(--space-3); }
.field label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.field .hint { display: block; font-weight: 400; color: var(--text-muted); font-size: var(--step--1); margin-bottom: 0.4rem; }
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { border-color: var(--brand); }
.field .req { color: var(--accent-ink); }
fieldset.field { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2); }
fieldset.field legend { font-weight: 700; padding-inline: 0.4rem; }

/* --------------------------------------------------------------------------
   Blog
   -------------------------------------------------------------------------- */

.post-list { list-style: none; padding: 0; display: grid; gap: var(--space-3); }
.post-list li { border-bottom: 1px solid var(--border); padding-bottom: var(--space-3); }
.post-list h2, .post-list h3 { margin-bottom: 0.25rem; }
.post-meta { color: var(--text-muted); font-size: var(--step--1); margin-bottom: 0.5rem; }
.post-body { max-width: var(--measure); }
.post-body > * + * { margin-top: var(--space-2); }
.post-body h2 { margin-top: var(--space-3); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  background: var(--band-bg);
  color: var(--band-text);
  padding-block: var(--space-4);
  margin-top: var(--space-6);
}
.footer-inner {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.site-footer a { color: var(--band-text); }
.site-footer a:hover { color: var(--accent-ink); }
.footer-name { font-weight: 800; font-size: var(--step-1); margin: 0; }
.footer-tagline { color: var(--band-muted); margin: 0.25rem 0 0; }
.footer-nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.footer-dogfood { color: var(--band-muted); font-size: var(--step--1); }
.footer-copy { color: var(--band-muted); font-size: var(--step--1); }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.text-center { text-align: center; }
.text-center p, .text-center .lede { margin-inline: auto; }
.mt-0 { margin-top: 0; }
.stack > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-4); }
.text-center .btn-row { justify-content: center; }

/* Eyebrow sitting on a dark feature band needs a light tint (the default
   amber-ink would not meet contrast on dark navy). */
.section--ink .eyebrow { color: #ffce7a; }

/* Radio/checkbox choices inside a fieldset */
.choice { margin-bottom: 0.35rem; }
.choice label { display: inline; font-weight: 400; margin-left: 0.4rem; }

/* Small helper note under a form */
.form-note { margin-top: var(--space-2); color: var(--text-muted); font-size: var(--step--1); }

/* Windows High Contrast / forced-colors: keep affordances visible */
@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText; }
  .theme-toggle, .nav-toggle { border: 2px solid ButtonText; }
  .nav-list a[aria-current="page"] { box-shadow: none; text-decoration: underline; }
  .card, .service, .entry-card, .arm-card { border: 1px solid CanvasText; }
}
