/* =========================================================================
   AI Developer Revision Guide — stylesheet
   Documentation-style layout (think MDN / Microsoft Learn): no cards, no
   grids, no motion. Generous whitespace, readable type, a simple divider
   between topics. CSS custom properties are used throughout so that future
   features (dark mode, alternate themes) only require swapping variables.
   ========================================================================= */

:root {
  /* -- color tokens (swap these for a future dark-mode theme) -- */
  --color-bg: #ffffff;
  --color-bg-subtle: #f6f8fa;
  --color-text: #1a202c;
  --color-text-muted: #57606a;
  --color-heading: #0f1b33;
  --color-accent: #2b6cb0;
  --color-accent-dark: #1e4e7d;
  --color-border: #d8dee4;
  --color-tag-bg: #eef3fb;
  --color-tag-text: #2b6cb0;
  --color-code-bg: #0f1b33;
  --color-code-text: #e3e8f0;

  /* -- toolbar tokens -- */
  --toolbar-bg-from: #eef2f9;
  --toolbar-bg-to: #e3e8f3;
  --toolbar-border: #c9d2e0;

  /* -- level badge tokens -- */
  --badge-bg: #ece9fb;
  --badge-text: #4c3fae;

  /* -- panel / callout tokens -- */
  --panel-border-accent: #2b6cb0;
  --panel-bg: #f8fafc;
  --deepdive-border-accent: #7c3aed;
  --deepdive-bg: #faf8ff;

  /* -- layout tokens -- */
  --content-max-width: 880px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;

  /* -- typography tokens -- */
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;
  --line-height-body: 1.65;
}

/* ----------------------------- Reset / base ----------------------------- */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: var(--line-height-body);
  font-size: 16px;
}

h1, h2, h3, h4 {
  color: var(--color-heading);
  line-height: 1.3;
}

a {
  color: var(--color-accent);
}

code {
  font-family: var(--font-mono);
  background: var(--color-bg-subtle);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.92em;
}

button {
  font-family: inherit;
}

/* ------------------------------ Page header ------------------------------ */
/* Bold title with a solid accent rule underneath, matching the reference
   "documentation cover page" look rather than a dashboard app bar. */

.page-header {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-3) var(--space-4);
  border-bottom: 4px solid var(--color-accent);
}

.page-title {
  margin: 0 0 var(--space-2) 0;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-heading);
}

.subtitle {
  margin: 0;
  color: var(--color-text-muted);
  max-width: 70ch;
}

/* -------------------------------- Toolbar -------------------------------- */
/* A bordered, softly-shaded control bar -- this is UI chrome, not a topic
   "card", so it's exempt from the no-cards rule that governs topic display. */

.toolbar {
  max-width: var(--content-max-width);
  margin: var(--space-4) auto 0;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(to bottom, var(--toolbar-bg-from), var(--toolbar-bg-to));
  border: 1px solid var(--toolbar-border);
  border-radius: 10px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-end;
}

.toolbar-row--actions {
  justify-content: flex-end;
  margin-top: var(--space-3);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.control-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.control-group input[type="search"],
.control-group select {
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-text);
  min-width: 220px;
}

.control-group input[type="search"]:focus,
.control-group select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.checkbox-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
  color: var(--color-text);
  white-space: nowrap;
  padding-bottom: 0.45rem;
}

.checkbox-control input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
}

.print-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  background: var(--color-accent);
  color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
}

.print-btn:hover {
  background: var(--color-accent-dark);
}

/* ------------------------------- Main area ------------------------------- */

#app-root {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-3) var(--space-6);
}

#loading-message,
.empty-state {
  color: var(--color-text-muted);
}

/* ------------------------------ Topic entries ----------------------------- */
/* Plain documentation-style sections: numbered label, title + level badge,
   short answer, and two inline expand links. No card backgrounds, no
   shadows, no rounded panels around the topic itself. */

.topic-entry {
  padding: var(--space-4) 0;
}

.topic-entry + .topic-entry {
  border-top: 1px solid var(--color-border);
}

.topic-number {
  margin: 0 0 var(--space-1) 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.topic-heading-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.topic-title {
  margin: 0;
  font-size: 1.4rem;
}

.level-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--badge-text);
  background: var(--badge-bg);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.topic-summary {
  margin: 0 0 var(--space-3) 0;
  max-width: 75ch;
}

.topic-keywords {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

/* The link row: plain text buttons with icons, separated by a dashed rule
   beneath them (matches the reference design's underline treatment). */

.topic-links {
  display: flex;
  gap: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--color-border);
}

.link-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.link-toggle:hover {
  color: var(--color-accent-dark);
}

.link-toggle[aria-expanded="true"] {
  color: var(--color-accent-dark);
}

.link-toggle .icon {
  flex-shrink: 0;
}

/* ------------------------------ Expand panels ------------------------------ */
/* Documentation-style callouts: a left accent border, not a floating card. */

.expand-panel {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--panel-border-accent);
  background: var(--panel-bg);
  border-radius: 0 6px 6px 0;
}

.expand-panel.deepdive-panel {
  border-left-color: var(--deepdive-border-accent);
  background: var(--deepdive-bg);
}

.expand-panel p {
  margin: 0 0 var(--space-3) 0;
}

.expand-panel p:last-child {
  margin-bottom: 0;
}

.panel-section {
  margin-top: var(--space-3);
}

.panel-section h3 {
  font-size: 0.95rem;
  margin: 0 0 var(--space-2) 0;
}

.code-block {
  margin: var(--space-2) 0 0 0;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: var(--space-3);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
}

/* Reset the global inline `code` styling (background/padding meant for
   prose like <code>topics.json</code>) so it doesn't fight the <pre> block's
   own background -- otherwise each wrapped line gets its own highlight box. */
.code-block code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.code-caption {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: var(--space-2) 0 0 0;
}

.panel-images {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.panel-images figure {
  margin: 0;
  flex: 1 1 240px;
}

.panel-images img {
  width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  display: block;
}

.panel-images figcaption {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.panel-references {
  margin: 0;
  padding-left: 1.2rem;
}

.panel-references li {
  margin-bottom: var(--space-1);
}

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

.page-footer {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-6);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
}

/* --------------------------------- Utility --------------------------------- */

.hidden {
  display: none !important;
}

/* =========================================================================
   Responsive: collapse the control row to a single column on narrow screens
   ========================================================================= */

@media (max-width: 640px) {
  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group input[type="search"],
  .control-group select {
    min-width: 0;
    width: 100%;
  }

  .toolbar-row--actions {
    justify-content: stretch;
  }

  .print-btn {
    width: 100%;
    justify-content: center;
  }
}

/* =========================================================================
   Print styles: only topic titles and the currently selected experience
   level's summary should appear on paper. Controls, buttons, links and
   expand panels are always excluded.
   ========================================================================= */

@media print {
  .no-print,
  .toolbar,
  .topic-links,
  .expand-panel,
  .topic-keywords {
    display: none !important;
  }

  body {
    font-size: 12pt;
  }

  .page-header {
    border-bottom: none;
    padding: 0 0 var(--space-3) 0;
  }

  #app-root {
    padding: 0;
    max-width: none;
  }

  .topic-entry {
    padding: var(--space-3) 0;
    break-inside: avoid;
  }

  .topic-entry + .topic-entry {
    border-top: 1px solid #999;
  }
}
