/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a12;
  --bg2: #10101e;
  --surface: #16162a;
  --surface-2: #1d1d33;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --accent: #7c6fff;
  --accent2: #ff6584;
  --green: #43c6ac;
  --orange: #f7971e;
  --text: #e8e8f0;
  --muted: #9a9ab8;
  --font-display: 'Unbounded', sans-serif;
  --font-body: 'Inter', sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 18px 60px rgba(0,0,0,0.28);
  --shadow-card: 0 14px 40px rgba(0,0,0,0.22);
}

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(circle at top left, rgba(124,111,255,0.15), transparent 28%),
    radial-gradient(circle at top right, rgba(255,101,132,0.12), transparent 24%),
    linear-gradient(180deg, #0a0a12 0%, #0d0d18 42%, #090910 100%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  opacity: 0;
  transform: translateY(10px);
  animation: pageEnter 0.65s ease-out forwards;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
a, button, input { -webkit-tap-highlight-color: transparent; }

::selection {
  background: rgba(124,111,255,0.32);
  color: #fff;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(124,111,255,0.8);
  outline-offset: 3px;
}

body.is-leaving {
  pointer-events: none;
  animation: pageExit 0.32s ease-in forwards;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pageExit {
  from {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(4px);
  }
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== NAVBAR ===== */
.navbar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1180px, calc(100% - 24px));
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(10,10,18,0.72);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 8px;
}

.nav-links a {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.burger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s;
}

/* ===== HERO ===== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 124px 32px 72px;
  max-width: 1180px;
  margin: 0 auto;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#mathCanvas {
  width: 100%;
  height: 100%;
}

.hero-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.5;
  pointer-events: none;
}

.hero-orb.orb-1 {
  width: 340px;
  height: 340px;
  right: 18%;
  top: 18%;
  background: radial-gradient(circle, rgba(124,111,255,0.22), transparent 70%);
}

.hero-orb.orb-2 {
  width: 280px;
  height: 280px;
  left: -40px;
  bottom: 40px;
  background: radial-gradient(circle, rgba(255,101,132,0.18), transparent 72%);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 620px;
  align-self: center;
}

.hero-content-centered {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: heroFadeUp 0.9s ease-out both;
  width: min(100%, 760px);
}

.hero-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(124,111,255,0.12);
  border: 1px solid rgba(124,111,255,0.3);
  border-radius: 100px;
  padding: 6px 16px;
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 5.8vw, 4.8rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -1.6px;
  margin-bottom: 18px;
  max-width: 9.5ch;
}

.accent {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.04rem;
  color: var(--muted);
  max-width: 42ch;
  margin-bottom: 26px;
  line-height: 1.75;
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 30px;
  max-width: 620px;
}

.hero-point {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 0.86rem;
}

.hero-point::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 12px rgba(124,111,255,0.7);
}

.hero-btns {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 196px;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.25s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9b8fff);
  color: #fff;
  box-shadow: 0 4px 24px rgba(124,111,255,0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124,111,255,0.5);
}

.btn-ghost {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  transform: translateY(-2px);
}

@keyframes heroFadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseOrb {
  0%, 100% {
    transform: scale(1);
    opacity: 0.45;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.7;
  }
}

@keyframes shimmerText {
  0%, 100% {
    filter: drop-shadow(0 0 0 rgba(124,111,255,0));
  }
  50% {
    filter: drop-shadow(0 8px 24px rgba(124,111,255,0.18));
  }
}

@keyframes softFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.hero-orb {
  animation: pulseOrb 10s ease-in-out infinite;
}

.hero-title {
  animation: shimmerText 8s ease-in-out infinite;
}

.hero-point {
  animation: softFloat 5s ease-in-out infinite;
}

.hero-point:nth-child(2) {
  animation-delay: 0.8s;
}

.hero-point:nth-child(3) {
  animation-delay: 1.6s;
}

.btn {
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

/* ===== SECTIONS ===== */
.section {
  padding: 84px 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.8vw, 2.05rem);
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.section-sub {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 0.98rem;
  max-width: 56ch;
  line-height: 1.7;
}

.section-badge {
  flex-shrink: 0;
  align-self: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(124,111,255,0.25);
  background: rgba(124,111,255,0.08);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ===== TOPICS GRID ===== */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.topic-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 248px;
  box-shadow: var(--shadow-card);
}

.topic-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--clr) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 0;
}

.topic-card:hover::before { opacity: 0.08; }

.topic-card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--clr) 50%, rgba(255,255,255,0.18));
}

.topic-card > * { position: relative; z-index: 1; }

.topic-icon {
  font-size: 2.3rem;
  margin-bottom: 14px;
  color: var(--clr);
}

.topic-card h3 {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 9px;
}

.topic-card p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.68;
  margin-bottom: 22px;
  max-width: 36ch;
}

.topic-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr);
  background: color-mix(in srgb, var(--clr) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--clr) 25%, transparent);
  padding: 4px 12px;
  border-radius: 100px;
  margin-top: auto;
  align-self: flex-start;
}

/* ===== HIGHLIGHTS ===== */
.highlights-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.hl-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)),
    var(--surface);
  padding: 28px 18px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}

