/* Garuda AI Learning Lab. Calm light theme: navy ink on warm neutrals with a
   restrained orange accent. System fonts only; no external requests. */

:root {
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #efe9dd;
  --ink: #1a2b45;
  --ink-soft: #37465c;
  --muted: #5b6270;
  --line: #ddd4c4;
  --line-strong: #c3b7a2;
  --accent: #c0561a;
  --accent-ink: #9a4211;
  --accent-wash: #fbeee2;
  --pass: #25603a;
  --pass-wash: #e5f0e7;
  --fail: #a2281d;
  --fail-wash: #f8e6e2;
  --warn: #7c5200;
  --warn-wash: #fbf0d6;
  --focus: #d0621c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --shadow: 0 1px 2px rgb(26 43 69 / 6%), 0 4px 16px rgb(26 43 69 / 5%);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; color: var(--ink); }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.4rem); margin: 0.25rem 0 0.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 0 0 0.35rem; }
p { margin: 0 0 0.9rem; }
a { color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-ink); }
code, pre { font-family: var(--mono); font-size: 0.875rem; }
mark { background: #f8dcc2; color: var(--ink); padding: 0 0.1em; border-radius: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: 3px solid var(--focus); }
[hidden] { display: none !important; }

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

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 10;
  background: var(--ink); color: #fff; padding: 0.5rem 0.9rem; border-radius: var(--radius);
}
.skip-link:focus { top: 0.75rem; color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem); }
.narrow { max-width: 780px; }

/* ---------- header ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1rem; padding-bottom: 0.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 1.5px solid var(--ink); border-radius: 5px; box-shadow: inset 0 -3px 0 var(--accent);
  font: 600 1.35rem/1 var(--serif); color: var(--ink);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font: 600 1.25rem/1.2 var(--serif); }
.brand-tag { font-size: 0.8rem; color: var(--muted); }
.demo-flag { margin: 0; font-size: 0.8rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.75rem; background: var(--paper); }

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: thin; }
.tabs a {
  flex: none; padding: 0.7rem 0.85rem 0.6rem; text-decoration: none; color: var(--ink-soft);
  border-bottom: 3px solid transparent; font-weight: 500;
}
.tabs a:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { display: block; padding: 2rem 0 4rem; }
main:focus { outline: none; }

.eyebrow { margin: 0; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-ink); }
.lead { font-size: 1.075rem; color: var(--ink-soft); max-width: 70ch; }
.section-note { color: var(--muted); max-width: 75ch; }
.muted { color: var(--muted); }
.hint { font-size: 0.85rem; color: var(--muted); margin: 0.25rem 0 0.75rem; }
.fine { font-size: 0.8rem; color: var(--muted); margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.6rem; padding: 0.5rem 1.1rem; border-radius: var(--radius);
  font: 600 0.95rem/1.2 var(--sans); text-decoration: none; cursor: pointer; border: 1.5px solid var(--ink);
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #24395b; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); text-decoration: underline; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0 0.5rem; }

/* ---------- overview ---------- */

.intro { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.glance { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); }
.glance h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.glance dl { margin: 0; }
.glance dl > div { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.75rem; padding: 0.5rem 0; border-top: 1px solid var(--line); }
.glance dt { color: var(--muted); font-size: 0.9rem; }
.glance dd { margin: 0; }

.flow { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; counter-reset: none; }
.flow li { display: flex; gap: 0.75rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.flow p { margin: 0; color: var(--ink-soft); font-size: 0.93rem; }
.flow-no, .step-no {
  flex: none; display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  border: 1.5px solid var(--accent); color: var(--accent-ink); font: 600 0.95rem/1 var(--sans);
}

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); }
thead th { font: 600 0.75rem/1.3 var(--sans); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 600; }
tfoot th, tfoot td { border-top: 1.5px solid var(--line-strong); border-bottom: 0; font-weight: 600; }
.outline td:nth-child(2) { white-space: nowrap; }

