/* ================================================================
   Ambrosoft Lab Theme — Core Stylesheet
   Independent software laboratory aesthetic
   Amber-on-charcoal signal accents, off-white reading surfaces
   ================================================================ */

/* ----- Custom Properties ----- */
:root {
  --bg-deep: #1a1a1e;
  --bg-frame: #222226;
  --bg-surface: #f5f0e8;
  --bg-surface-alt: #ece6da;
  --bg-code: #2a2a30;

  --text-primary: #2c2a26;
  --text-secondary: #5a5750;
  --text-muted: #8a8680;
  --text-on-dark: #85817b;
  --text-on-dark-muted: #8a857c;

  --accent-amber: #d4922a;
  --accent-copper: #b87840;
  --accent-signal: #e8a030;
  --accent-teal: #4a7a80;
  --accent-slate: #5a7088;

  --border-light: #d8d2c6;
  --border-dark: #3a3a40;
  --border-rule: #c8c2b6;

  --font-heading: "Source Serif 4", "Georgia", serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;

  --max-content: 860px;
  --max-wide: 1200px;
  --nav-height: 60px;
  --radius: 4px;
  --radius-lg: 8px;
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent-amber);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-signal); }
a:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: 2.2rem; margin-bottom: 0.6em; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin-top: 2em; margin-bottom: 0.5em; }
h3 { font-size: 1.25rem; margin-top: 1.6em; margin-bottom: 0.4em; }
h4 { font-size: 1.1rem; margin-top: 1.4em; margin-bottom: 0.4em; }

p { margin-bottom: 1.1em; }

blockquote {
  border-left: 3px solid var(--accent-amber);
  padding: 0.8em 1.2em;
  margin: 1.4em 0;
  background: var(--bg-surface-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text-secondary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-surface-alt);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--accent-copper);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 1.2em 1.4em;
  overflow-x: auto;
  margin: 1.4em 0;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text-on-dark);
  font-size: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.95rem;
}

th, td {
  padding: 0.6em 0.9em;
  border: 1px solid var(--border-light);
  text-align: left;
}

th {
  background: var(--bg-surface-alt);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

hr {
  border: none;
  border-top: 1px solid var(--border-rule);
  margin: 2em 0;
}

ul, ol { margin: 0.6em 0 1.2em 1.4em; }
li { margin-bottom: 0.35em; }

/* ----- Site Header / Nav ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-frame);
  border-bottom: 1px solid var(--border-dark);
  height: var(--nav-height);
}

.site-header-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 2rem;
}

.site-wordmark {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent-amber);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.site-wordmark:hover { color: var(--accent-signal); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-on-dark-muted);
  text-decoration: none;
  padding: 0.4em 0.7em;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.site-nav a:hover,
.site-nav a.active {
  color: var(--accent-amber);
  background: rgba(212, 146, 42, 0.08);
}

.nav-search-trigger {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border-dark);
  color: var(--text-on-dark-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.35em 0.8em;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4em;
  transition: border-color 0.15s, color 0.15s;
}
.nav-search-trigger:hover {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}
.nav-search-trigger svg {
  width: 14px;
  height: 14px;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-on-dark);
  cursor: pointer;
  padding: 0.4em;
}

/* ----- Search Overlay ----- */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 26, 30, 0.92);
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}
.search-overlay.active {
  display: flex;
}
.search-container {
  width: 90%;
  max-width: 640px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.search-container input[type="text"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.1rem;
  padding: 0.7em 1em;
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-primary);
  outline: none;
}
.search-container input[type="text"]:focus {
  border-color: var(--accent-amber);
}
.search-results-area {
  margin-top: 1rem;
  max-height: 50vh;
  overflow-y: auto;
}

/* ----- Page Frame ----- */
.page-frame {
  flex: 1;
  max-width: var(--max-wide);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ----- Content Surface ----- */
.content-surface {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  max-width: var(--max-content);
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.content-wide {
  max-width: var(--max-wide);
}

/* ----- Hero / Page Header ----- */
.page-hero {
  margin-bottom: 2rem;
}

.page-hero-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.page-dek {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.8em;
}

.page-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 1.5em;
  flex-wrap: wrap;
  margin-bottom: 1.5em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--border-rule);
}