.hl-num {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 2.8rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hl-text {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ===== QUICKREF ===== */
.quickref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.qr-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
}

.qr-item:hover {
  background: rgba(124,111,255,0.12);
  border-color: rgba(124,111,255,0.28);
  color: #fff;
  transform: translateY(-2px);
}

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  background: rgba(9,9,16,0.8);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer p {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===== PAGE LAYOUT (inner pages) ===== */
.page-hero {
  padding: 132px 32px 68px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at top right, rgba(124,111,255,0.12), transparent 24%),
    linear-gradient(180deg, rgba(16,16,30,0.92) 0%, rgba(10,10,18,0.86) 100%);
}

.page-hero .label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

.page-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 14px;
}

.page-hero p {
  color: var(--muted);
  max-width: 540px;
  font-size: 1rem;
}

.page-body {
  padding: 60px 0 80px;
}

/* ===== TOPIC SECTIONS ===== */
.topic-section {
  margin-bottom: 64px;
  scroll-margin-top: 96px;
}

.topic-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.topic-section h2 .tag {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tag-10 { background: rgba(124,111,255,0.15); color: var(--accent); }
.tag-11 { background: rgba(255,101,132,0.15); color: var(--accent2); }
.tag-both { background: rgba(67,198,172,0.15); color: var(--green); }

/* ===== FORMULA BLOCKS ===== */
.formula-block {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
    var(--surface);
  border: 1px solid rgba(255,255,255,0.07);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 20px 24px;
  margin: 16px 0;
  font-family: 'Georgia', serif;
  font-size: 1.05rem;
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

.formula-block.green { border-left-color: var(--green); }
.formula-block.red { border-left-color: var(--accent2); }
.formula-block.orange { border-left-color: var(--orange); }

.formula-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}

/* ===== INFO CARDS ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.info-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.info-card h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--accent);
}

.info-card ul {
  padding-left: 18px;
}

.info-card ul li {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
  line-height: 1.5;
}

/* ===== TABLE ===== */
.math-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9rem;
  overflow: hidden;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.math-table th {
  background: rgba(255,255,255,0.035);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.math-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: 'Georgia', serif;
  background: rgba(255,255,255,0.01);
}

.math-table tr:last-child td { border-bottom: none; }
.math-table tr:hover td { background: rgba(255,255,255,0.03); }

/* ===== EXPLANATION ===== */
.explanation {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.8;
  margin: 16px 0;
}

.highlight-text {
  color: var(--text);
  font-weight: 500;
}

/* ===== SIDEBAR NAV (inner pages) ===== */
.page-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 96px;
}

.sidebar-nav {
  list-style: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.sidebar-nav a {
  display: block;
  padding: 13px 18px;
  font-size: 0.88rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  transition: all 0.2s;
}

.sidebar-nav a:last-child { border-bottom: none; }
.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar-nav a.active { color: var(--accent); background: rgba(124,111,255,0.08); }

/* ===== EXAMPLE BOX ===== */
.example {
  background: rgba(67,198,172,0.06);
  border: 1px solid rgba(67,198,172,0.2);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  margin: 16px 0;
  box-shadow: var(--shadow-card);
}

.example-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--green);
  margin-bottom: 10px;
  display: block;
}

/* ===== CHEAT SHEET ===== */
.cheat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.search-bar {
  width: 100%;
  max-width: 440px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-body);
  outline: none;
  box-shadow: var(--shadow-card);
}

.search-bar:focus { border-color: rgba(124,111,255,0.45); }
.search-bar::placeholder { color: var(--muted); }

.search-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.cheat-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.cheat-card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--accent);
}

.cheat-card ul {
  list-style: none;
}

.cheat-card ul li {
  font-family: 'Georgia', serif;
  font-size: 0.92rem;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.5;
}

.cheat-card ul li:last-child { border-bottom: none; }

.cheat-section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 48px 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

/* ===== MOBILE ===== */
@media (max-width: 900px) {
  .hero {
    max-width: 760px;
  }
}

@media (max-width: 768px) {
  .container { padding: 0 18px; }

  .navbar {
    top: 10px;
    width: calc(100% - 20px);
    padding: 12px 14px;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: 74px;
    left: 10px;
    right: 10px;
    background: rgba(16,16,30,0.96);
    border: 1px solid var(--border);
    border-radius: 18px;
    flex-direction: column;
    padding: 16px;
    gap: 4px;
    box-shadow: var(--shadow-soft);
  }

  .nav-links.open { display: flex; }
  .burger { display: flex; }

  .hero {
    padding: 104px 20px 44px;
  }

  .hero-content-centered {
    width: 100%;
  }

  .hero-sub {
    max-width: 32ch;
  }

  .btn {
    min-width: 0;
  }

  .topics-grid { grid-template-columns: 1fr; }
  .highlights-grid { grid-template-columns: repeat(2, 1fr); }

  .footer-inner { flex-direction: column; text-align: center; }

  .page-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }

  .page-hero { padding: 104px 20px 48px; }
  .page-body .container { padding: 0 16px; }

  .section-head,
  .cheat-toolbar {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .highlights-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 2.2rem; letter-spacing: -1px; }
  .btn { width: 100%; padding: 12px 20px; font-size: 0.9rem; }
  .hero-point { width: 100%; justify-content: center; }
  .search-bar { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  body,
  body.is-leaving,
  .hero-content-centered,
  .hero-orb,
  .hero-title,
  .hero-point,
  .btn,
  .topic-card,
  .hl-card,
  .qr-item {
    animation: none !important;
    transition: none !important;
  }
}
