/* ==========================================================================
   ITI JUNCTION — DESIGN SYSTEM & TOKENS
   Mobile-First 3D Educational UI | Dark & Light Mode | WCAG Accessible
   ========================================================================== */

:root {
  /* Core Brand Palette */
  --navy-950: #060b14;
  --navy-900: #0b1220;
  --navy-800: #111c33;
  --navy-700: #1a2947;
  --royal-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --cyan-500: #06b6d4;
  --cyan-400: #22d3ee;
  --orange-500: #f59e0b;
  --orange-600: #d97706;
  --green-500: #10b981;
  --green-600: #059669;
  --yellow-500: #eab308;
  --red-500: #ef4444;
  --purple-500: #8b5cf6;

  /* Light Theme Surface Tokens */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-2: #f1f5f9;
  --bg-surface-3: #e2e8f0;
  --bg-glass: rgba(255, 255, 255, 0.82);
  --bg-glass-dark: rgba(11, 18, 32, 0.82);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-color: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-glass: rgba(255, 255, 255, 0.45);

  /* 3D Depth & Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow-sm: 0 4px 12px -2px rgba(11, 18, 32, 0.08), 0 1px 3px rgba(11, 18, 32, 0.05);
  --shadow-3d: 0 12px 28px -6px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(37, 99, 235, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --shadow-3d-hover: 0 22px 42px -10px rgba(15, 23, 42, 0.18), 0 8px 18px -4px rgba(37, 99, 235, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-glow-blue: 0 10px 26px -4px rgba(37, 99, 235, 0.42);
  --shadow-glow-cyan: 0 10px 26px -4px rgba(6, 182, 212, 0.36);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Spacing & Radii */
  --radius-sm: 0.5rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.75rem;
  --radius-full: 9999px;

  --container-max: 1280px;
  --header-height: 70px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --transition-fast: 180ms var(--ease-out);
  --transition-med: 280ms var(--ease-out);
}

[data-theme="dark"] {
  --bg-page: #0b1220;
  --bg-surface: #111c33;
  --bg-surface-2: #16233f;
  --bg-surface-3: #1e3054;
  --bg-glass: rgba(17, 28, 51, 0.84);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-color: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.28);
  --border-glass: rgba(148, 163, 184, 0.2);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 6px 16px -4px rgba(0, 0, 0, 0.4);
  --shadow-3d: 0 14px 32px -8px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(6, 182, 212, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-3d-hover: 0 24px 48px -10px rgba(0, 0, 0, 0.7), 0 8px 20px rgba(37, 99, 235, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: clip;
  transition: background-color var(--transition-med), color var(--transition-med);
}

img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--cyan-500);
  outline-offset: 2px;
}

/* Skip to content for screen readers & keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 9999;
  background: var(--blue-600);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  transition: top 150ms ease;
}
.skip-link:focus {
  top: 1rem;
}

/* Layout Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: 1rem;
}
@media (min-width: 640px) {
  .container { padding-inline: 1.5rem; }
}
@media (min-width: 1024px) {
  .container { padding-inline: 2rem; }
}

.section {
  padding-block: 3.25rem;
}
@media (min-width: 768px) {
  .section { padding-block: 4.5rem; }
}

.section-alt {
  background: var(--bg-surface-2);
  border-block: 1px solid var(--border-color);
}

/* Typography Hierarchy */
h1, h2, h3, h4 {
  margin: 0 0 0.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-weight: 800;
}

h1 { font-size: clamp(1.75rem, 4vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2.2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.375rem); }
h4 { font-size: 1rem; font-weight: 700; }

p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
}

.text-muted { color: var(--text-muted); }
.text-gradient {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 55%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="dark"] .text-gradient {
  background: linear-gradient(135deg, #60a5fa 0%, #22d3ee 55%, #fbbf24 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Section Header */
.section-head {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 2rem;
}
.section-head--row {
  justify-content: space-between;
  align-items: flex-start;
}
@media (min-width: 768px) {
  .section-head--row {
    flex-direction: row;
    align-items: flex-end;
  }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue-600);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  width: fit-content;
}
[data-theme="dark"] .eyebrow {
  color: var(--cyan-400);
  background: rgba(6, 182, 212, 0.14);
  border-color: rgba(34, 211, 238, 0.25);
}

/* 3D Surface Cards */
.card-3d {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3d);
  padding: 1.35rem;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--transition-med), box-shadow var(--transition-med), border-color var(--transition-med);
}
.card-3d::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
[data-theme="dark"] .card-3d::before {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.card-3d--interactive:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-3d-hover);
  border-color: rgba(37, 99, 235, 0.35);
}

.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3d);
}

/* Buttons (Touch-Friendly min 44px height) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.94rem;
  border: 1px solid transparent;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
  white-space: normal;
  text-align: center;
  max-width: 100%;
}
.btn:active {
  transform: translateY(1px);
}
.btn-sm {
  min-height: 36px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  min-height: 50px;
  padding: 0.8rem 1.6rem;
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue-600) 0%, var(--royal-700) 100%);
  color: #fff;
  box-shadow: var(--shadow-glow-blue), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -4px rgba(37, 99, 235, 0.55);
}

.btn-cyan {
  background: linear-gradient(135deg, var(--cyan-500) 0%, #0284c7 100%);
  color: #fff;
  box-shadow: var(--shadow-glow-cyan), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-cyan:hover {
  transform: translateY(-2px);
}

.btn-orange {
  background: linear-gradient(135deg, var(--orange-500) 0%, var(--orange-600) 100%);
  color: #0b1220;
  box-shadow: 0 10px 22px -6px rgba(245, 158, 11, 0.45);
}
.btn-orange:hover { transform: translateY(-2px); }

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  border-color: var(--blue-600);
  color: var(--blue-600);
  background: rgba(37, 99, 235, 0.06);
}
[data-theme="dark"] .btn-outline:hover {
  color: var(--cyan-400);
  border-color: var(--cyan-400);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.62rem;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
  max-width: 100%;
}
.badge-blue { background: rgba(37, 99, 235, 0.12); color: var(--blue-600); }
.badge-cyan { background: rgba(6, 182, 212, 0.14); color: #0891b2; }
.badge-green { background: rgba(16, 185, 129, 0.14); color: #047857; }
.badge-orange { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.badge-yellow { background: rgba(234, 179, 8, 0.18); color: #a16207; }
.badge-red { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.badge-purple { background: rgba(139, 92, 246, 0.14); color: #6d28d9; }

[data-theme="dark"] .badge-blue { color: #93c5fd; }
[data-theme="dark"] .badge-cyan { color: #67e8f9; }
[data-theme="dark"] .badge-green { color: #6ee7b7; }
[data-theme="dark"] .badge-orange { color: #fcd34d; }
[data-theme="dark"] .badge-yellow { color: #fde047; }
[data-theme="dark"] .badge-red { color: #fca5a5; }
[data-theme="dark"] .badge-purple { color: #c4b5fd; }

/* Responsive Grids */
.grid {
  display: grid;
  gap: 1.25rem;
}
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.form-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}
.textarea {
  min-height: 110px;
  resize: vertical;
}

/* Responsive Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
th {
  background: var(--bg-surface-2);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a:hover {
  color: var(--blue-600);
  text-decoration: underline;
}

/* Utility Helpers */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print Styles for Printable Papers & Study Sheets */
@media print {
  .site-header, .site-footer, .no-print, .mobile-drawer { display: none !important; }
  body { background: #fff; color: #000; }
  .card-3d { box-shadow: none; border: 1px solid #ccc; }
}
