/* ==========================================================================
   8.6a. Design Tokens (Theming Engine)
   ========================================================================== */
:root {
  --bg: #060810;
  --surface: #0e1420;
  --surface-raised: #141c2e;
  --border: #2e3d55;
  --text: #dce6f5;
  --muted: #6e87a8;
  --faint: #8fa3c0;
  --accent: #4f8ef7;
  --accent-soft: rgba(79, 142, 247, 0.16);

  --color-success: #91f0c0;
  --bg-success-soft: rgba(145, 240, 192, 0.08);
  --color-warning: #ffbe5c;
  --bg-warning-soft: rgba(255, 190, 92, 0.08);

  --max-width: 1180px;
  --radius: 24px;
  --radius-sm: 14px;

  --space-sm: 0.85rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 4rem;
  --space-xxl: 6rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-raised: #eaeef6;
    --border: #cbd5e1;
    --text: #0f172a;
    --muted: #475569;
    --faint: #64748b;
    --accent: #1e6091;
    --accent-soft: rgba(30, 96, 145, 0.1);
  }
}

/* ==========================================================================
   8.6b. Global Reset & Base Utilities
   ========================================================================== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }
main { width: min(100% - 2rem, var(--max-width)); margin: 0 auto; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; height: auto; display: block; }
button, input { font: inherit; color: inherit; background: transparent; border: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.d-flex { display: flex; }
.fd-column { flex-direction: column; }
.ai-center { align-items: center; }
.jc-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* ==========================================================================
   8.6c. Typography System
   ========================================================================== */
h1 { font-size: clamp(2.6rem, 7vw, 5.8rem); line-height: 0.95; letter-spacing: -0.07em; margin: 0; }
h2 { font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.05; letter-spacing: -0.04em; margin: 0; }
h3 { font-size: 1.15rem; line-height: 1.2; margin: 0; }
p { color: var(--muted); max-width: 68ch; margin: 0; }
.eyebrow { color: var(--accent); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; }
.hero-copy { max-width: 660px; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.3rem); }

/* ==========================================================================
   8.6d. Layout Elements & Structure
   ========================================================================== */
.site-header { position: sticky; top: 0; z-index: 50; padding: 1rem 2rem; background: rgba(6, 8, 16, 0.86); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.logo { font-weight: 700; letter-spacing: -0.03em; }
.main-nav { display: flex; gap: 1rem; color: var(--muted); }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); }
.header-cta { padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: 999px; background: var(--accent-soft); }
.nav-toggle { display: none; cursor: pointer; padding: 0.5rem; }

.content-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(280px, 3fr); gap: var(--space-lg); align-items: start; margin-bottom: var(--space-xl); }
.main-panel, .side-panel, .card, .validation-block, .feedback, .form-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--space-lg); }
.side-panel { position: sticky; top: 6rem; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md); margin-bottom: var(--space-xl); }
.page-hero { padding: var(--space-xxl) 0 var(--space-xl); max-width: 820px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-lg); }

/* ==========================================================================
   8.6e. Interactive Components & Forms
   ========================================================================== */
.chapter-pills { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: var(--space-lg); }
.pill { padding: 0.55rem 0.9rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: rgba(255, 255, 255, 0.02); }
.pill.active, .pill:hover { color: var(--text); background: var(--accent-soft); border-color: rgba(79, 142, 247, 0.5); }

.tabs { display: flex; gap: 0.5rem; padding: 0.4rem; width: fit-content; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); margin-bottom: var(--space-xl); }
.tab { border: 0; border-radius: 999px; padding: 0.65rem 1rem; background: transparent; color: var(--muted); cursor: pointer; }
.tab.active, .tab[aria-selected="true"] { background: var(--surface-raised); color: var(--text); }
.tab-panel[hidden] { display: none !important; }

.card-label { color: var(--accent); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; }
.card h3 { margin-bottom: 0.5rem; }
.card.warning { background: linear-gradient(135deg, var(--surface), var(--bg-warning-soft)); }

