/* ==========================================================================
   Heroes' Vow: Three Kingdoms Guide — Shared Stylesheet
   Version: 1.0.1 (2026-09-28)
   Standard: SOP / 00B v2.26 Visual Contract
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Color Palette — Han Scholar Dark Theme */
  --bg-base: #0b0f15;
  --bg-surface: #121822;
  --bg-surface-elevated: #18212e;
  --bg-surface-card: #141c27;
  --bg-surface-highlight: #1e2a3b;
  --bg-accent-crimson: rgba(192, 57, 43, 0.12);
  --bg-accent-gold: rgba(223, 172, 66, 0.1);
  --bg-accent-jade: rgba(22, 160, 133, 0.1);

  /* Border Colors */
  --border-subtle: #222d3e;
  --border-medium: #2e3e54;
  --border-gold: #dfac42;
  --border-gold-subtle: rgba(223, 172, 66, 0.35);
  --border-jade: rgba(45, 179, 151, 0.4);

  /* Typography Colors */
  --text-primary: #f2f5f9;
  --text-secondary: #cdd7e3;
  --text-muted: #8b9bb0;
  --text-inverse: #0b0f15;

  /* Accent Colors */
  --gold-primary: #dfac42;
  --gold-light: #f5cf70;
  --gold-hover: #fae196;
  --jade-primary: #2db397;
  --jade-light: #48c9b0;
  --crimson-accent: #c0392b;

  /* Typography Stacks */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Cinzel", "Palatino Linotype", "Book Antiqua", Palatino, "Songti SC", serif;

  /* Sizing and Layout Constraints */
  --site-max-width: 1120px;
  --reading-max-width: 68ch;
  --wide-max-width: 980px;
  --header-height: 72px;

  /* Spacing Scale */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* --------------------------------------------------------------------------
   2. Reset & Base Styles
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-base);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Accessible focus styling */
:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   3. Typography & Headings
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 0;
  letter-spacing: -0.015em;
}

h1 {
  font-size: clamp(1.85rem, 4vw + 0.5rem, 2.75rem);
  font-weight: 800;
  margin-bottom: var(--space-md);
  color: #ffffff;
}

h2 {
  font-size: clamp(1.4rem, 2.5vw + 0.3rem, 1.95rem);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

h2::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 48px;
  height: 2px;
  background: var(--gold-primary);
}

h3 {
  font-size: clamp(1.15rem, 1.8vw + 0.2rem, 1.45rem);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
  color: var(--gold-light);
}

p {
  margin-top: 0;
  margin-bottom: var(--space-md);
  max-width: var(--reading-max-width);
}

ul, ol {
  margin-top: 0;
  margin-bottom: var(--space-lg);
  padding-left: var(--space-lg);
  max-width: var(--reading-max-width);
}

li {
  margin-bottom: var(--space-xs);
}

li::marker {
  color: var(--gold-primary);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* In-text Links */
a {
  color: var(--gold-primary);
  text-decoration: underline;
  text-underline-offset: 0.25em;
  text-decoration-thickness: 1px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
  color: var(--gold-hover);
  text-decoration-thickness: 2px;
}

/* External Link Component (00B §4B.1 compliant) */
.external-link {
  display: inline;
  color: var(--gold-primary);
  text-decoration: underline;
  text-underline-offset: 0.25em;
  font-weight: 500;
}

.external-link::after {
  content: " ↗";
  font-size: 0.85em;
  font-weight: 700;
  display: inline-block;
  vertical-align: baseline;
}

.external-link:hover {
  color: var(--gold-hover);
}

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

/* --------------------------------------------------------------------------
   4. Site Shell (Header, Navigation, Footer)
   -------------------------------------------------------------------------- */
.site-header {
  background-color: rgba(18, 24, 34, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.header-container {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 0.75rem var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--text-primary);
}

.brand-link:hover {
  text-decoration: none;
}

.brand-logo-img {
  height: 48px;
  width: auto;
  display: block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: var(--space-xs) 0;
  position: relative;
  transition: color var(--transition-fast);
}

.nav-link:hover {
  color: var(--gold-primary);
  text-decoration: none;
}

.nav-link.active {
  color: var(--gold-primary);
  font-weight: 600;
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--gold-primary);
}

/* Mobile Nav Toggle Button */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
}

.nav-toggle:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--gold-primary);
}

/* --------------------------------------------------------------------------
   5. Main Content Containers & Layout
   -------------------------------------------------------------------------- */
.site-main {
  flex: 1 0 auto;
  width: 100%;
}

.content-container {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md) var(--space-3xl);
}