/* ----- Table of Contents ----- */
.toc-wrapper {
  float: right;
  width: 240px;
  margin: 0 0 1.5em 2em;
  padding: 1em 1.2em;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.toc-wrapper .toc-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6em;
}

.toc-wrapper nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-wrapper nav li { margin-bottom: 0.3em; }
.toc-wrapper nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.83rem;
}
.toc-wrapper nav a:hover { color: var(--accent-amber); }
.toc-wrapper nav ul ul { padding-left: 0.8em; }

/* ----- Callout Boxes ----- */
.callout {
  padding: 1em 1.2em;
  margin: 1.4em 0;
  border-radius: var(--radius);
  border-left: 4px solid;
  font-size: 0.95rem;
}
.callout-note {
  background: #eef2f5;
  border-color: var(--accent-slate);
}
.callout-warning {
  background: #fdf6ec;
  border-color: var(--accent-amber);
}
.callout-pitfall {
  background: #fceef0;
  border-color: #c04040;
}
.callout-benchmark {
  background: #edf5f5;
  border-color: var(--accent-teal);
}
.callout .callout-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 0.4em;
  display: block;
}

/* ----- Related Reading Box ----- */
.related-reading {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.2em 1.4em;
  margin: 2em 0;
}
.related-reading h4 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 0.6em;
}
.related-reading ul { margin: 0; padding-left: 1.2em; }
.related-reading li { margin-bottom: 0.3em; font-size: 0.92rem; }

/* ----- FAQ Section ----- */
.faq-section details {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 0.5em;
  background: var(--bg-surface);
}
.faq-section summary {
  padding: 0.7em 1em;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style-position: outside;
}
.faq-section details[open] summary {
  border-bottom: 1px solid var(--border-light);
}
.faq-section details > div,
.faq-section details > p {
  padding: 0.8em 1em;
  font-size: 0.93rem;
}

/* ----- Home Page Modules ----- */
.home-hero {
  text-align: center;
  padding: 3rem 1.5rem;
}

.home-hero h1 {
  font-size: 2.6rem;
  color: var(--text-on-dark);
  margin-bottom: 0.4em;
}

.home-hero .hero-tagline {
  font-size: 1.2rem;
  color: var(--text-on-dark-muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.65;
}

.home-hero-image {
  width: 100%;
  max-width: 900px;
  margin: 2rem auto 0;
  border-radius: var(--radius-lg);
  height: 360px;
  object-fit: cover;
}

/* Topic cards */
.topic-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.topic-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 1.5em;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
}
.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  border-color: var(--accent-amber);
}
.topic-card h3 {
  font-size: 1.05rem;
  margin: 0 0 0.4em;
  color: var(--text-primary);
}
.topic-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.55;
}
.topic-card .card-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
  margin-bottom: 0.5em;
  display: block;
}

/* Notable pages strip */
.notable-strip {
  background: var(--bg-frame);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 1.5em 2em;
  margin: 2rem 0;
}
.notable-strip h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
  margin: 0 0 1em;
}
.notable-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
}
.notable-links a {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-on-dark);
  background: rgba(212, 146, 42, 0.08);
  border: 1px solid var(--border-dark);
  padding: 0.4em 0.9em;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.notable-links a:hover {
  background: rgba(212, 146, 42, 0.15);
  border-color: var(--accent-amber);
}

/* Field Notes section */
.field-notes {
  margin: 2rem 0;
}
.field-notes h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-muted);
  margin-bottom: 1em;
}
.field-note-item {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  margin-bottom: 0.6em;
  display: block;
  text-decoration: none;
  transition: transform 0.1s;
}
.field-note-item:hover { transform: translateX(4px); }
.field-note-item h3 {
  font-size: 1rem;
  margin: 0 0 0.2em;
  color: var(--text-primary);
}
.field-note-item .note-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Benchmark panel */
.bench-panel {
  background: var(--bg-frame);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 1.5em 2em;
  margin: 2rem 0;
}
.bench-panel h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-teal);
  margin: 0 0 1em;
}
.bench-rows { display: flex; flex-direction: column; gap: 0.5em; }
.bench-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border-dark);
  font-size: 0.88rem;
}
.bench-row:last-child { border-bottom: none; }
.bench-row .bench-label {
  font-family: var(--font-mono);
  color: var(--text-on-dark);
  font-size: 0.82rem;
}
.bench-row .bench-value {
  font-family: var(--font-mono);
  color: var(--accent-amber);
  font-weight: 600;
  font-size: 0.85rem;
}

