/*
  System Design Studio — Bauhaus Neo-Brutalist Edition Design Tokens & Styles
  Typography: Space Grotesk (Headline/Display) + Inter (Body) + SFMono/Menlo (Code)
  Color Palette:
    Surface: Warm Cream Paper (#f5f0e8) / Midnight Dark (#141414)
    Primary: Deep Charcoal / Ink (#1a1a1a) / Warm Linen (#f5f0e8)
    Primary Container: Bauhaus Yellow (#ffcc00)
    Secondary: Bauhaus Cadmium Red (#e63b2e)
    Tertiary: Bauhaus Cobalt Blue (#0055ff)
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

:root {
  --surface-bright: #faf7f2;
  --surface: #f5f0e8;
  --surface-container-high: #e8e3da;
  --surface-dim: #d6d1c9;
  --inverse-on-surface: #f5f0e8;
  --surface-variant: #e8e3da;
  --tertiary-fixed: #d6e3ff;
  --secondary: #e63b2e;
  --on-tertiary: #ffffff;
  --primary-fixed: #ffcc00;
  --background: #f5f0e8;
  --on-tertiary-fixed-variant: #1a1a1a;
  --error-container: #ffdad6;
  --on-secondary: #ffffff;
  --on-secondary-container: #1a1a1a;
  --on-surface: #1a1a1a;
  --on-primary-container: #1a1a1a;
  --inverse-surface: #1a1a1a;
  --on-tertiary-fixed: #1a1a1a;
  --tertiary-fixed-dim: #a8c6ff;
  --secondary-fixed-dim: #ffb3ab;
  --secondary-container: #ffdad6;
  --on-primary: #ffffff;
  --on-surface-variant: #4a4a4a;
  --on-primary-fixed: #1a1a1a;
  --secondary-fixed: #ffdad6;
  --on-primary-fixed-variant: #1a1a1a;
  --inverse-primary: #f5f0e8;
  --surface-container-low: #f2ede5;
  --outline: #1a1a1a;
  --on-tertiary-container: #1a1a1a;
  --on-error-container: #93000a;
  --on-secondary-fixed: #1a1a1a;
  --surface-container-lowest: #ffffff;
  --on-secondary-fixed-variant: #1a1a1a;
  --error: #cc0000;
  --on-background: #1a1a1a;
  --surface-tint: #1a1a1a;
  --on-error: #ffffff;
  --tertiary-container: #d6e3ff;
  --tertiary: #0055ff;
  --surface-container: #eee9e0;
  --outline-variant: #d0cbc3;
  --surface-container-highest: #e2ddd4;
  --primary-fixed-dim: #e6b800;
  --primary-container: #ffcc00;
  --primary: #1a1a1a;

  --font-headline: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-body);
  background-color: var(--surface);
  color: var(--on-surface);
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--surface);
}

::selection {
  background-color: #ffcc00;
  color: #1a1a1a;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--surface-container);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border: 1px solid var(--surface);
}

/* Bauhaus Checkbox */
.bauhaus-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid #1a1a1a;
  background-color: #ffffff;
  border-radius: 0;
  cursor: pointer;
  position: relative;
  display: inline-grid;
  place-content: center;
  transition: all 0.1s ease;
}

.bauhaus-checkbox:checked {
  background-color: #1a1a1a;
}

.bauhaus-checkbox:checked::after {
  content: "";
  width: 6px;
  height: 6px;
  background-color: #ffcc00;
}

/* DARK MODE OVERRIDES */
html.dark {
  --surface-bright: #242424;
  --surface: #141414;
  --surface-container-high: #2a2a2a;
  --surface-dim: #383838;
  --surface-container-low: #181818;
  --surface-container-lowest: #1c1c1c;
  --surface-container: #202020;
  --on-surface: #f5f0e8;
  --on-surface-variant: #a8a398;
  --primary: #f5f0e8;
  --outline: #f5f0e8;
  --outline-variant: #444444;
}

html.dark body {
  background-color: #141414 !important;
  color: #f5f0e8 !important;
}

html.dark header,
html.dark aside {
  background-color: #141414 !important;
  border-color: #383838 !important;
}

html.dark footer {
  background-color: #181818 !important;
  border-color: #383838 !important;
}

html.dark .bg-surface {
  background-color: #141414 !important;
}

html.dark .bg-surface-container {
  background-color: #1f1f1f !important;
}

