/* ─── Custom Properties ─────────────────────────────────────────── */
:root {
  --bg:           #f7f8fc;
  --bg-raised:    #ffffff;
  --bg-card:      #f0f2f8;
  --bg-code:      #f4f5f9;
  --border:       #dde1ed;
  --border-light: #c8cde0;
  --text:         #1e2235;
  --text-muted:   #5a6180;
  --text-dim:     #9099b8;
  --accent:       #3b6fe0;
  --accent-soft:  #e8eefb;
  --green:        #1e8f52;
  --green-soft:   #e6f5ed;
  --yellow:       #9a6b00;
  --yellow-soft:  #fdf6e3;
  --red:          #c0392b;
  --cyan:         #1a7fa0;
  --cyan-soft:    #e6f4f8;
  --purple:       #6c3eb0;
  --orange:       #b85c00;
  --nav-width:    280px;
  --header-h:     56px;
  --font-mono:    'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  padding-top: var(--header-h);
}

/* ─── Topbar ────────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo img {
  height: 32px;
  display: block;
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 14px;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59,111,224,0.25);
  border-radius: 20px;
  padding: 3px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Layout ────────────────────────────────────────────────────── */
#layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

/* ─── Sidebar Nav ───────────────────────────────────────────────── */
#nav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--nav-width);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  padding: 16px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#nav::-webkit-scrollbar { width: 4px; }
#nav::-webkit-scrollbar-track { background: transparent; }
#nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 16px 20px 6px;
}

.nav-section:first-child { padding-top: 4px; }

#nav a {
  display: block;
  font-size: 13.5px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 20px 5px 28px;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

#nav a.sub {
  font-size: 13px;
  padding-left: 44px;
}

#nav a.subsub {
  font-size: 12.5px;
  padding-left: 60px;
}

#nav a:hover {
  color: var(--text);
  background: rgba(59,111,224,0.04);
}

#nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

/* ─── Main Content ──────────────────────────────────────────────── */
#content {
  margin-left: var(--nav-width);
  flex: 1;
  padding: 48px 56px 100px;
  max-width: calc(var(--nav-width) + 900px);
}

/* ─── Typography ────────────────────────────────────────────────── */
h1 {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

h1 .sub {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 10px;
}

h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
  margin-top: 8px;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--cyan);
  font-family: var(--font-mono);
  margin-bottom: 10px;
  margin-top: 6px;
}

h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

p { margin-bottom: 14px; }
p:last-child { margin-bottom: 0; }

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

ul, ol { margin: 0 0 14px 20px; }

li { margin-bottom: 4px; }

code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--cyan);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 12px 0 16px;
}

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

/* ─── Syntax color helpers ──────────────────────────────────────── */
.t-cyan   { color: var(--cyan); }
.t-green  { color: var(--green); }
.t-yellow { color: var(--yellow); }
.t-orange { color: var(--orange); }
.t-purple { color: var(--purple); }
.t-muted  { color: var(--text-muted); }
.t-dim    { color: var(--text-dim); }
.t-white  { color: var(--text); }
.t-red    { color: var(--red); }

/* ─── Sections ──────────────────────────────────────────────────── */
.section {
  margin-bottom: 72px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

/* ─── Callout Boxes ─────────────────────────────────────────────── */
.callout {
  border-radius: 6px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.callout-icon { flex-shrink: 0; margin-top: 1px; }

.callout.info {
  background: var(--accent-soft);
  border: 1px solid rgba(59,111,224,0.3);
  color: #2a52b0;
}

.callout.tip {
  background: var(--green-soft);
  border: 1px solid rgba(30,143,82,0.3);
  color: #1a6b40;
}

.callout.warn {
  background: var(--yellow-soft);
  border: 1px solid rgba(154,107,0,0.3);
  color: #7a5500;
}

/* ─── Badge Pills ───────────────────────────────────────────────── */
.badge-row { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 20px;
  padding: 3px 10px;
  letter-spacing: 0.03em;
}

.pill-manual     { background: rgba(154,107,0,0.10);   color: var(--yellow); border: 1px solid rgba(154,107,0,0.25); }
.pill-scantron   { background: rgba(169,126,232,0.12); color: var(--purple); border: 1px solid rgba(169,126,232,0.25); }
.pill-mediavalet { background: rgba(26,127,160,0.10);  color: var(--cyan);   border: 1px solid rgba(26,127,160,0.25); }
.pill-auto       { background: rgba(30,143,82,0.10);   color: var(--green);  border: 1px solid rgba(30,143,82,0.25); }
.pill-required   { background: rgba(192,57,43,0.08);   color: var(--red);    border: 1px solid rgba(192,57,43,0.25); }

/* ─── Command Blocks ────────────────────────────────────────────── */
.cmd-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 20px 0;
  overflow: hidden;
}

.cmd-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.04);
}

.cmd-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--cyan);
}

.cmd-sig {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.cmd-body { padding: 14px 18px; }

.cmd-desc {
  color: var(--text);
  margin-bottom: 12px;
  font-size: 14px;
}

.cmd-ref-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-family: var(--font-sans);
}

.cmd-ref {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 12px 0 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
}

/* ─── Step Cards ────────────────────────────────────────────────── */
.step-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 20px 0;
  overflow: hidden;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.step-number {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59,111,224,0.25);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title-block { flex: 1; }

.step-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.step-body { padding: 16px 20px; }

.step-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.step-desc:last-child { margin-bottom: 0; }

