/* WebCLI Spec — style.css
   Furo-inspired design by Pradyun Gedam
   System fonts, CSS custom properties, no framework. */

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  --bg-primary:    #ffffff;
  --bg-secondary:  #f8f9fb;
  --bg-hover:      #efeff4;
  --border:        #eeebee;

  --text-primary:  #000000;
  --text-secondary:#5a5c63;
  --text-muted:    #6b6f76;

  --accent:        #2757dd;
  --accent-visited:#872ee0;

  --code-bg:       #f2f2f2;
  --code-fg:       #1e1e1e;
  --prompt-color:  #f6822d;
  --comment-color: #6b7280;

  /* Sidebar/TOC scale with viewport: min = current, max ≈ 2× on standard full-screen */
  --sidebar-width: clamp(15em, 25vw, 30em);
  --toc-width:     clamp(14em, 23.5vw, 28em);
  --content-max:   60em;   /* ~30% wider than original 46em */

  --radius:        0.2rem;
  --shadow-sm:     0 .2rem .5rem rgba(0,0,0,.05);
}

[data-theme="dark"] {
  --bg-primary:    #131416;
  --bg-secondary:  #1a1c1e;
  --bg-hover:      #22262a;
  --border:        #303335;

  --text-primary:  #cfd0d0;
  --text-secondary:#9ca0a5;
  --text-muted:    #6b6f76;

  --accent:        #5ca5ff;
  --accent-visited:#b27aeb;

  --code-bg:       #202020;
  --code-fg:       #d0d0d0;

  --shadow-sm:     0 .2rem .5rem rgba(0,0,0,.25);
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 100%; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--accent-visited); }

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.25;
  margin: 1.5em 0 .5em;
  color: var(--text-primary);
}
h1 { font-size: 2.5em; margin-top: 0; }
h2 { font-size: 1.75em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
h3 { font-size: 1.25em; }
h4 { font-size: 1em; }

p { margin: .75em 0; }
ul, ol { margin: .75em 0 .75em 1.5em; }
li { margin: .25em 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ============================================================
   3. CODE
   ============================================================ */
code {
  font-family: "SFMono-Regular", Menlo, Consolas, Monaco, "Liberation Mono", monospace;
  font-size: 81.25%;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: .1em .3em;
  border-radius: var(--radius);
}

pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  padding: .625rem .875rem;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 81.25%;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.prompt { color: var(--prompt-color); user-select: none; }
.comment { color: var(--comment-color); }

/* ============================================================
   4. TABLES
   ============================================================ */
.spec-table,
#md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 87.5%;
}
.spec-table th,
#md-content th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: .5em .75em;
  border-bottom: 2px solid var(--border);
}
.spec-table td,
#md-content td {
  padding: .5em .75em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.spec-table tr:last-child td,
#md-content tr:last-child td { border-bottom: none; }

/* ============================================================
   5. SPEC METADATA TABLE
   ============================================================ */