html.dark .bg-surface-container-low {
  background-color: #181818 !important;
}

html.dark .bg-surface-container-high {
  background-color: #282828 !important;
}

html.dark .bg-surface-container-lowest {
  background-color: #1c1c1c !important;
}

html.dark .text-on-surface {
  color: #f5f0e8 !important;
}

html.dark .text-on-surface-variant {
  color: #a8a398 !important;
}

html.dark .border-primary {
  border-color: #383838 !important;
}

html.dark .border-primary\/20 {
  border-color: rgba(255, 255, 255, 0.12) !important;
}

html.dark .shadow-\[2px_2px_0px_#1a1a1a\],
html.dark .shadow-\[3px_3px_0px_#1a1a1a\],
html.dark .shadow-\[4px_4px_0px_#1a1a1a\],
html.dark .shadow-\[5px_5px_0px_#1a1a1a\],
html.dark .shadow-\[6px_6px_0px_#1a1a1a\],
html.dark .shadow-\[8px_8px_0px_#1a1a1a\] {
  box-shadow: 4px 4px 0px #000000 !important;
}

html.dark .cluster-card {
  background-color: #1a1a1a !important;
  border-color: #383838 !important;
  box-shadow: 5px 5px 0px #000000 !important;
}

html.dark .cluster-card:hover {
  box-shadow: 6px 6px 0px #ffcc00 !important;
}

html.dark .topic-item {
  background-color: #161616 !important;
  border-color: #282828 !important;
}

html.dark .topic-item:hover {
  background-color: #222222 !important;
}

html.dark .bauhaus-checkbox {
  border-color: #f5f0e8;
  background-color: #181818;
}

html.dark .bauhaus-checkbox:checked {
  background-color: #ffcc00;
}

html.dark .bauhaus-checkbox:checked::after {
  background-color: #1a1a1a;
}


/* ==========================================================================
   HIGH-CONTRAST INTERACTIVE STATE ENGINE (IDLE, HOVER, ACTIVE, FOCUS)
   ========================================================================== */

/* Universal Link & Button Transitions */
a, button, input {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

/* 1. Terminal Installation Box & Tabs */
.tab-btn {
  background-color: transparent;
  color: #d6d1c9;
  border-color: transparent;
  cursor: pointer;
}

.tab-btn:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.08);
}

.tab-btn:active {
  transform: translateY(1px);
}

/* Active Tab in Light Mode */
.tab-btn.bg-surface,
.tab-btn.tab-active {
  background-color: #f5f0e8 !important;
  color: #1a1a1a !important;
  border-top: 2px solid #1a1a1a !important;
  border-left: 2px solid #1a1a1a !important;
  border-right: 2px solid #1a1a1a !important;
}

/* Active Tab in Dark Mode */
html.dark .tab-btn.bg-surface,
html.dark .tab-btn.tab-active {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #ffcc00 !important;
  font-weight: 700;
}

/* Copy Button States */
#copy-btn {
  background-color: #f5f0e8;
  color: #1a1a1a;
  border: 1.5px solid #1a1a1a;
  cursor: pointer;
}

#copy-btn:hover {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #1a1a1a !important;
}

#copy-btn:active {
  background-color: #e6b800 !important;
  color: #1a1a1a !important;
  transform: scale(0.97);
}

html.dark #copy-btn {
  background-color: #262626 !important;
  color: #f5f0e8 !important;
  border-color: #444444 !important;
}

html.dark #copy-btn:hover {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #ffcc00 !important;
}

html.dark #copy-btn:active {
  background-color: #e6b800 !important;
  color: #1a1a1a !important;
}

/* 2. Top Navigation Links (Light & Dark) */
header nav a {
  color: #4a4a4a;
}

header nav a:hover {
  color: #1a1a1a !important;
  background-color: #e8e3da !important;
}

header nav a:active {
  transform: translateY(1px);
}

html.dark header nav a {
  color: #a8a398 !important;
}

html.dark header nav a:hover {
  color: #f5f0e8 !important;
  background-color: #282828 !important;
}

html.dark header nav a:active {
  color: #ffcc00 !important;
}

/* 3. Hero & Action Buttons */
/* Primary Black CTA Button */
.bg-primary {
  background-color: #1a1a1a;
  color: #ffffff;
}

a.bg-primary:hover, button.bg-primary:hover {
  background-color: #e63b2e !important;
  color: #ffffff !important;
  border-color: #1a1a1a !important;
}

