/* ===========================================================
   Shared styles — course-flashcards/
   Matches the dark/gradient aesthetic of ../lab-1-deploying-pods/
   =========================================================== */

:root {
  --bg: #06080d;
  --panel: #11151c;
  --panel-light: #1f2738;
  --panel-2: #161b25;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --good: #27AE60;
  --bad: #E74C3C;
  --warning: #F39C12;
  --grad-start: #4A90E2;
  --grad-end: #9B59B6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(ellipse at top, rgba(56, 189, 248, 0.05), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(155, 89, 182, 0.04), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body { padding-left: 60px; }

/* ====== Left rail nav (shared with labs) ====== */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 60px; z-index: 200;
  background: #0c1018; border-right: 1px solid #1f2738;
  display: flex; flex-direction: column;
  align-items: center; padding: 12px 0; gap: 4px;
}
.rail-brand {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: white; font-size: 0.9em;
  text-decoration: none; margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}
.rail-link {
  width: 44px; height: 44px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3em; color: white;
  text-decoration: none;
  transition: background 0.15s;
  position: relative;
}
.rail-link:hover { background: rgba(255,255,255,0.08); }
.rail-link.active { background: rgba(56, 189, 248, 0.18); }
.rail-link.active::before {
  content: ''; position: absolute; left: -8px; top: 10px; bottom: 10px;
  width: 3px; background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.rail-link:hover::after {
  content: attr(title);
  position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  background: var(--panel-light); color: var(--text);
  padding: 6px 12px; border-radius: 6px;
  font-size: 0.85em; font-weight: 600;
  white-space: nowrap;
  border: 1px solid #475569;
  z-index: 300; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ====== Header ====== */
header.page-header {
  padding: 22px 28px;
  background:
    linear-gradient(135deg, rgba(74, 144, 226, 0.85), rgba(155, 89, 182, 0.85)),
    var(--bg);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  position: relative;
}
header.page-header h1 {
  margin: 0; font-size: 1.5em; font-weight: 800;
  display: flex; align-items: center; gap: 10px;
}
header.page-header p {
  margin: 6px 0 0; opacity: 0.92; font-size: 0.95em;
}
header.page-header .breadcrumb {
  font-size: 0.78em;
  opacity: 0.75;
  margin-bottom: 6px;
}
header.page-header .breadcrumb a {
  color: white; text-decoration: none;
}
header.page-header .breadcrumb a:hover { text-decoration: underline; }

/* ====== Main containers ====== */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 28px 80px;
}
section.topic { margin-bottom: 56px; }
section.topic > h2 {
  font-size: 1.5em;
  margin: 0 0 6px;
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  display: flex; align-items: baseline; gap: 10px;
}
section.topic > h2 .topic-num {
  font-size: 0.65em;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  letter-spacing: 0.05em;
  font-weight: 700;
}
section.topic > p.lede {
  color: var(--muted);
  font-size: 1em;
  margin: 0 0 22px;
  line-height: 1.6;
  max-width: 800px;
}

/* ====== Flashcards ====== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  perspective: 1400px;
  height: 200px;
  cursor: pointer;
}
.card-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform 0.55s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-style: preserve-3d;
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  border-radius: 14px;
  padding: 18px 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--panel-light);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  overflow: hidden;
}
.card-front {
  background:
    linear-gradient(135deg, rgba(56,189,248,0.06), rgba(129,140,248,0.04)),
    var(--panel);
}
.card-front::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.card-back {
  transform: rotateY(180deg);
  background: var(--panel-2);
}
.card-back::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--grad-end), var(--accent));
}
.card .q {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}
.card .a {
  font-size: 0.88em;
  color: #e2e8f0;
  line-height: 1.55;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}
.card .a code,
.card .a strong { color: var(--accent); }
.card .a code {
  background: rgba(56, 189, 248, 0.08);
  padding: 1px 5px; border-radius: 4px;
  font-size: 0.92em;
}
.card .footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; font-size: 0.72em;
  color: var(--muted);
}
.card .tag {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-light);
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.85em;
}
.card .hint {
  opacity: 0.65;
  font-style: italic;
}
.card:hover .card-front {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(56,189,248,0.18);
}

/* ====== Animation player ====== */
.anim-player {
  background: var(--panel);
  border: 1px solid var(--panel-light);
  border-radius: 16px;
  padding: 22px;
  margin: 12px 0 0;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.anim-player .anim-title {
  font-size: 1.1em;
  font-weight: 700;
  margin: 0 0 4px;
}
.anim-player .anim-narration {
  color: var(--muted);
  font-size: 0.92em;
  line-height: 1.55;
  min-height: 3em;
  margin: 0 0 16px;
}
.anim-stage {
  position: relative;
  width: 100%;
  background:
    radial-gradient(ellipse at center, rgba(56,189,248,0.04), transparent 70%),
    #0a0e16;
  border: 1px solid var(--panel-light);
  border-radius: 12px;
  overflow: hidden;
}
.anim-stage svg {
  display: block;
  width: 100%;
  height: auto;
}
.anim-controls {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px;
}
.anim-btn {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid #475569;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.anim-btn:hover { background: #2a3344; border-color: var(--accent); }
.anim-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.anim-btn.play { background: rgba(56,189,248,0.18); border-color: var(--accent); }
.anim-progress {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
}
.anim-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--panel-light);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}
.anim-dot:hover { background: #475569; }
.anim-dot.done { background: var(--accent); }
.anim-dot.current {
  background: var(--accent);
  transform: scale(1.4);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.25);
}
.step-counter {
  font-size: 0.82em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ====== Animation primitives (SVG) ====== */
.box {
  fill: var(--panel-2);
  stroke: var(--panel-light);
  stroke-width: 1.5;
  transition: all 0.5s ease;
}
.box.active { stroke: var(--accent); }
.box.good { stroke: var(--good); }
.box.bad { stroke: var(--bad); }
.label {
  fill: var(--text);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.label.small { font-size: 9px; }
.label.muted { fill: var(--muted); }
.label.accent { fill: var(--accent); }
.label.good { fill: var(--good); }
.label.bad { fill: var(--bad); }
.arrow {
  stroke: var(--muted);
  stroke-width: 1.6;
  fill: none;
  opacity: 0;
  transition: opacity 0.5s, stroke 0.4s;
  marker-end: url(#arrowhead);
}
.arrow.show { opacity: 1; }
.arrow.active { stroke: var(--accent); }

/* Pulse for active elements */
@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 0px rgba(56,189,248,0)); }
  50% { filter: drop-shadow(0 0 6px rgba(56,189,248,0.65)); }
}
.pulse { animation: pulseGlow 1.6s ease-in-out infinite; }

/* Fade entering */
.svg-fade {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.svg-fade.in { opacity: 1; }

/* ====== Module index cards ====== */
.module-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
a.module-card {
  background: var(--panel);
  border: 1px solid var(--panel-light);
  border-radius: 14px;
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}
a.module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border-color: var(--accent);
}
a.module-card.disabled {
  cursor: default;
  opacity: 0.5;
}
a.module-card.disabled:hover {
  transform: none;
  border-color: var(--panel-light);
}
a.module-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
a.module-card.disabled::before {
  background: var(--panel-light);
}
.module-card .num {
  font-size: 0.72em;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.module-card h3 {
  margin: 0 0 8px; font-size: 1.08em; font-weight: 700;
  line-height: 1.3;
}
.module-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88em; line-height: 1.55;
}
.module-card .meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 0.75em; color: var(--muted);
}
.module-card .badge {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-light);
  padding: 2px 8px; border-radius: 999px;
}
.module-card .badge.ready { background: rgba(80,200,120,0.15); color: #4ade80; border-color: rgba(80,200,120,0.4); }
.module-card .badge.soon { background: rgba(243,156,18,0.15); color: #fbbf24; border-color: rgba(243,156,18,0.4); }

/* ====== Quick TOC ====== */
.toc {
  background: var(--panel);
  border: 1px solid var(--panel-light);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 32px;
}
.toc h3 {
  margin: 0 0 12px;
  font-size: 0.95em;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.toc ol {
  margin: 0; padding-left: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 24px;
}
.toc ol a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.92em;
}
.toc ol a:hover { color: var(--accent); }

/* ====== YAML / code blocks ====== */
.codeblock {
  background: #0a0e16;
  border: 1px solid var(--panel-light);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82em;
  color: #e2e8f0;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}
.codeblock .k { color: #38bdf8; }
.codeblock .v { color: #fbbf24; }
.codeblock .c { color: #64748b; font-style: italic; }

/* ====== Responsive ====== */
@media (max-width: 720px) {
  body { padding-left: 50px; }
  .rail { width: 50px; }
  .rail-brand { width: 36px; height: 36px; }
  .rail-link { width: 38px; height: 38px; font-size: 1.1em; }
  header.page-header { padding: 16px 18px; }
  header.page-header h1 { font-size: 1.2em; }
  main { padding: 22px 16px 56px; }
  section.topic > h2 { font-size: 1.25em; }
  .cards { grid-template-columns: 1fr 1fr; }
  .card { height: 180px; }
  .card .q { font-size: 0.92em; }
  .card .a { font-size: 0.82em; }
}
@media (max-width: 460px) {
  .cards { grid-template-columns: 1fr; }
}