.spec-meta {
  margin: 0;
  padding: 0;
  width: 100%;
}
.spec-meta-row {
  display: flex;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding: .45em 0;
  gap: 1em;
}
.spec-meta-row:last-child { border-bottom: none; }
.spec-meta dt {
  flex: 0 0 7em;
  font-weight: 600;
  font-size: 87.5%;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.spec-meta dd {
  margin: 0;
  font-size: 87.5%;
  color: var(--text-primary);
}

/* ============================================================
   6. ADMONITIONS
   ============================================================ */
.admonition {
  border-left: 3.2px solid var(--accent);
  padding: .75em 1em;
  margin: 1.25em 0;
  box-shadow: var(--shadow-sm);
}
.admonition.warning { border-left-color: #ff9100; }
.admonition-title {
  font-weight: 700;
  font-size: 87.5%;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  margin-bottom: .35em;
}
.admonition p:last-child { margin-bottom: 0; }

/* ============================================================
   7. LAYOUT
   ============================================================ */
.sidebar-toggle-input { display: none; }

.page-wrap {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-inner {
  padding: 1.5em 1em;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-brand {
  margin-bottom: 1.5em;
  display: flex;
  align-items: baseline;
  gap: .5em;
}
.sidebar-brand a {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--text-primary);
}
.sidebar-brand a:visited { color: var(--text-primary); }
.sidebar-brand-link {
  display: inline-flex;
  align-items: center;
  gap: .4em;
}
.sidebar-logo {
  height: 1.4em;
  width: auto;
  display: block;
}
.version-badge {
  font-size: 68%;
  font-family: "SFMono-Regular", Menlo, Consolas, Monaco, monospace;
  background: var(--bg-hover);
  color: var(--text-muted);
  padding: .1em .4em;
  border-radius: var(--radius);
}

/* Nav tree */
.nav-tree, .nav-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-tree > li { margin: .1em 0; }
.nav-tree a {
  display: block;
  padding: .25em .5em;
  border-radius: var(--radius);
  font-size: 87.5%;
  color: var(--text-secondary);
  transition: background .12s, color .12s;
}
.nav-tree > li > a {
  font-weight: 600;
  color: var(--text-primary);
}
.nav-tree a:hover {
  background: var(--bg-hover);
  color: var(--accent);
  text-decoration: none;
}
.nav-tree a:visited { color: inherit; }
.nav-tree ul {
  margin: .1em 0 .2em 1em;
  border-left: 1px solid var(--border);
  padding-left: .5em;
}

.sidebar-footer { margin-top: auto; padding-top: 1em; }

/* --- Content --- */
.content {
  flex: 1;
  min-width: 0;
  padding: 2.5em 3em;
  max-width: var(--content-max);
}

.content section { margin-bottom: 3em; }

/* Anchor headings */
.headerlink { color: inherit; text-decoration: none; }
.pilcrow {
  color: var(--border);
  font-size: .75em;
  margin-left: .25em;
  transition: color .1s;
}
h2:hover .pilcrow,
h3:hover .pilcrow { color: var(--accent); }

/* --- Right TOC --- */
.right-toc {
  width: var(--toc-width);
  min-width: var(--toc-width);
  flex-shrink: 0;
  padding: 2.5em 1em 2.5em 1.5em;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  font-size: 75%;
  border-left: 1px solid var(--border);
}
.toc-title {
  font-size: 62.5%;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .75em;
}
.right-toc ul, .right-toc ul ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.right-toc ul ul { margin-left: 1em; }
.right-toc a {
  display: block;
  padding: .2em 0;
  color: var(--text-secondary);
  line-height: 1.3;
}
.right-toc a:hover { color: var(--accent); text-decoration: none; }
.right-toc a:visited { color: var(--text-secondary); }

/* ============================================================
   8. HERO
   ============================================================ */
.hero { padding: 1em 0 2em; }
.hero-eyebrow {
  font-size: 75%;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .5em;
}
.hero h1 { margin-bottom: .4em; }
.hero-lead {
  font-size: 1.1em;
  color: var(--text-secondary);
  max-width: 48em;
  margin-bottom: 1.5em;
}

/* Hero stat tiles */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: .5em 2em;
  margin-bottom: 1.25em;
}
.hero-stat { min-width: 0; }
.hero-stat-value {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  margin: 0;
}
.hero-stat-label {
  font-size: 80%;
  color: var(--text-muted);
  margin: .2em 0 0;
  line-height: 1.3;
}
@media (max-width: 540px) {
  .hero-stats { grid-template-columns: 1fr 1fr; }
}

.hero-actions {
  display: flex;
  gap: .75em;
  flex-wrap: wrap;
  margin-bottom: 1.75em;
}
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: .5em 1.25em;
  border-radius: .25rem;
  font-size: 87.5%;
  font-weight: 600;
  transition: opacity .12s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { opacity: .88; text-decoration: none; color: #fff; }
.btn-primary:visited { color: #fff; }
.btn-secondary {
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-secondary);
}
.btn-secondary:hover { background: var(--bg-hover); text-decoration: none; }
.btn-secondary:visited { color: var(--text-secondary); }

.hero-code { margin-top: .5em; }

/* Hero compare: good vs bad side by side */
.hero-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
  margin-top: 1.25em;
}
.hero-compare-pane {
  min-width: 0;
}
.hero-compare-label {
  font-size: 72%;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: .35em;
}
.hero-compare-label.label-good { color: #2da44e; }
.hero-compare-label.label-bad  { color: #cf222e; }
[data-theme="dark"] .hero-compare-label.label-good { color: #3fb950; }
[data-theme="dark"] .hero-compare-label.label-bad  { color: #f85149; }
.hero-compare pre {
  margin: 0;
  font-size: 77%;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: .75em 1em;
  overflow-x: auto;
  height: 100%;
}
.hero-compare pre code { background: none; }
@media (max-width: 600px) {
  .hero-compare { grid-template-columns: 1fr; }
}

/* ============================================================
   9. MOBILE HEADER
   ============================================================ */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: .75em 1em;
  align-items: center;
  gap: 1em;
}
.mobile-header .site-title {
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: .35em;
}
.header-logo {
  height: 1.25em;
  width: auto;
  display: block;
}
.nav-icon {
  cursor: pointer;
  font-size: 1.2em;
  color: var(--text-secondary);
  user-select: none;
}

/* ============================================================
   10. THEME TOGGLE
   ============================================================ */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 87.5%;
  padding: .25em .5em;
  display: flex;
  align-items: center;
  gap: .3em;
}
.theme-toggle:hover { background: var(--bg-hover); }

/* ============================================================
   11. PAGE FOOTER
   ============================================================ */
.page-footer {
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--border);
  font-size: 81.25%;
  color: var(--text-muted);
}
.footer-disclaimer {
  margin-top: .5em;
  font-size: 87.5%;
  color: var(--text-muted);
  opacity: .75;
}

/* ============================================================
   12. RESPONSIVE
   ============================================================ */

/* Collapse right TOC at ~82em */
@media (max-width: 82em) {
  .right-toc { display: none; }
}

/* Collapse sidebar to drawer at ~63em */
@media (max-width: 63em) {
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    z-index: 99;
    height: 100vh;
    transition: left .25s ease-in-out;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
  }

  /* CSS checkbox hack: show sidebar when checked */
  .sidebar-toggle-input:checked ~ .page-wrap .sidebar {
    left: 0;
  }

  .content { padding: 1.5em 1.25em; }
  .theme-toggle-sidebar { display: none; }
}

/* Full-width content on small screens */
@media (max-width: 46em) {
  .content { padding: 1em .75em; }
  h1 { font-size: 1.75em; }
  h2 { font-size: 1.35em; }
  .hero-lead { font-size: 1em; }
  pre { font-size: 75%; }
}

/* ============================================================
   13. NAV EXTRAS
   ============================================================ */

/* Section label — Furo-style: small caps, muted, de-emphasized */
.nav-section-label {
  display: block;
  padding: .35em .5em .2em;
  font-size: 62.5%;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

/* Collapsible nav section */
.nav-collapsible-input { display: none; }

.nav-collapsible-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .25em .5em;
  border-radius: var(--radius);
  font-size: 87.5%;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.nav-collapsible-label:hover { background: var(--bg-hover); }

.nav-toggle-icon {
  font-size: 70%;
  color: var(--text-muted);
  transition: transform .15s;
}

.nav-collapsible-list {
  display: none;
  list-style: none;
  margin: .1em 0 .2em 1em !important;
  border-left: 1px solid var(--border);
  padding-left: .5em !important;
}

.nav-collapsible-input:checked ~ .nav-collapsible-list {
  display: block;
}
.nav-collapsible-input:checked ~ .nav-collapsible-label .nav-toggle-icon {
  transform: rotate(90deg);
}

/* Fix label/input ordering for CSS sibling selector */
.nav-collapsible {
  position: relative;
}
.nav-collapsible .nav-collapsible-label { display: flex; }

/* Current page / active nav link — accent blue, not purple */
.nav-tree a[aria-current="page"] {
  background: var(--bg-hover);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.nav-tree a[aria-current="page"]:visited {
  color: var(--accent);
}

/* Evidence list: CLI as parent with help/examples sub-links */
.nav-cli-parent {
  margin: .4em 0;
  list-style: none;
}
.nav-cli-name {
  display: block;
  font-family: "SFMono-Regular", Menlo, Consolas, Monaco, monospace;
  font-size: 81.25%;
  color: var(--text-muted);
  padding: .1em .5em 0;
  margin-bottom: .15em;
}
.nav-cli-sublist {
  list-style: none;
  margin: 0 !important;
  padding: 0 0 0 .25em !important;
  border-left: none !important;
}
.nav-cli-sublist li { margin: 0; }
.nav-cli-sublist a {
  padding: .15em .5em;
  font-size: 81.25%;
}

/* Article page — article-style hero (no terminal block) */
.article-hero { padding: 1em 0 2em; border-bottom: 1px solid var(--border); margin-bottom: 2em; }
.article-hero h1 { margin-bottom: .4em; }
.article-meta {
  font-size: 81.25%;
  color: var(--text-muted);
  margin-top: .5em;
}

/* Review score block — shown just below article-hero on CLI review pages */
.review-score-block {
  display: flex;
  align-items: center;
  gap: 1.1em;
  margin: 1.6em 0 2em;
  padding: 1em 1.25em;
  border: 1px solid var(--border);
  border-left: 3.2px solid var(--accent);
  background: var(--bg-secondary);
  border-radius: var(--radius);
}
.score-badge {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  min-width: 2.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.score-badge.score-good { color: var(--accent); }
.score-badge.score-ok   { color: #b45309; }
.score-badge.score-poor { color: #9b1c1c; }
[data-theme="dark"] .score-badge.score-ok   { color: #fbbf24; }
[data-theme="dark"] .score-badge.score-poor { color: #f87171; }
.score-label {
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.score-meta {
  font-size: .8125rem;
  color: var(--text-secondary);
  flex: 1;
}
.score-link {
  font-size: .8125rem;
  white-space: nowrap;
}

/* Ranking page score column */
.rank-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rank-score.score-good { color: var(--accent); }
.rank-score.score-ok   { color: #b45309; }
.rank-score.score-poor { color: #9b1c1c; }
[data-theme="dark"] .rank-score.score-ok   { color: #fbbf24; }
[data-theme="dark"] .rank-score.score-poor { color: #f87171; }

/* Viewer page */
.viewer-meta {
  font-size: 81.25%;
  color: var(--text-muted);
  margin-bottom: 1.5em;
  padding-bottom: .75em;
  border-bottom: 1px solid var(--border);
}
.viewer-raw-link {
  font-family: "SFMono-Regular", Menlo, Consolas, Monaco, monospace;
  font-size: 87.5%;
}
#md-content h1 { font-size: 2em; margin-top: 1em; }
#md-content h2 { font-size: 1.5em; }
#md-content h3 { font-size: 1.2em; }
#md-content blockquote { border-left: 3.2px solid var(--accent); padding: .5em 1em; margin: 1em 0; color: var(--text-secondary); }
#md-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