/* Article Container — Constrained reading column */
.article-container {
  max-width: var(--wide-max-width);
  margin: 0 auto;
}

.article-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.article-identity {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gold-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-xs);
}

.article-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.meta-badge {
  background-color: var(--bg-surface-highlight);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
}

.meta-badge.badge-gold {
  border-color: var(--border-gold-subtle);
  color: var(--gold-light);
  background-color: var(--bg-accent-gold);
}

.meta-badge.badge-jade {
  border-color: var(--border-jade);
  color: var(--jade-light);
  background-color: var(--bg-accent-jade);
}

/* Breadcrumb Navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--gold-primary);
  text-decoration: underline;
}

.breadcrumb-separator {
  color: var(--border-medium);
}

.breadcrumb-current {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   6. Content Components (Callouts, Cards, Sections)
   -------------------------------------------------------------------------- */
.lead-paragraph {
  font-size: 1.1875rem;
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
  font-weight: 400;
}

.callout-box {
  background-color: var(--bg-surface);
  border-left: 4px solid var(--gold-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  max-width: var(--reading-max-width);
}

.callout-box.callout-jade {
  border-left-color: var(--jade-primary);
  background-color: rgba(22, 160, 133, 0.07);
}

.callout-box.callout-crimson {
  border-left-color: var(--crimson-accent);
  background-color: rgba(192, 57, 43, 0.08);
}

.callout-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Quick Answer Summary Card */
.direct-answer-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-gold-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.direct-answer-card h2 {
  font-size: 1.25rem;
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
  color: var(--gold-light);
}

.direct-answer-card h2::after {
  display: none;
}

/* Action Banner / Guide Promotion Card */
.action-card {
  background: linear-gradient(135deg, var(--bg-surface-elevated) 0%, #151f2b 100%);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.action-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.action-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--gold-primary);
  color: #0b0f15;
  border-color: var(--gold-primary);
}

.btn-primary:hover {
  background-color: var(--gold-hover);
  border-color: var(--gold-hover);
  color: #000000;
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--bg-surface-highlight);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--gold-primary);
  color: var(--gold-light);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   7. Tables & Responsive Scroll Containers (00B compliant)
   -------------------------------------------------------------------------- */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-lg) 0 var(--space-xl);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  text-align: left;
}

.data-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--gold-light);
  font-weight: 600;
  padding: 0.85rem var(--space-md);
  border-bottom: 2px solid var(--border-medium);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  color: var(--text-secondary);
}

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

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table td strong {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   8. Media, Figures & Figcaptions (00B §4A compliant)
   -------------------------------------------------------------------------- */
.article-figure {
  margin: var(--space-xl) 0;
  padding: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.article-figure picture,
.article-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: cover;
}

.article-figure figcaption {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.85rem;
  color: var(--text-muted);
  background-color: var(--bg-surface-card);
  border-top: 1px solid var(--border-subtle);
  line-height: 1.5;
}

.article-figure figcaption em {
  font-style: italic;
}

/* --------------------------------------------------------------------------
   9. Site Footer & Attribution
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: #090d13;
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-2xl) var(--space-md) var(--space-xl);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-container {
  max-width: var(--site-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xl);
}

.footer-brand {
  max-width: 440px;
}

.footer-brand p {
  font-size: 0.875rem;
  line-height: 1.6;
  margin-top: var(--space-xs);
  color: var(--text-muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xl);
}

.footer-nav-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.footer-nav-heading {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  font-weight: 700;
  margin-bottom: var(--space-2xs);
}

.footer-nav-col a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition-fast);
}

.footer-nav-col a:hover {
  color: var(--gold-primary);
  text-decoration: underline;
}

.footer-bottom {
  padding-top: var(--space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8125rem;
}

.footer-meta-line {
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   10. Responsive Breakpoints & Mobile Optimization
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: column;
    padding: var(--space-md);
    gap: var(--space-md);
    box-shadow: var(--shadow-lg);
  }

  .site-nav.is-open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .content-container {
    padding-top: var(--space-lg);
    padding-bottom: var(--space-2xl);
  }

  .action-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-top {
    flex-direction: column;
    gap: var(--space-lg);
  }

  .data-table th,
  .data-table td {
    padding: 0.75rem var(--space-sm);
  }
}

/* Codex 1.0.1: anchor visibility and existing component accessibility. */
.article-container section[id], .article-container h3[id] { scroll-margin-top: calc(var(--header-height) + 1rem); }
.breadcrumb { flex-wrap: wrap; }
.table-scroll:focus-visible { outline: 2px solid var(--gold-primary); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
