/* ─── Glass panel ────────────────────────────────────────────────────────── */
.glass-panel {
  border: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(148deg,
    rgba(15, 28, 52, 0.82) 0%,
    rgba(10, 18, 38, 0.58) 100%
  );
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 1px 0   rgba(255,255,255,0.06) inset,
    0 24px 48px -12px rgba(0,0,0,0.55),
    0  0px 80px -20px rgba(34,211,238,0.10);
}

/* ─── Animated gradient border on form ──────────────────────────────────── */
.form-glow {
  position: relative;
}

.form-glow::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg,
    rgba(34, 211, 238, 0.35),
    rgba(59, 130, 246, 0.22),
    rgba(139, 92, 246, 0.18),
    rgba(34, 211, 238, 0.35)
  );
  background-size: 300% 300%;
  animation: gradient-shift 9s ease infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0.6;
  pointer-events: none;
}

@keyframes gradient-shift {
  0%, 100% { background-position:   0% 50%; }
  50%       { background-position: 100% 50%; }
}

/* ─── Primary button ─────────────────────────────────────────────────────── */
.btn-space-primary {
  background: linear-gradient(135deg, #22d3ee 0%, #3b82f6 58%, #6366f1 100%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12) inset,
    0 4px 20px -4px rgba(34,211,238,0.45),
    0 10px 28px -6px rgba(59,130,246,0.30);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn-space-primary:hover:not(:disabled) {
  filter: brightness(1.12) saturate(1.1);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.15) inset,
    0 8px 32px -6px rgba(34,211,238,0.55),
    0 18px 44px -10px rgba(99,102,241,0.38);
  transform: translateY(-2px);
}

.btn-space-primary:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(1.05);
}

