:root {
  /* Palette */
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #6b7280;
  --card: #ffffff;
  --ring: #e5e7eb;

  /* Accents */
  --blue: #2563eb;    /* DFS */
  --green: #16a34a;   /* BFS */
  --violet: #7c3aed;  /* A*  */

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 10px 20px rgba(0,0,0,.06), 0 3px 6px rgba(0,0,0,.05);

  /* Motion */
  --dur: .24s;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* =========================
   Dark theme tokens
========================= */
.dark {
  --bg: #0b1220;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --card: #0f172a;
  --ring: #1f2937;
  --shadow-md: 0 10px 24px rgba(0,0,0,.35);
}

/* =========================
   Global Elements
========================= */
#theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 9999px;
  padding: 8px;
  line-height: 1;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#theme-toggle:hover { background: rgba(0,0,0,.06); transform: scale(1.04); }
.dark #theme-toggle:hover { background: rgba(255,255,255,.06); }

/* Invert theme icon in dark mode (same as activities) */
#theme-toggle img {
  display: block;
  width: 28px;
  height: 28px;
  filter: invert(0);
  transition: filter var(--dur) var(--ease);
}
.dark #theme-toggle img { filter: invert(1); }

/* =========================
   Hero
========================= */
.hero {
  max-width: 980px;
  margin: 72px auto 0;
  padding: 0 20px;
  text-align: center;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-family: 'Poppins', Inter, system-ui, sans-serif;
}
.brand__emoji { font-size: 32px; color: #ec4899; }
.brand__title {
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 36px);
  letter-spacing: 0.3px;
}
.hero__title {
  margin: 10px 0 10px;
  font-weight: 600;
  font-size: clamp(28px, 4.8vw, 40px);
}
.hero__lead {
  margin: 0 auto;
  color: var(--muted);
  max-width: 740px;
  font-size: clamp(16px, 1.9vw, 18px);
  line-height: 1.65;
}

/* =========================
   Cards Grid
========================= */
.cards {
  max-width: 1100px;
  margin: 42px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 980px) {
  .cards { grid-template-columns: 1fr; }
}

/* =========================
   Card Component
========================= */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 28px 26px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  outline: none;
}

/* Accent glow (top fade) */
.card__accent {
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 60%;
  background: linear-gradient(to bottom, rgba(37,99,235,.20), transparent 60%);
  border-radius: 18px 18px 0 0;
  filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

/* Icon */
.card__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  font-size: 26px;
  color: white;
  box-shadow: 0 6px 16px rgba(0,0,0,.10);
  transition: transform var(--dur) var(--ease);
}
.card__icon--blue   { background: var(--blue); }
.card__icon--green  { background: var(--green); }
.card__icon--violet { background: var(--violet); }

.card__title { margin: 6px 0 8px; font-size: 20px; font-weight: 600; }
.card__desc  { color: var(--muted); font-size: 14.5px; line-height: 1.55; margin: 0 0 14px; }

.card__bullets {
  list-style: disc inside;
  color: var(--muted);
  text-align: left;
  max-width: 360px;
  margin: 0 auto 16px;
  padding: 0;
}
.card__bullets li { margin: 4px 0; }

/* CTA button */
.button {
  display: inline-block;
  border: 1px solid transparent;
  color: #fff;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 9999px;
  text-decoration: none;
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.button:hover { filter: brightness(.95); transform: translateY(-2px); }
.button--blue   { background: var(--blue); }
.button--green  { background: var(--green); }
.button--violet { background: var(--violet); }

/* Hover/focus states */
.card:hover,
.card:focus-within {
  transform: translateY(-12px) scale(1.01);
  box-shadow: 0 18px 40px rgba(0,0,0,.10), 0 6px 12px rgba(0,0,0,.06);
}
.card:hover .card__icon,
.card:focus-within .card__icon { transform: translateY(-4px) rotate(-2deg); }
.card:hover .card__title,
.card:focus-within .card__title {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.card:hover .card__accent,
.card:focus-within .card__accent { opacity: 1; }

/* Themed border on hover using per-card modifier */
.card--dfs:hover, .card--dfs:focus-within     { border-color: color-mix(in oklab, var(--blue) 45%, var(--ring)); }
.card--bfs:hover, .card--bfs:focus-within     { border-color: color-mix(in oklab, var(--green) 45%, var(--ring)); }
.card--astar:hover, .card--astar:focus-within { border-color: color-mix(in oklab, var(--violet) 45%, var(--ring)); }

/* =========================
   On-load reveal animation (cards)
========================= */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(22px) scale(.985); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.reveal-cards .card {
  opacity: 0;
  animation: cardIn .66s var(--ease) forwards;
  animation-delay: var(--reveal-delay, 0ms);
}
@media (prefers-reduced-motion: reduce) {
  .reveal-cards .card { opacity: 1; animation: none; }
}

/* ===== Non-card UI (titles / quick) use the same slide-down as other pages ===== */
@keyframes cardInDown {
  from { opacity: 0; transform: translateY(-22px) scale(.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
/* Apply only while <html> has .reveal-home */
.reveal-home #theme-toggle,
.reveal-home .brand,
.reveal-home .hero__title,
.reveal-home .hero__lead,
.reveal-home .quick__title,
.reveal-home .pill {
  opacity: 0;
  animation: cardInDown .4s var(--ease) forwards;
  animation-delay: var(--home-delay, 0ms);
  will-change: transform, opacity;
}

/* =========================
   Test Your Knowledge
========================= */
.quick {
  max-width: 900px;
  margin: 8px auto 60px;
  text-align: center;
  padding: 0 20px;
}
.quick__title { margin: 6px 0 12px; font-size: 20px; }

/* Theme-aware pill */
.pill {
  display: inline-block;
  border: 1px solid var(--ring);
  padding: 10px 16px;
  border-radius: 9999px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
/* Subtle interaction states for both themes */
.pill:hover { transform: translateY(-1px); }
.pill:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--blue) 45%, transparent);
  outline-offset: 2px;
  text-decoration: none;
}
.dark .pill { box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.dark .pill:hover { box-shadow: 0 4px 14px rgba(0,0,0,.45); }

/* =========================
   Progressive enhancement
========================= */
@media (hover: none) {
  .card { cursor: default; }
}
