/* ============================================================
   VECTORS MODULE – CSS
   Matches Math Lab design tokens (mathlab.css vars & panels)
   ============================================================ */

/* ── Layout ─────────────────────────────────────────────────── */

html {
  scroll-behavior: smooth;
}

body.vectors-page {
  background:
    radial-gradient(circle at top left, rgba(148, 163, 184, 0.08), transparent 30%),
    linear-gradient(180deg, #0f172a 0%, #111c2d 55%, #0d1626 100%);
  color: #e5eef9;
}

body.vectors-page header {
  background: rgba(10, 18, 30, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.vectors-page .header-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

body.vectors-page .header-btn:hover,
body.vectors-page .header-btn:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.vectors-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.vectors-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.vectors-hero {
  display: block;
  margin-bottom: 1rem;
  padding: 1.15rem 1.2rem;
  background: rgba(12, 22, 36, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.vectors-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #dbeafe;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.vectors-hero-copy h2 {
  margin: 0.55rem 0 0.55rem;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.15;
  color: #f8fafc;
}

.vectors-hero-copy p {
  margin: 0;
  max-width: 70ch;
  color: rgba(241, 245, 249, 0.88);
  line-height: 1.65;
}

.vectors-lab-launcher {
  margin-bottom: 1rem;
  padding: 1rem 1.05rem;
  background: rgba(12, 22, 36, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.vectors-section-heading {
  margin-bottom: 0.9rem;
}

.vectors-section-kicker {
  display: inline-flex;
  margin-bottom: 0.3rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7dd3fc;
}

.vectors-section-heading h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #f8fafc;
}

.vectors-section-heading p {
  margin: 0.35rem 0 0;
  color: rgba(241, 245, 249, 0.82);
  font-size: 0.9rem;
}

.vectors-lab-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.vectors-lab-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 152px;
  padding: 0.95rem;
  border-radius: 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.vectors-lab-card:hover,
.vectors-lab-card:focus-visible {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(125, 211, 252, 0.24);
}

.vectors-lab-card strong {
  font-size: 1rem;
}

.vectors-lab-card p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: rgba(241, 245, 249, 0.84);
}

.vectors-lab-card-tag {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 700;
}

.vectors-tier-card.active {
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.18), rgba(37, 99, 235, 0.14));
  border-color: rgba(125, 211, 252, 0.3);
  box-shadow: 0 14px 28px rgba(2, 132, 199, 0.16);
}

.vectors-mobile-note {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(241, 245, 249, 0.86);
  font-size: 0.86rem;
}

/* ── Tier sections ──────────────────────────────────────────── */

.tier-section {
  margin-bottom: 1.2rem;
  scroll-margin-top: 92px;
  display: none;
}

.tier-section.active-tier {
  display: block;
}

.tier-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left-width: 4px;
  border-radius: 14px;
  user-select: none;
  transition: background 0.2s, transform 0.2s ease;
}

.tier-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: rgb(224, 226, 240);
  border: none;
  padding: 0;
}

.tier-header-copy {
  flex: 1;
  min-width: 0;
}

.tier-header-copy p {
  margin: 0.18rem 0 0;
  font-size: 0.88rem;
  color: rgba(226, 232, 240, 0.82);
  line-height: 1.45;
}

.tier-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.tier-section[data-tier="foundational"] .tier-header {
  border-left-color: #60a5fa;
}

.tier-section[data-tier="intermediate"] .tier-header {
  border-left-color: #94a3b8;
}

.tier-section[data-tier="advanced"] .tier-header {
  border-left-color: #cbd5e1;
}

.tier-body {
  display: block;
  padding: 0.65rem 0 0;
}

/* ── Topic cards ────────────────────────────────────────────── */

.topic-card {
  background: rgba(15, 23, 36, 0.9);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.topic-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.topic-card-lab {
  border-color: rgba(125, 211, 252, 0.16);
  background: linear-gradient(180deg, rgba(11, 26, 42, 0.98), rgba(15, 23, 36, 0.92));
}

.topic-card-lab .vec-lab {
  background: rgba(6, 12, 22, 0.58);
  border-color: rgba(125, 211, 252, 0.18);
  padding: 1rem;
}

.topic-card-lab .vec-lab h4 {
  font-size: 0.98rem;
}

.topic-card-header h3 {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 600;
  color: #f8fafc;
}

.topic-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(125, 211, 252, 0.18);
  color: #bae6fd;
  font-size: 0.72rem;
  font-weight: 700;
}

.topic-caret {
  font-size: 0.6rem;
  color: var(--accent);
  transition: transform 0.25s ease;
}

