/* ==========================================================================
   LOCAL//CORE - Architecture & Design System Stylesheet
   Self-contained, zero-remote-dependency responsive layout
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  /* Theme: Dark (Default) */
  --bg-canvas: #090d14;
  --bg-surface: #111726;
  --bg-card: #151d30;
  --bg-elevated: #1c263e;
  --bg-tag: rgba(56, 189, 248, 0.12);

  --border-strong: #2a3754;
  --border-medium: #1f2b42;
  --border-subtle: #162033;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;

  --accent-cyan: #38bdf8;
  --accent-emerald: #34d399;
  --accent-amber: #fbbf24;
  --accent-rose: #f43f5e;
  --accent-indigo: #818cf8;

  --glow-cyan: rgba(56, 189, 248, 0.25);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);

  --header-height: 72px;
  --container-max: 1200px;
}

[data-theme="light"] {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --bg-tag: rgba(14, 165, 233, 0.12);

  --border-strong: #cbd5e1;
  --border-medium: #e2e8f0;
  --border-subtle: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-accent: #0284c7;

  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-indigo: #6366f1;

  --glow-cyan: rgba(2, 132, 199, 0.15);
  --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

a:hover {
  text-decoration: underline;
}

img, svg {
  vertical-align: middle;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1.5rem;
  background: var(--accent-cyan);
  color: #000000;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  border-radius: 4px;
  z-index: 9999;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
}

/* Reading Progress Indicator */
@keyframes progress-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-emerald));
  z-index: 1100;
  transform-origin: 0 50%;
  animation: progress-grow auto linear;
  animation-timeline: scroll();
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Site Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(9, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-medium);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

[data-theme="light"] .site-header {
  background-color: rgba(248, 250, 252, 0.88);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

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

.brand-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-emerald);
  padding: 0.15rem 0.45rem;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 4px;
  margin-left: 0.25rem;
  font-weight: 500;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.925rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

.nav-link[aria-current="page"],
.nav-link.active {
  color: var(--accent-cyan);
  background-color: var(--bg-surface);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* Main Content */
main {
  flex: 1;
  padding-bottom: 5rem;
}

/* Hero Section */
.hero {
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.75rem;
  background: var(--bg-tag);
  border: 1px solid var(--border-medium);
  border-radius: 9999px;
  color: var(--accent-cyan);
  margin-bottom: 1.5rem;
}

.hero-pill-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

.hero-title {
  font-size: clamp(2.2rem, 5vw, 3.75rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.035em;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.hero-title .gradient-text {
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 820px;
  line-height: 1.65;
  margin-bottom: 2.25rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Button UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent-cyan);
  color: #06090e;
  border-color: var(--accent-cyan);
}

.btn-primary:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

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

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

/* Section Header */
.section-header {
  margin: 4rem 0 2rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-emerald);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.section-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 720px;
}

/* Cards & Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 1.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.card-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

.card-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  flex: 1;
}

.card-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Callout Box */
.callout {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-left: 4px solid var(--accent-cyan);
  border-radius: 0 8px 8px 0;
  padding: 1.5rem;
  margin: 2rem 0;
}

.callout-warning {
  border-left-color: var(--accent-amber);
}

.callout-success {
  border-left-color: var(--accent-emerald);
}

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

.callout p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

/* Comparison Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  background: var(--bg-surface);
}

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

th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}

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

tr:hover td {
  background: var(--bg-card);
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  color: var(--accent-cyan);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Architecture Flow Diagrams (Pure CSS/HTML) */
.diagram-canvas {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 2rem;
  margin: 2.5rem 0;
}

.diagram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.diagram-caption {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.diagram-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.diagram-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  position: relative;
}

.flow-step {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 1.25rem;
  position: relative;
}

.flow-step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-emerald);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.flow-step-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.flow-step-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Technical Specification List */
.spec-list {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.spec-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.spec-bullet {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: bold;
}

/* Diagnostic / 404 View */
.diagnostic-container {
  padding: 4rem 0;
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
}

.diagnostic-code {
  font-family: var(--font-mono);
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 900;
  line-height: 1;
  color: var(--accent-rose);
  letter-spacing: -0.05em;
  margin-bottom: 1rem;
  text-shadow: 0 0 40px rgba(244, 63, 94, 0.2);
}

.diagnostic-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 1.75rem;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 2rem 0;
}

.diagnostic-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border-subtle);
  color: var(--text-secondary);
}

.diagnostic-row:last-child {
  border-bottom: none;
}

.diagnostic-row .key {
  color: var(--text-muted);
}

.diagnostic-row .val {
  color: var(--accent-cyan);
}

.diagnostic-row .val-err {
  color: var(--accent-rose);
}

/* Site Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-medium);
  padding: 3.5rem 0 2.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.footer-brand-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 380px;
  line-height: 1.6;
}

.footer-col-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent-cyan);
}

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  color: var(--accent-emerald);
}

/* Responsive Media Queries */
@media (max-width: 900px) {
  .diagram-flow {
    grid-template-columns: 1fr 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

@media (max-width: 680px) {
  :root {
    --header-height: auto;
  }
  .header-inner {
    flex-direction: column;
    padding: 1rem 0;
    align-items: stretch;
  }
  .site-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  .header-actions {
    justify-content: center;
  }
  .diagram-flow {
    grid-template-columns: 1fr;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}