a.bg-primary:active, button.bg-primary:active {
  background-color: #cc291d !important;
  color: #ffffff !important;
  transform: translate(2px, 2px);
}

html.dark a.bg-primary, html.dark button.bg-primary {
  background-color: #222222 !important;
  color: #f5f0e8 !important;
  border-color: #444444 !important;
}

html.dark a.bg-primary:hover, html.dark button.bg-primary:hover {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #ffcc00 !important;
}

html.dark a.bg-primary:active, html.dark button.bg-primary:active {
  background-color: #e6b800 !important;
  color: #1a1a1a !important;
}

/* Secondary Red Buttons */
.bg-secondary {
  background-color: #e63b2e !important;
  color: #ffffff !important;
}

a.bg-secondary:hover, button.bg-secondary:hover {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

a.bg-secondary:active, button.bg-secondary:active {
  background-color: #000000 !important;
  color: #ffffff !important;
  transform: translate(2px, 2px);
}

html.dark a.bg-secondary:hover, html.dark button.bg-secondary:hover {
  background-color: #ffffff !important;
  color: #1a1a1a !important;
  border-color: #ffffff !important;
}

/* 4. Curriculum Filter Pills & Tier Tabs */
.tier-tab, .filter-pill {
  cursor: pointer;
}

.tier-tab:hover, .filter-pill:hover {
  background-color: #e8e3da !important;
  color: #1a1a1a !important;
}

.tier-tab:active, .filter-pill:active {
  transform: translateY(1px);
}

/* Active Tier Tab / Filter Pill (Light Mode) */
.tier-tab.bg-primary, .filter-pill.bg-primary {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

.tier-tab.bg-primary:hover, .filter-pill.bg-primary:hover {
  background-color: #333333 !important;
  color: #ffffff !important;
}

/* Active Tier Tab / Filter Pill (Dark Mode) */
html.dark .tier-tab, html.dark .filter-pill {
  background-color: #202020 !important;
  color: #f5f0e8 !important;
  border-color: #444444 !important;
}

html.dark .tier-tab:hover, html.dark .filter-pill:hover {
  background-color: #2a2a2a !important;
  color: #ffcc00 !important;
}

html.dark .tier-tab.bg-primary, html.dark .filter-pill.bg-primary {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #ffcc00 !important;
}

html.dark .tier-tab.bg-primary:hover, html.dark .filter-pill.bg-primary:hover {
  background-color: #e6b800 !important;
  color: #1a1a1a !important;
}

/* 5. Topic Accordion Items (Curriculum Page) */
.topic-item {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.topic-item:hover {
  background-color: #e8e3da !important;
}

.topic-item:active {
  background-color: #ddd8cf !important;
}

html.dark .topic-item {
  background-color: #181818 !important;
  border-color: #2d2d2d !important;
}

html.dark .topic-item:hover {
  background-color: #222222 !important;
  border-color: #444444 !important;
}

html.dark .topic-item:active {
  background-color: #2a2a2a !important;
}

/* 6. Contrast Accents in Dark Mode */
html.dark .text-primary-fixed {
  color: #ffcc00 !important;
}

html.dark .text-on-surface-variant {
  color: #a8a398 !important;
}

html.dark .text-on-surface {
  color: #f5f0e8 !important;
}

html.dark #topic-search-input {
  color: #f5f0e8 !important;
  background-color: transparent !important;
}

html.dark #topic-search-input::placeholder {
  color: #777777 !important;
}

/* Ensure text-primary in dark mode is bright readable linen/cream, EXCEPT inside yellow containers or buttons */
html.dark .text-primary:not(.bg-primary-container):not(.bg-primary-container *):not(header nav a.bg-primary-container) {
  color: #f5f0e8 !important;
}

/* ==========================================================================
   HIGH-SPECIFICITY CONTRAST & ACCESSIBILITY GUARDS (LIGHT & DARK MODES)
   ========================================================================== */

/* 1. Yellow Containers (bg-primary-container / #ffcc00):
   All titles, paragraphs, and inner text MUST be deep charcoal #1a1a1a in BOTH light & dark modes.
   This overrides any html.dark h1..h6 or html.dark p rules. */
.bg-primary-container,
html.dark .bg-primary-container {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
}

.bg-primary-container h1, .bg-primary-container h2, .bg-primary-container h3, .bg-primary-container h4, .bg-primary-container h5, .bg-primary-container h6,
.bg-primary-container p,
.bg-primary-container div,
.bg-primary-container > span,
html.dark .bg-primary-container h1, html.dark .bg-primary-container h2, html.dark .bg-primary-container h3, html.dark .bg-primary-container h4, html.dark .bg-primary-container h5, html.dark .bg-primary-container h6,
html.dark .bg-primary-container p,
html.dark .bg-primary-container div,
html.dark .bg-primary-container > span {
  color: #1a1a1a !important;
}

/* 2. Explicit Buttons / Action Links inside Yellow Containers (e.g., 'Browse Full Syllabus')
   MUST ALWAYS have dark background (#1a1a1a) with crisp white text (#ffffff) in BOTH modes. */
.syllabus-cta-btn,
.bg-primary-container a,
.bg-primary-container a[href="curriculum.html"],
html.dark .syllabus-cta-btn,
html.dark .bg-primary-container a,
html.dark .bg-primary-container a[href="curriculum.html"] {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
  border-color: #1a1a1a !important;
}

.syllabus-cta-btn *,
.bg-primary-container a *,
.bg-primary-container a[href="curriculum.html"] *,
html.dark .syllabus-cta-btn *,
html.dark .bg-primary-container a *,
html.dark .bg-primary-container a[href="curriculum.html"] * {
  color: #ffffff !important;
}

.syllabus-cta-btn:hover,
.bg-primary-container a:hover,
.bg-primary-container a[href="curriculum.html"]:hover,
html.dark .syllabus-cta-btn:hover,
html.dark .bg-primary-container a:hover,
html.dark .bg-primary-container a[href="curriculum.html"]:hover {
  background-color: #e63b2e !important;
  color: #ffffff !important;
  border-color: #e63b2e !important;
}

.syllabus-cta-btn:hover *,
.bg-primary-container a:hover *,
.bg-primary-container a[href="curriculum.html"]:hover *,
html.dark .syllabus-cta-btn:hover *,
html.dark .bg-primary-container a:hover *,
html.dark .bg-primary-container a[href="curriculum.html"]:hover * {
  color: #ffffff !important;
}

/* 3. Header Navigation (Active & Inactive in Light and Dark) */
header nav a {
  color: #4a4a4a;
}

header nav a:hover {
  color: #1a1a1a !important;
  background-color: #e8e3da !important;
}

html.dark header nav a {
  color: #a8a398 !important;
}

html.dark header nav a:hover {
  color: #f5f0e8 !important;
  background-color: #282828 !important;
}

/* Active navigation link in BOTH light and dark mode: Solid yellow box with black text */
header nav a.bg-primary-container,
html.dark header nav a.bg-primary-container,
header nav a.bg-primary-container:hover,
html.dark header nav a.bg-primary-container:hover,
header nav a[aria-current="page"],
html.dark header nav a[aria-current="page"],
header nav a[aria-current="page"]:hover,
html.dark header nav a[aria-current="page"]:hover,
aside nav a.bg-primary-container,
html.dark aside nav a.bg-primary-container,
aside nav a[aria-current="page"],
html.dark aside nav a[aria-current="page"] {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #1a1a1a !important;
  font-weight: 700 !important;
}

header nav a.bg-primary-container *,
html.dark header nav a.bg-primary-container *,
header nav a[aria-current="page"] *,
html.dark header nav a[aria-current="page"] *,
aside nav a.bg-primary-container *,
html.dark aside nav a.bg-primary-container *,
aside nav a[aria-current="page"] *,
html.dark aside nav a[aria-current="page"] * {
  color: #1a1a1a !important;
}

/* 4. Terminal & Installer Tabs (Light & Dark) */
.tab-btn {
  color: #8c8c8c !important;
  background-color: transparent !important;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: #ffffff !important;
  background-color: #262626 !important;
}

.tab-btn.tab-active,
.tab-btn.bg-surface {
  color: #1a1a1a !important;
  background-color: #f5f0e8 !important;
  border-color: #1a1a1a !important;
}

html.dark .tab-btn.tab-active,
html.dark .tab-btn.bg-surface {
  color: #1a1a1a !important;
  background-color: #ffcc00 !important;
  border-color: #ffcc00 !important;
  font-weight: 700 !important;
}

/* Terminal comment lines inside dark terminal/code blocks */
.text-surface-dim,
html.dark .text-surface-dim {
  color: #9ca3af !important;
}

/* Copy Buttons */
#copy-btn, #copy-cli-btn {
  transition: all 0.15s ease;
}