.sub-steps {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.sub-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
  margin-bottom: 0;
}

.sub-steps li:last-child { border-bottom: none; }

.sub-step-bullet {
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 700;
  margin-top: 2px;
  font-size: 13px;
}

/* ─── Flow Grid ─────────────────────────────────────────────────── */
.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.flow-phase {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.flow-phase-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.flow-phase-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.flow-phase-steps {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.8;
}

.flow-step-num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0 5px;
  margin-right: 4px;
}

/* ─── Options / Schema Tables ───────────────────────────────────── */
.opts-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
  font-size: 13.5px;
}

.opts-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 10px 8px 0;
  border-bottom: 1px solid var(--border);
}

.opts-table td {
  padding: 7px 10px 7px 0;
  vertical-align: top;
  border-bottom: 1px solid rgba(221,225,237,0.7);
}

.opts-table tr:last-child td { border-bottom: none; }

.opts-table td:first-child {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--yellow);
  white-space: nowrap;
  padding-right: 20px;
  width: 1%;
}

.opts-table td:nth-child(2) {
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Phase Intro Block ─────────────────────────────────────────── */
.phase-intro {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 28px;
  font-size: 14px;
  color: var(--text-muted);
}

.phase-intro strong { color: var(--text); }

/* ─── Divider ───────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* ─── Font Declarations ─────────────────────────────────────────── */
@font-face {
  font-family: 'Acumin Pro Condensed';
  src: url('fonts/Acumin Pro Condensed.woff') format('woff'),
       url('fonts/Acumin Pro Condensed.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Disco Party';
  src: url('fonts/Disco Party.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'DiscoDiva Base';
  src: url('fonts/DiscoDiva-Base.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'DiscoDiva Inline';
  src: url('fonts/DiscoDiva-Inline.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'DiscoDiva Line';
  src: url('fonts/DiscoDiva-Line.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'DiscoDiva Outline';
  src: url('fonts/DiscoDiva-Outline.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'DiscoDiva Sketch';
  src: url('fonts/DiscoDiva-Sketch.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Groovy Day';
  src: url('fonts/GroovyDay.woff') format('woff'),
       url('fonts/GroovyDay.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'KC Close Encounter Bold';
  src: url('fonts/KCCLOSEENCOUNTER-BOLD.OTF') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'KC Close Encounter Inked';
  src: url('fonts/KCCLOSEENCOUNTER-INKED.OTF') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'KCRagsak';
  src: url('fonts/KCRagsak.otf') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'Magic Night';
  src: url('fonts/Magic Night.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Mexcellent 3D';
  src: url('fonts/Mexcellent 3d.otf') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'Mexcellent';
  src: url('fonts/Mexcellent Rg.otf') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'Moonlight';
  src: url('fonts/Moonlight.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Roboto Condensed';
  src: url('fonts/RobotoCondensed-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
}
@font-face {
  font-family: 'Roboto Condensed';
  src: url('fonts/RobotoCondensed-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
}

/* ─── Font Sample Cards ──────────────────────────────────────────── */
.font-sample {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0;
  overflow: hidden;
}

.font-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.font-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.font-file {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.font-display {
  font-size: 52px;
  line-height: 1.15;
  color: var(--text);
  padding: 20px 24px 8px;
}

.font-body-sample {
  font-size: 18px;
  color: var(--text-muted);
  padding: 0 24px 20px;
  line-height: 1.4;
}

.font-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 32px 0 8px;
}

.font-group-label:first-child { margin-top: 0; }

/* ─── Font Grid ──────────────────────────────────────────────────── */
.font-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}

.font-grid .font-sample { margin: 0; }

/* ─── Color Swatch Cards ─────────────────────────────────────────── */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.color-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.color-swatch {
  height: 90px;
  width: 100%;
}

.color-info {
  padding: 10px 12px 12px;
}

.color-hex {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.color-field {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 2px;
}

.color-value {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  min-height: 20px;
}

.color-value.empty {
  color: var(--text-dim);
  font-style: italic;
}

/* ─── Contrast Table ────────────────────────────────────────────── */
.contrast-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

.contrast-table thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 0 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.contrast-table thead th:first-child { text-align: left; }

.contrast-table td {
  padding: 18px 12px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(0,0,0,0.12);
}

.contrast-table tr:last-child td { border-bottom: none; }

.contrast-color-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 5px;
  opacity: 0.65;
}

/* ─── Page Example Frame ────────────────────────────────────────── */
.page-example-frame {
  display: block;
  width: 100%;
  border: none;
  margin-top: 24px;
}

/* ─── Definition Links ──────────────────────────────────────────── */
.def {
  cursor: pointer;
  border-bottom: 1px dashed var(--accent);
  color: inherit;
}

.def::after {
  content: '?';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59,111,224,0.3);
  border-radius: 50%;
  margin-left: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* ─── Definition Modal ──────────────────────────────────────────── */
#def-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

#def-overlay.open { display: flex; }

#def-modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(480px, calc(100vw - 48px));
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

#def-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

#def-modal-term {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

#def-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  padding: 0 2px;
}

#def-modal-close:hover { color: var(--text); }

#def-modal-body {
  padding: 20px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #nav { display: none; }
  #content { margin-left: 0; padding: 24px; }
  .flow-grid { grid-template-columns: 1fr 1fr; }
  .font-grid { grid-template-columns: repeat(2, 1fr); }
  .color-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .flow-grid { grid-template-columns: 1fr; }
  .font-grid { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: repeat(2, 1fr); }
}
