/* ==========================================================================
   OmniOperand — Core Mathematical Design System (omni-core.css)
   Precision UI, High-Contrast Glassmorphism, Math Typography & Grid Layouts
   ========================================================================== */

:root {
  /* Color Palette — Deep Obsidian Scientific Theme */
  --bg-space: #070a12;
  --bg-surface: #0d1322;
  --bg-surface-elevated: #131c31;
  --bg-glass: rgba(13, 19, 34, 0.78);
  --bg-glass-card: rgba(19, 28, 49, 0.65);
  
  --border-subtle: rgba(56, 189, 248, 0.12);
  --border-active: rgba(56, 189, 248, 0.38);
  --border-accent: rgba(6, 182, 212, 0.5);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #030712;

  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-blue: #38bdf8;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-violet: #a855f7;
  --accent-violet-glow: rgba(168, 85, 247, 0.22);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-math: "Cambria Math", "Latin Modern Math", "TeX Gyre Termes Math", "STIX Two Math", Cambria, Georgia, serif;

  /* Dimensions & Spacing */
  --container-max: 1200px;
  --header-height: 68px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.5), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 24px -4px var(--accent-cyan-glow);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-space: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --bg-glass-card: rgba(255, 255, 255, 0.85);

  --border-subtle: rgba(14, 165, 233, 0.18);
  --border-active: rgba(14, 165, 233, 0.45);
  --border-accent: rgba(2, 132, 199, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;

  --accent-cyan: #0284c7;
  --accent-cyan-glow: rgba(2, 132, 199, 0.15);
  --accent-blue: #0369a1;
  --accent-emerald: #059669;
  --accent-violet: #7c3aed;
  --accent-amber: #d97706;

  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px -4px rgba(2, 132, 199, 0.2);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-space);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-image: 
    radial-gradient(rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(6, 182, 212, 0.12), transparent 70%);
  background-size: 28px 28px, 100% 100%;
  background-position: 0 0, center 0;
}

/* Typography Basics */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); margin-top: 1.5rem; margin-bottom: 0.5rem; }

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 1.025rem;
}

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

a:hover {
  color: var(--accent-blue);
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
}

/* Mathematical Notation Styling */
.math-tex {
  font-family: var(--font-math);
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--text-primary);
}

.math-sym {
  font-family: var(--font-math);
  font-style: normal;
}

.math-num {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.math-display {
  display: block;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  font-family: var(--font-math);
  font-size: 1.25rem;
  overflow-x: auto;
  color: var(--text-primary);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.math-fraction {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  font-size: 0.9em;
  padding: 0 0.2em;
}

.math-fraction .num {
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}

.math-fraction .den {
  padding-top: 1px;
}

.math-radical {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.math-radical .rad-symbol {
  font-size: 1.2em;
  margin-right: 1px;
}

.math-radical .rad-content {
  border-top: 1px solid currentColor;
  padding-top: 1px;
}

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

/* Master Navigation Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  transition: border-color 0.2s ease;
}

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

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-family: var(--font-math);
  font-size: 1.15rem;
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.925rem;
  font-weight: 500;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: rgba(56, 189, 248, 0.08);
}

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

/* Quick Search Bar */
.search-btn-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-btn-trigger:hover {
  border-color: var(--border-active);
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.search-kbd {
  font-size: 0.7rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* Theme Toggle Button */
.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
  background: var(--bg-surface);
}

/* Breadcrumbs Component */
.breadcrumb-wrapper {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(13, 19, 34, 0.4);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb-item a {
  color: var(--text-secondary);
  transition: color 0.15s;
}

.breadcrumb-item a:hover {
  color: var(--accent-cyan);
}

.breadcrumb-separator {
  color: var(--text-muted);
  user-select: none;
}

.breadcrumb-item.active {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Category Hubs Card Grid */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.hub-card {
  position: relative;
  background: var(--bg-glass-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.hub-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--card-accent, var(--accent-cyan)), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hub-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-active);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.hub-card:hover::before {
  opacity: 1;
}

.hub-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.hub-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--accent-cyan);
  font-size: 1.35rem;
}

.hub-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.hub-card-title {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.hub-card-desc {
  font-size: 0.925rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.hub-card-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}

.hub-card-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.15s ease;
}

.hub-card-links a:hover {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-cyan);
  transform: translateX(3px);
}

/* Callout Box Component */
.callout {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  background: var(--bg-surface-elevated);
  border-left: 4px solid var(--accent-cyan);
  border: 1px solid var(--border-subtle);
  border-left-width: 4px;
}

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

.callout.info { border-left-color: var(--accent-cyan); }
.callout.success { border-left-color: var(--accent-emerald); }
.callout.warning { border-left-color: var(--accent-amber); }
.callout.theory { border-left-color: var(--accent-violet); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-cyan-glow);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

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

.btn-sm {
  font-size: 0.825rem;
  padding: 0.4rem 0.75rem;
}

/* Modal Search Overlay */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 1.5rem 2rem;
}

.search-modal.active {
  display: flex;
}

.search-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-md), 0 0 40px rgba(6, 182, 212, 0.15);
  overflow: hidden;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.75rem;
}

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.15rem;
  outline: none;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.75rem;
  list-style: none;
}

.search-result-item a {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: background 0.15s ease;
}

.search-result-item a:hover {
  background: var(--bg-surface-elevated);
}

.search-result-title {
  font-weight: 600;
  color: var(--accent-cyan);
}

.search-result-category {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Master Footer */
.site-footer {
  margin-top: 5rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 3rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-col h4 {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

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

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

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

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .header-nav { display: none; }
  .hub-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 1rem; text-align: center; }
}