.btn-space-primary:disabled {
  opacity: 0.55;
  filter: grayscale(0.7);
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Site header nav — pill bar (all non-preview pages) ────────────────── */
body:not(.preview-mode-active) .site-header-nav {
  border-color: rgba(56, 189, 248, 0.12);
  background: linear-gradient(
    180deg,
    rgba(12, 22, 42, 0.5) 0%,
    rgba(8, 14, 32, 0.56) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(56, 189, 248, 0.03) inset,
    0 3px 18px -8px rgba(0, 0, 0, 0.38),
    0 0 28px -14px rgba(56, 189, 248, 0.06);
  backdrop-filter: blur(12px) saturate(1.06);
  -webkit-backdrop-filter: blur(12px) saturate(1.06);
}

body:not(.preview-mode-active) .site-header-nav a {
  color: rgb(132 165 196);
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

body:not(.preview-mode-active) .site-header-nav a:hover {
  color: rgb(203 230 248);
  background: rgba(56, 189, 248, 0.07);
  box-shadow: 0 0 12px -4px rgba(56, 189, 248, 0.12);
}

.nav-link-active {
  background: rgba(255,255,255,0.10);
  color: #fff;
}

body:not(.preview-mode-active) .site-header-nav a.nav-link-active {
  color: rgb(226 246 255);
  background: linear-gradient(
    135deg,
    rgba(34, 211, 238, 0.15) 0%,
    rgba(59, 130, 246, 0.11) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 0 1px rgba(34, 211, 238, 0.11) inset,
    0 0 14px -4px rgba(34, 211, 238, 0.12);
}

/* ─── Library subject tabs ───────────────────────────────────────────────── */
.tab-active {
  background: linear-gradient(135deg, rgba(34,211,238,0.22), rgba(59,130,246,0.28));
  color: rgb(207 250 254);
  box-shadow: 0 0 0 1px rgba(34,211,238,0.28) inset;
  transition: all 0.2s ease;
}

.tab-active-violet {
  background: linear-gradient(135deg, rgba(167,139,250,0.22), rgba(139,92,246,0.28));
  color: rgb(221 214 254);
  box-shadow: 0 0 0 1px rgba(167,139,250,0.28) inset;
  transition: all 0.2s ease;
}

.tab-active-emerald {
  background: linear-gradient(135deg, rgba(52,211,153,0.22), rgba(16,185,129,0.28));
  color: rgb(209 250 229);
  box-shadow: 0 0 0 1px rgba(52,211,153,0.28) inset;
  transition: all 0.2s ease;
}

.tab-active-blue {
  background: linear-gradient(135deg, rgba(96,165,250,0.22), rgba(59,130,246,0.28));
  color: rgb(219 234 254);
  box-shadow: 0 0 0 1px rgba(96,165,250,0.28) inset;
  transition: all 0.2s ease;
}

.tab-active-slate {
  background: linear-gradient(135deg, rgba(203,213,225,0.18), rgba(148,163,184,0.24));
  color: rgb(226 232 240);
  box-shadow: 0 0 0 1px rgba(203,213,225,0.28) inset;
  transition: all 0.2s ease;
}


.tab-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(34, 211, 238, 0.15);
}

.tab-inactive {
  color: rgb(148 163 184);
  transition: all 0.2s ease;
}

.tab-inactive:hover {
  color: rgb(226 232 240);
  background: rgba(255,255,255,0.07);
}

/* ─── Library cards ──────────────────────────────────────────────────────── */
.lib-card {
  cursor: pointer;
  touch-action: manipulation;   /* eliminates 300 ms tap delay on iOS/Android */
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.lib-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.07) inset,
    0 12px 24px -6px rgba(0,0,0,0.35),
    0  0px 40px -10px rgba(34,211,238,0.09);
}

/* ─── Library page entrance animations ──────────────────────────────────── */
body:not(.page-entered) #lib-hero > div:first-child { animation: hero-in 0.1s ease   0ms both; }
body:not(.page-entered) #lib-hero > div:last-child  { animation: hero-in 0.1s ease  40ms both; }
body:not(.page-entered) #lib-controls               { animation: hero-in 0.1s ease 100ms both; }
body:not(.page-entered) #grid-physics               { animation: hero-in 0.1s ease 120ms both; }

/* ─── Library h1 violet shimmer ─────────────────────────────────────────── */
#lib-hero h1.font-display {
  background: linear-gradient(118deg, rgb(248 250 252) 0%, rgb(221 214 254) 40%, rgb(196 181 253) 72%, rgb(167 139 250) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 200%;
  animation: title-shimmer 8s ease-in-out infinite alternate;
}

/* Pause shimmer in background tabs */
html.doc-background-paused #lib-hero h1.font-display {
  animation-play-state: paused;
}

/* ─── Helper drawer rendered markdown content ───────────────────────────── */
/* Server renders cached <kind>.md to HTML; this block styles the result.
   Use em (not rem) so headings/lists scale with the drawer's base font size
   (practice page = text-base, test page = text-sm). */
.ex-helper-body {
  padding: 0.85rem 1rem;
}
.ex-helper-body > :first-child { margin-top: 0; }
.ex-helper-body > :last-child  { margin-bottom: 0; }

/* H1 included for backward-compat with cached "# Topic" helpers that pre-date
   the prompt update; visually identical to H2. */
.ex-helper-body h1,
.ex-helper-body h2 {
  font-family: 'Sora', 'Outfit', system-ui, sans-serif;
  font-size: 1.05em;
  font-weight: 600;
  color: rgb(241, 245, 249);   /* slate-100 */
  margin: 1em 0 0.4em;
}
.ex-helper-body h3 {
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgb(148, 163, 184);   /* slate-400 */
  margin: 0.9em 0 0.3em;
}
.ex-helper-body p {
  margin: 0.45rem 0;
  line-height: 1.65;
}
.ex-helper-body ul,
.ex-helper-body ol {
  margin: 0.4rem 0;
  padding-left: 1.25rem;
}
.ex-helper-body ul { list-style: disc; }
.ex-helper-body ol { list-style: decimal; font-variant-numeric: tabular-nums; }
.ex-helper-body li { margin: 0.18rem 0; line-height: 1.5; }
.ex-helper-body strong {
  color: rgb(248, 250, 252);   /* slate-50 — lift from body slate-200 */
  font-weight: 600;
}
.ex-helper-body em {
  color: rgb(226, 232, 240);   /* slate-200 */
  font-style: italic;
}
.ex-helper-body code {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  color: rgb(165, 243, 252);   /* cyan-200 */
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}
.ex-helper-body pre {
  background: rgba(2, 6, 23, 0.6);
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem;
  overflow-x: auto;
  margin: 0.6rem 0;
}
.ex-helper-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.85em;
}
.ex-helper-body blockquote {
  border-left: 2px solid rgba(34, 211, 238, 0.4);
  padding-left: 0.7rem;
  margin: 0.5rem 0;
  color: rgb(203, 213, 225);   /* slate-300 */
}
.ex-helper-body hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 0.9rem 0;
}
/* Display math (KaTeX renders inside this wrapper from dollarmath) */
.ex-helper-body .math.block {
  margin: 0.7rem 0;
  overflow-x: auto;
}