/* Timeline / changelog preview */
.changelog-preview {
  margin: 2rem 0;
}
.changelog-preview h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-muted);
  margin-bottom: 1em;
}
.timeline-item {
  position: relative;
  padding-left: 1.6em;
  margin-bottom: 1em;
  font-size: 0.9rem;
  color: var(--text-on-dark);
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-amber);
}
.timeline-item .tl-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-on-dark-muted);
  display: block;
  margin-bottom: 0.1em;
}

/* ----- Section List ----- */
.section-list {
  list-style: none;
  padding: 0;
  margin: 1.5em 0;
}
.section-list li {
  padding: 1em 0;
  border-bottom: 1px solid var(--border-rule);
}
.section-list li:last-child { border-bottom: none; }
.section-list a {
  text-decoration: none;
  display: block;
}
.section-list a:hover h3 { color: var(--accent-amber); }
.section-list h3 {
  font-size: 1.1rem;
  margin: 0 0 0.2em;
  transition: color 0.15s;
}
.section-list .list-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}
.section-list .list-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ----- Downloads Grid ----- */
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5em 0;
}
.download-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.2em 1.4em;
}
.download-card h3 { font-size: 1rem; margin: 0 0 0.3em; }
.download-card p { font-size: 0.88rem; color: var(--text-secondary); margin: 0 0 0.8em; }
.download-card .dl-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ----- Data Tables ----- */
.data-table-wrapper {
  overflow-x: auto;
  margin: 1.4em 0;
}
.data-table {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* ----- Figure Captions ----- */
figure {
  margin: 1.5em 0;
}
figcaption {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5em;
  padding-left: 0.5em;
  border-left: 2px solid var(--accent-amber);
}

/* ----- Footer ----- */
.site-footer {
  background: var(--bg-frame);
  border-top: 1px solid var(--border-dark);
  padding: 2rem 1.5rem;
  margin-top: auto;
}
.site-footer-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1em;
}
.footer-nav {
  display: flex;
  gap: 1.5em;
}
.footer-nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-on-dark-muted);
  text-decoration: none;
}
.footer-nav a:hover { color: var(--accent-amber); }

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-on-dark-muted);
}

/* ----- Pagefind Integration ----- */
.pagefind-ui {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--accent-amber);
  --pagefind-ui-text: var(--text-primary);
  --pagefind-ui-background: var(--bg-surface);
  --pagefind-ui-border: var(--border-light);
  --pagefind-ui-tag: var(--bg-surface-alt);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: var(--radius);
  --pagefind-ui-font: var(--font-body);
}

/* ----- Utility ----- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ----- Dark text on dark bg contexts ----- */
.dark-ctx h1, .dark-ctx h2, .dark-ctx h3,
.dark-ctx h4, .dark-ctx h5, .dark-ctx h6 {
  color: var(--text-on-dark);
}
.dark-ctx p, .dark-ctx li {
  color: var(--text-on-dark);
}
.dark-ctx a { color: var(--accent-amber); }

/* ----- Responsive ----- */
@media (max-width: 768px) {
  :root { --nav-height: 52px; }

  .site-nav { display: none; }
  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-frame);
    border-bottom: 1px solid var(--border-dark);
    padding: 1em;
    gap: 0.3em;
  }

  .nav-toggle { display: block; margin-left: auto; }
  .nav-search-trigger { margin-left: 0; }

  .content-surface { padding: 1.5rem 1.2rem; }
  .home-hero h1 { font-size: 1.8rem; }
  .home-hero-image { height: 200px; }
  .topic-cards { grid-template-columns: 1fr; }
  .toc-wrapper {
    float: none;
    width: 100%;
    margin: 0 0 1.5em 0;
  }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .notable-links { flex-direction: column; }
  .site-footer-inner { flex-direction: column; text-align: center; }
  .footer-nav { flex-wrap: wrap; justify-content: center; }
}