.test-id, .req-id, .note-id { font: 600 0.8rem/1.3 var(--mono); color: var(--accent-ink); white-space: nowrap; }
.test-title { display: block; font-weight: 400; color: var(--ink-soft); }
.input-json { display: block; max-width: 30ch; word-break: break-all; color: var(--ink-soft); }
.reason { display: block; margin-top: 0.3rem; font-size: 0.85rem; color: var(--fail); }
tr.row-fail > :first-child { box-shadow: inset 3px 0 0 var(--fail); }

.badge { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-pass { background: var(--pass-wash); color: var(--pass); }
.badge-fail { background: var(--fail-wash); color: var(--fail); }
.badge-not-run, .badge-no-tests { background: var(--surface-2); color: var(--muted); }
.status-text { display: block; margin-top: 0.25rem; font-size: 0.85rem; color: var(--muted); }

/* ---------- lab ---------- */

.step { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.step h2 { display: flex; align-items: center; gap: 0.6rem; margin-top: 0; }

.req-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.req { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; }
.req-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin-bottom: 0.3rem; }
.req-count { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.req p { margin: 0; font-size: 0.93rem; color: var(--ink-soft); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.panel-title { font-size: 1.05rem; margin: 1.25rem 0 0.25rem; }
.panel > .panel-title:first-child, .source-head .panel-title { margin-top: 0; }
.candidate-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1.25rem; align-items: start; }
.evidence-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1.25rem; align-items: start; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 0.4rem; }
.option-list { display: grid; gap: 0.5rem; }
.option-card { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.7rem 0.8rem; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--paper); }
.option-card:has(input:checked) { border-color: var(--ink); background: var(--surface); }
.option-card input { margin-top: 0.3rem; }
.option-body { display: flex; flex-direction: column; }
.option-title { font-weight: 600; }
.option-desc { font-size: 0.87rem; color: var(--muted); }
.candidate-status { margin: 0.75rem 0 0; font-size: 0.93rem; }
.tag { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.tag-warn { background: var(--warn-wash); color: var(--warn); }

input, select, button { font: inherit; color: inherit; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }
input[type="number"], input[type="search"], select {
  min-height: 2.5rem; padding: 0.4rem 0.6rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: #fff;
}
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 1rem; }
.field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.field-number input { width: 8rem; }
.field-number .hint { margin: 0; }
.field-check { flex-direction: row; align-items: flex-start; gap: 0.5rem; grid-column: 1 / -1; }
.field-check input { margin-top: 0.3rem; flex: none; }
.field-group { grid-column: 1 / -1; padding-top: 0.4rem; }
.field-group legend { font-weight: 500; }
.inline-option { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0 1.1rem 0.3rem 0; }
.field-label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.adjustments ul { margin: 0.75rem 0 0; padding-left: 1.5rem; }

