/* ==========================================================================
   When 27B Feels Bigger: A Local Qwen3.8 Agent Field Guide
   Warm beige technical site · dark navy accent · no remote dependencies
   ========================================================================== */

:root {
  /* Palette */
  --bg:            #f3ecdf;   /* warm beige page */
  --bg-alt:        #ece2cf;   /* deeper beige band */
  --surface:       #faf6ee;   /* card surface */
  --surface-2:     #f6f0e3;
  --ink:           #2a2620;   /* warm near-black text */
  --ink-soft:      #5d5546;
  --ink-faint:     #8a8070;
  --navy:          #17263f;   /* dark navy accent */
  --navy-deep:     #101c30;
  --navy-soft:     #24395e;
  --navy-tint:     #dfe5ee;   /* navy used on light fills */
  --accent-amber:  #8f5a1a;   /* warm amber for the selected variant (darkened in Phase 5: white-on-amber badge 3.79→5.76, amber computed-note 3.52→5.34) */
  --accent-amber-soft: #e8d5b5;
  --line:          #d8ccb4;
  --line-soft:     #e3d9c4;
  --good:          #4f7a52;
  --warn:          #a05a2c;
  --focus:         #b3762a;

  /* Type */
  --font-body: "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  /* Shape */
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(42, 38, 32, 0.06), 0 6px 18px rgba(42, 38, 32, 0.08);
  --focus-ring: 3px solid var(--focus);
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -100px, rgba(23, 38, 63, 0.06), transparent 60%),
    var(--bg);
}

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

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  background: var(--navy);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 8px 8px;
  z-index: 100;
  transition: top 0.15s ease;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* Visible keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

main > section {
  padding: 2.75rem 0 0.5rem;
  scroll-margin-top: 4.5rem;
}

h1, h2, h3 {
  line-height: 1.25;
  color: var(--navy);
  margin: 0 0 0.6rem;
}
h2 {
  font-size: 1.65rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--line);
}
h2::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  margin-top: -2px;
  background: var(--accent-amber);
  border-radius: 2px;
}
p { margin: 0 0 1rem; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 0.08em 0.35em;
}