.status-strip { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: var(--space-md); }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0.35rem 0.65rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; background: rgba(255, 255, 255, 0.03); }

.form-panel { display: grid; gap: var(--space-md); }
.form-field { display: grid; gap: 0.35rem; }
label { color: var(--text); font-weight: 600; }
input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.03); color: var(--text); padding: 0.8rem 0.9rem; }
input:focus { border-color: var(--accent); outline: none; }
.helper-text { color: var(--muted); font-size: 0.9rem; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.7rem 1rem; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; line-height: 1; transition: opacity 0.2s ease, transform 0.1s ease; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #06101f; border-color: var(--accent); }
.btn-secondary { background: var(--accent-soft); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.feedback { margin-bottom: var(--space-md); }
.feedback-success { background: linear-gradient(135deg, var(--surface), var(--bg-success-soft)); }
.validation-block { margin: var(--space-xl) 0; background: linear-gradient(135deg, var(--surface), var(--accent-soft)); }
.checklist { padding-left: 1.2rem; color: var(--muted); }
.checklist li { margin-bottom: 0.5rem; }

/* Pricing page ribbon marker for featured tier */
.ribbon-marker {
  position: absolute;
  top: 0;
  right: var(--space-md);
  transform: translateY(-50%);
  background: var(--accent);
  color: var(--background);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  z-index: 1;
}

.pricing-tier {
  position: relative;
}

.site-footer { margin-top: var(--space-xxl); padding: var(--space-xl) 2rem; border-top: 1px solid var(--border); color: var(--muted); }
.site-footer nav { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ==========================================================================
   8.6f. Accessibility Core Utilities
   ========================================================================== */
.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 100; padding: 0.75rem 1rem; background: var(--accent); color: #06101f; border-radius: var(--radius-sm); transition: top 0.2s ease; }
.skip-link:focus { top: 1rem; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ==========================================================================
   8.6g. Responsive Breakdown Adaptability
   ========================================================================== */
@media (max-width: 820px) {
  .site-header { flex-direction: row; flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .main-nav { display: none; width: 100%; flex-direction: column; padding: var(--space-md) 0; order: 3; }
  .main-nav.is-active { display: flex; }
  .content-grid, .card-grid { grid-template-columns: 1fr; }
  .side-panel { position: static; }
  .tabs { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .site-footer { flex-direction: column; }
}

@media (max-width: 540px) {
  main { width: min(100% - 1rem, var(--max-width)); }
  .page-hero { padding: var(--space-xl) 0; }
  .site-header { padding: 1rem; }
  .main-panel, .side-panel, .card, .validation-block, .feedback, .form-panel { padding: var(--space-md); border-radius: var(--radius-sm); }
  .chapter-pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.5rem; -webkit-overflow-scrolling: touch; }
  .pill { flex: 0 0 auto; }
}

/* ==========================================================================
   CSS Additions — Ch15 Supplement
   Required by all HTML templates; not in base stylesheet.
   ========================================================================== */

/* 1. Content width constraint — used by all page layouts */
.container {
  width: min(100% - 2rem, var(--max-width));
  margin: 0 auto;
}

/* 2. Pricing ribbon — "Most Popular" badge */
.ribbon-marker {
  position: absolute;
  top: 0;
  right: var(--space-md);
  transform: translateY(-50%);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  z-index: 1;
}

.pricing-tier {
  position: relative;
}

/* 3. Contact page 50/50 split */
.split-focus-layout {
  grid-template-columns: 1fr 1fr !important;
}

@media (max-width: 768px) {
  .split-focus-layout {
    grid-template-columns: 1fr !important;
  }
}

/* 4. Product page alternating reverse layout */
.alternating-reverse .content-grid {
  direction: rtl;
}

.alternating-reverse .content-grid > * {
  direction: ltr;
}

@media (max-width: 768px) {
  .alternating-reverse .content-grid {
    direction: ltr;
  }
}