.topic-card.open > .topic-card-header .topic-caret {
  transform: rotate(90deg);
}

.topic-card-body {
  display: none;
  padding-top: 0.75rem;
}

.topic-card.open > .topic-card-body {
  display: block;
}

.topic-description {
  font-size: 0.92rem;
  color: rgba(241, 245, 249, 0.92);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

.topic-action-prompt {
  margin: 0 0 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(125, 211, 252, 0.14);
  color: #dbeafe;
  font-size: 0.84rem;
  line-height: 1.45;
}

.topic-tip {
  margin-top: 0.5rem;
  font-size: 0.86rem;
  color: rgba(191, 219, 254, 0.9);
}

.topic-examples {
  background: rgba(15, 23, 42, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(148, 163, 184, 0.55);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
  color: rgba(226, 232, 240, 0.9);
}

.topic-examples .example-item {
  padding: 0.2rem 0;
}

.vector-arithmetic-box {
  display: grid;
  gap: 0.8rem;
}

.vector-arithmetic-grid {
  display: grid;
  gap: 0.45rem;
}

.vector-arithmetic-formula {
  color: rgba(226, 232, 240, 0.94);
  line-height: 1.55;
}

.formula-note {
  color: rgba(191, 219, 254, 0.82);
  font-size: 0.82rem;
}

.vector-arithmetic-controls {
  margin: 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.vector-arithmetic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.vector-arithmetic-result {
  margin-top: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(6, 12, 22, 0.42);
  border: 1px solid rgba(125, 211, 252, 0.14);
}

.vector-arithmetic-meta {
  display: grid;
  gap: 0.2rem;
  padding-top: 0.1rem;
}

/* ── Interactive lab areas ──────────────────────────────────── */

.vec-lab {
  background: rgba(8, 14, 24, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.85rem;
  margin-top: 0.5rem;
}

.vec-lab h4 {
  margin: 0 0 0.6rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: #dbeafe;
}

.vec-lab canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  background: #0d1117;
  cursor: crosshair;
  touch-action: none;
}

/* ── Controls row ───────────────────────────────────────────── */

.vec-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0.6rem 0 0.7rem;
  align-items: center;
}

.vec-controls label {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.88);
}

.vec-controls input[type="number"],
.vec-controls input[type="range"],
.vec-controls select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #f8fafc;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
  width: 72px;
}

.vec-controls input[type="number"]::placeholder,
.vec-controls select::placeholder {
  color: rgba(248, 250, 252, 0.7);
}

.vec-controls input[type="number"]:focus-visible,
.vec-controls input[type="range"]:focus-visible,
.vec-controls select:focus-visible,
.vec-btn:focus-visible,
.vectors-tier-card:focus-visible,
.topic-card-header:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

.vec-controls input[type="range"] {
  width: 100px;
  padding: 0;
}

.vec-controls select {
  width: auto;
}

.vec-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 0.35rem 0.9rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.vec-btn:hover {
  background: #1d4ed8;
}

.vec-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.vec-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Readout / info strip ───────────────────────────────────── */

.vec-readout {
  margin-top: 0.5rem;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.vec-readout .val {
  color: #dbeafe;
  font-weight: 600;
}

.vectors-page mjx-container,
.vectors-page .MathJax,
.vectors-page .MathJax_Display {
  color: inherit !important;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 768px) {
  .vectors-container {
    padding: 0.5rem;
  }

  .vectors-header-actions {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .vectors-hero {
    padding: 1rem;
  }

  .vectors-lab-grid {
    grid-template-columns: 1fr;
  }

  .topic-card {
    padding: 0.75rem 0.9rem;
  }

  .topic-card-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topic-badge {
    margin-left: 1.3rem;
  }

  .tier-header {
    align-items: flex-start;
    padding: 0.85rem 0.9rem;
  }

  .tier-header-copy p {
    font-size: 0.82rem;
  }

  .tier-pill {
    margin-left: auto;
    font-size: 0.72rem;
  }

  .vec-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .vec-controls label {
    margin-bottom: -4px;
  }

  .vec-controls input[type="number"] {
    width: 100%;
  }

  .vec-controls input[type="range"] {
    width: 100%;
  }

  .topic-examples {
    font-size: 0.82rem;
    overflow-x: auto;
  }

  .vector-arithmetic-actions {
    flex-direction: column;
  }

  .vec-readout {
    font-size: 0.8rem;
  }
}

@media (max-width: 540px) {
  .tier-header {
    gap: 8px;
  }

  .tier-header h2 {
    font-size: 1rem;
  }

  .topic-card-header h3 {
    font-size: 0.95rem;
  }
}