#copy-btn:hover {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #ffcc00 !important;
}

html.dark #copy-btn {
  background-color: #262626 !important;
  color: #f5f0e8 !important;
  border-color: #444444 !important;
}

html.dark #copy-btn:hover {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
}

#copy-cli-btn,
html.dark #copy-cli-btn {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #1a1a1a !important;
}

#copy-cli-btn:hover,
html.dark #copy-cli-btn:hover {
  background-color: #e63b2e !important;
  color: #ffffff !important;
  border-color: #e63b2e !important;
}

/* 5. Comparison Table in Light & Dark Mode */
table thead tr th {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

table thead tr th.bg-primary-container,
html.dark table thead tr th.bg-primary-container {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  font-weight: 700 !important;
}

/* Light mode table tbody */
table tbody tr td {
  background-color: transparent;
  color: #1a1a1a;
}

table tbody tr td.bg-surface-container-lowest {
  background-color: #ffffff;
}

table tbody tr:hover td,
table tbody tr:hover td * {
  background-color: #e8e3da !important;
  color: #1a1a1a !important;
}

table tbody tr:hover td code {
  background-color: #d6d1c9 !important;
  color: #1a1a1a !important;
}

/* Dark mode table tbody */
html.dark table tbody tr td,
html.dark table tbody tr td.text-on-surface,
html.dark table tbody tr td.text-on-surface-variant {
  background-color: #181818 !important;
  color: #f5f0e8 !important;
  border-color: #2d2d2d !important;
}

html.dark table tbody tr td.bg-surface-container-lowest {
  background-color: #141414 !important;
  color: #f5f0e8 !important;
}

html.dark table tbody tr td code {
  background-color: #262626 !important;
  color: #ffcc00 !important;
  border: 1px solid #383838 !important;
}

/* Dark mode table hover: MUST stay dark background (#282828) with crisp bright white/cream text */
html.dark table tbody tr:hover td,
html.dark table tbody tr:hover td *,
html.dark table tbody tr:hover td.text-on-surface,
html.dark table tbody tr:hover td.text-on-surface-variant,
html.dark table tbody tr:hover td.bg-surface-container-lowest,
html.dark table tbody tr.hover\:bg-surface-container-high:hover td,
html.dark table tbody tr.hover\:bg-surface-container-high:hover td * {
  background-color: #282828 !important;
  color: #ffffff !important;
}

html.dark table tbody tr:hover td code {
  background-color: #383838 !important;
  color: #ffcc00 !important;
}

/* 6. Curriculum Cluster Cards & Badges Wrapping */
.cluster-badge {
  white-space: nowrap !important;
  word-break: keep-all !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1.2 !important;
  min-width: max-content !important;
}

.cluster-badge.bg-surface-container-lowest {
  background-color: #ffffff !important;
  color: #1a1a1a !important;
  border-color: #1a1a1a !important;
}

html.dark .cluster-badge.bg-surface-container-lowest {
  background-color: #222222 !important;
  color: #f5f0e8 !important;
  border-color: #555555 !important;
}

.cluster-badge.bg-primary-container,
html.dark .cluster-badge.bg-primary-container {
  background-color: #ffcc00 !important;
  color: #1a1a1a !important;
  border-color: #1a1a1a !important;
}

.cluster-badge.bg-emerald-400,
html.dark .cluster-badge.bg-emerald-400 {
  background-color: #34d399 !important;
  color: #1a1a1a !important;
  border-color: #1a1a1a !important;
}

.topic-item .font-mono {
  word-break: break-all !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.3 !important;
}

/* 7. Search Input Leading Icon in Light & Dark Mode */
#search-icon-wrap,
#search-icon-wrap .material-symbols-outlined {
  color: #1a1a1a !important;
}

html.dark #search-icon-wrap,
html.dark #search-icon-wrap .material-symbols-outlined {
  color: #f5f0e8 !important;
}

/* 8. Mobile Responsiveness Guards */
*, *::before, *::after {
  max-width: 100%;
}

body {
  overflow-x: hidden !important;
  position: relative;
  width: 100%;
}

@media (max-width: 640px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
  .cluster-badge {
    font-size: 10px !important;
    padding: 2px 6px !important;
  }
}