.num {
  font-family: var(--font-mono);
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Header ---------- */
.site-header {
  background:
    radial-gradient(700px 260px at 15% 0%, rgba(23, 38, 63, 0.10), transparent 70%),
    var(--navy);
  color: #f0ebe0;
  padding: 3.25rem 0 2.5rem;
}
.site-header .eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #c9a76a;
  margin-bottom: 0.9rem;
}
.site-header h1 {
  color: #fff;
  font-size: clamp(1.8rem, 4.2vw, 2.7rem);
  max-width: 22ch;
}
.site-header .lede {
  max-width: 62ch;
  font-size: 1.02rem;
  color: #d9d4c7;
}
.site-header code {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.22);
  color: #efe9db;
}

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0;
  margin: 1.4rem 0 0;
}
.chip {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
}
.chip-k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #b7ae9d;
}
.chip-v {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

/* ---------- Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(42, 38, 32, 0.06);
}
.nav-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.55rem 1.25rem;
}
.site-nav a {
  color: var(--navy);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
}
.site-nav a:hover {
  background: var(--navy-tint);
  text-decoration: underline;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.1rem 0 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
caption { text-align: left; padding: 0.7rem 1rem; }
thead th {
  background: var(--navy);
  color: #f0ebe0;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.6rem 0.9rem;
}
tbody th[scope="row"] {
  text-align: left;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}
tbody td, tbody th {
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--line-soft);
}
tbody tr:nth-child(even) { background: var(--surface-2); }

.fact-table tbody td { font-family: var(--font-mono); font-size: 0.92rem; }

.provenance, .thermal-note, .kbd-hint {
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-left: 3px solid var(--navy-soft);
  border-radius: 0 8px 8px 0;
  padding: 0.7rem 1rem;
}
.thermal-note { border-left-color: var(--warn); }
.kbd-hint { border-left-color: var(--accent-amber); margin-top: 1rem; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05em 0.45em;
}

/* ---------- Variant cards ---------- */
.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 1rem;
  margin: 1.2rem 0 1.5rem;
}
.variant-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--navy-soft);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: var(--shadow);
}
.variant-card h3 { margin-bottom: 0.1rem; font-size: 1.25rem; }
.variant-tag {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 0 0 0.7rem;
}
.variant-card.hero {
  border-top-color: var(--accent-amber);
  background:
    linear-gradient(180deg, var(--accent-amber-soft) 0%, var(--surface) 140px);
}
.hero-badge {
  position: absolute;
  top: -0.85rem;
  right: 0.9rem;
  background: var(--accent-amber);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.variant-stats {
  margin: 0;
  display: grid;
  gap: 0.45rem;
}
.variant-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px dashed var(--line-soft);
  padding-bottom: 0.4rem;
}
.variant-stats > div:last-child { border-bottom: 0; padding-bottom: 0; }
.variant-stats dt {
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.variant-stats dd {
  margin: 0;
  font-weight: 600;
  color: var(--navy);
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Charts ---------- */
.chart-figure {
  margin: 1.3rem 0 1.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.chart-figure figcaption {
  font-size: 0.83rem;
  color: var(--ink-faint);
  margin-top: 0.6rem;
}
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }

.computed-note { color: var(--accent-amber); font-style: normal; font-weight: 600; }

/* ---------- Compare controls ---------- */
.compare-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: flex-end;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  margin-bottom: 1.1rem;
}
.endpoint-field {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.endpoint-field legend {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
  padding: 0;
}
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.radio-pill:hover { border-color: var(--navy-soft); }
.radio-pill:has(input:checked) {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}
.radio-pill input { accent-color: var(--accent-amber); }

.select-pair { display: flex; flex-wrap: wrap; gap: 1rem; }
.select-pair label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
select {
  font: inherit;
  font-size: 0.95rem;
  min-width: 150px;
  padding: 0.45rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
select:hover { border-color: var(--navy-soft); }

output#compare-result {
  display: block;
  margin-top: 0.7rem;
  font-size: 0.95rem;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  color: var(--ink-soft);
}
output#compare-result strong { color: var(--navy); }

/* ---------- Lessons & limitations ---------- */
.lessons {
  counter-reset: lesson;
  list-style: none;
  padding: 0;
  margin: 1.1rem 0 1.4rem;
  display: grid;
  gap: 0.8rem;
}
.lessons > li {
  counter-increment: lesson;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 0.85rem 3.4rem;
  box-shadow: var(--shadow);
}
.lessons > li::before {
  content: counter(lesson);
  position: absolute;
  left: 0.9rem;
  top: 0.95rem;
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
}

.limitations {
  list-style: none;
  padding: 0;
  margin: 1.1rem 0 1.4rem;
  display: grid;
  gap: 0.6rem;
}
.limitations > li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow);
}

.packet-notes {
  margin: 1rem 0 1.4rem;
  padding: 0.9rem 1.2rem;
  background: var(--navy);
  color: #e7e2d6;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.packet-notes p { margin: 0 0 0.55rem; }
.packet-notes p:last-child { margin-bottom: 0; }

/* ---------- Thermals grid ---------- */
.thermal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}
.thermal-grid .chart-figure { margin: 0 0 1rem; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 3rem;
  background: var(--navy-deep);
  color: #cfc9bb;
  padding: 1.6rem 0;
  font-size: 0.88rem;
}
.site-footer strong { color: #fff; }
.site-footer code {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #efe9db;
}
.footer-meta { color: #a39d90; margin-bottom: 0; }

/* ---------- Noscript ---------- */
.noscript-note {
  background: var(--accent-amber-soft);
  border: 1px solid var(--accent-amber);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 1rem auto;
  max-width: 1060px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .variant-grid { grid-template-columns: repeat(auto-fit, minmax(100%, 1fr)); }
  .compare-controls { flex-direction: column; align-items: stretch; }
  .select-pair { flex-direction: column; }
  select { min-width: 0; width: 100%; }
  main > section { padding-top: 2.1rem; }
}