.source-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; }
.toggle { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
pre.source {
  margin: 0; padding: 0.75rem 0; overflow-x: auto; background: #fbf8f1; border: 1px solid var(--line);
  border-radius: var(--radius); line-height: 1.55; counter-reset: line;
}
pre.source code { display: block; min-width: max-content; }
pre.source .line { display: block; padding: 0 1rem 0 0; counter-increment: line; }
pre.source .line::before {
  content: counter(line); display: inline-block; width: 4.5ch; margin-right: 1.25ch; padding-right: 0.75ch;
  text-align: right; color: #9a9384; border-right: 1px solid var(--line); user-select: none;
}
pre.source .line.is-diff { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
pre.source .line.is-diff::before { content: "Δ " counter(line); color: var(--accent-ink); font-weight: 600; }

.run-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-bottom: 1rem; }
.run-status { margin: 0; color: var(--ink-soft); }
.stats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.5rem; }
.stat { display: flex; flex-direction: column; min-width: 7rem; padding: 0.6rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.stat-value { font: 600 1.8rem/1.1 var(--serif); }
.stat-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-pass .stat-value { color: var(--pass); }
.stat-fail { border-color: #e2b3ab; background: var(--fail-wash); }
.stat-fail .stat-value { color: var(--fail); }
.run-meta { font-size: 0.87rem; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 0; margin: 0 0 1rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.segmented label { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem; cursor: pointer; font-size: 0.9rem; }
.segmented label + label { border-left: 1px solid var(--line); }
.segmented label:has(input:checked) { background: var(--surface-2); font-weight: 600; }

.callout { margin: 0.75rem 0; padding: 0.7rem 0.9rem; border-radius: var(--radius); border-left: 4px solid; font-size: 0.93rem; }
.callout ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.callout p:last-child { margin-bottom: 0; }
ul.callout { padding-left: 1.9rem; }
.callout-pass { background: var(--pass-wash); border-color: var(--pass); }
.callout-fail { background: var(--fail-wash); border-color: var(--fail); }
.callout-warn { background: var(--warn-wash); border-color: #c79a2e; }

select { width: 100%; max-width: 26rem; }
details { margin-top: 0.75rem; }
summary { cursor: pointer; font-weight: 600; padding: 0.3rem 0; }
pre.json { max-height: 26rem; overflow: auto; margin: 0.5rem 0 0; padding: 0.75rem 1rem; background: #fbf8f1; border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.8rem; }

/* ---------- traceability ---------- */

.gap-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.93rem; }
.gap-ok span { color: var(--pass); font-weight: 700; }
.gap-bad { color: var(--fail); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { font: 0.78rem/1.2 var(--mono); padding: 0.2rem 0.45rem; border-radius: 4px; border: 1px solid var(--line); background: var(--paper); white-space: nowrap; }
.chip-pass { border-color: #b7d3bf; background: var(--pass-wash); color: var(--pass); }
.chip-fail { border-color: #e2b3ab; background: var(--fail-wash); color: var(--fail); font-weight: 700; }
.trace th[scope="row"] { min-width: 12rem; }

/* ---------- library ---------- */

.search-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1.25rem; margin: 1.5rem 0 0.5rem; }
.search-row { flex: 1 1 26rem; }
.search-input { display: flex; gap: 0.5rem; }
.search-input input { flex: 1; min-width: 0; }
.search-form .segmented { margin: 0; }
.search-status { color: var(--ink-soft); min-height: 1.6em; }
.library-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.25rem; align-items: start; }
.results-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.9rem; }
.result.is-open { border-color: var(--ink); }
.result-open { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; font: 600 1rem/1.35 var(--serif); color: var(--ink); }
.result-open:hover .result-title { text-decoration: underline; text-decoration-color: var(--accent); }
.snippet { margin: 0.35rem 0 0; font-size: 0.9rem; color: var(--ink-soft); }
.matched { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--muted); }
.note-detail { position: sticky; top: 1rem; }
.note-detail h2 { margin-top: 0.25rem; }
.note-detail h3 { margin-top: 1.25rem; }
.sources { padding-left: 1.2rem; margin: 0; }
.sources li { margin-bottom: 0.35rem; }
.host { display: block; font-size: 0.8rem; color: var(--muted); }

/* ---------- limits ---------- */

.limits { padding-left: 1.2rem; }
.limits li { margin-bottom: 0.6rem; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: 0; padding: 1.1rem 0; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .intro, .candidate-grid, .evidence-grid, .library-grid { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-detail { position: static; }
}

@media (max-width: 700px) {
  main { padding-top: 1.25rem; }
  .flow, .req-list, .settings-form { grid-template-columns: minmax(0, 1fr); }
  .glance dl > div { grid-template-columns: 1fr; gap: 0.1rem; }
  .demo-flag { display: none; }

  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack tr, table.stack td, table.stack th { display: block; width: 100%; }
  table.stack tr { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); }
  table.stack tr.row-fail { box-shadow: inset 3px 0 0 var(--fail); }
  table.stack tr.row-fail > :first-child { box-shadow: none; }
  table.stack td, table.stack th { border: 0; padding: 0.25rem 0; }
  table.stack [data-label]::before {
    content: attr(data-label); display: block; font: 600 0.7rem/1.4 var(--sans);
    letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  }
  .input-json { max-width: none; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media print {
  .site-header .tabs, .skip-link, .actions, .button-row, .run-bar button { display: none; }
  body { background: #fff; }
  .panel, .table-wrap { box-shadow: none; }
}
