/* ============================================================
   DS MIDTERM — components
   ============================================================ */

/* ---------- top bar / progress ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 90;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  background: linear-gradient(rgba(7, 10, 18, 0.88), rgba(7, 10, 18, 0.62));
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: min(100% - 2.4rem, 1320px);
  margin-inline: auto;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  font-family: var(--font-disp);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: #fff;
  white-space: nowrap;
}

.brand-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 4px rgba(79, 216, 232, 0.16), 0 0 18px var(--cyan);
}

.navlinks {
  display: flex;
  gap: 0.18rem;
  margin-left: auto;
  min-width: 0;
  flex: 0 1 auto;
  justify-content: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.2rem;
}
.navlinks.is-scroll {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
}
.navlinks::-webkit-scrollbar { display: none; }

.navlinks a {
  font-size: 0.755rem;
  font-weight: 500;
  color: var(--ink-3);
  padding: 0.34rem 0.52rem;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
  border: 1px solid transparent;
}

.navlinks a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }

.navlinks a.active {
  color: #04121a;
  background: linear-gradient(120deg, var(--cyan), #8ff0c8);
  border-color: transparent;
  font-weight: 600;
}

.progress {
  position: fixed;
  top: 60px; left: 0;
  height: 2px;
  width: 100%;
  z-index: 91;
  background: transparent;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--violet) 55%, var(--amber));
  box-shadow: 0 0 14px rgba(79, 216, 232, 0.7);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 8rem 0 6rem;
  overflow: hidden;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.hero-inner { position: relative; z-index: 2; text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(79, 216, 232, 0.32);
  border-radius: 99px;
  background: rgba(79, 216, 232, 0.07);
  margin-bottom: 1.6rem;
}

.hero h1 {
  font-size: clamp(2.6rem, 7.4vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
  margin-bottom: 1.2rem;
}

.hero-sub {
  max-width: 620px;
  margin: 0 auto 2.2rem;
  font-size: 1.06rem;
  color: var(--ink-2);
}

.hero-meta {
  display: flex;
  gap: 2.2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--line);
}

.hero-meta div { text-align: left; }
.hero-meta dt {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 0.18rem;
}
.hero-meta dd {
  margin: 0;
  font-family: var(--font-disp);
  font-size: 0.94rem;
  color: var(--ink);
}

.scroll-cue {
  margin-top: 2.6rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.scroll-cue span.line {
  width: 1px; height: 46px;
  background: linear-gradient(var(--cyan), transparent);
}

/* hero CTA + line reveal */
.hero-line { display: block; }

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.78rem 1.5rem;
  border-radius: 99px;
  font-family: var(--font-disp);
  font-size: 0.92rem;
  font-weight: 600;
  color: #04121a;
  background: linear-gradient(115deg, #6fe6f2, #a99bff 55%, #ffc078);
  box-shadow: 0 18px 44px -18px rgba(79, 216, 232, 0.65);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.hero-cta:hover {
  color: #04121a;
  transform: translateY(-2px);
  box-shadow: 0 22px 52px -16px rgba(155, 123, 246, 0.7);
}

/* ---------- section head ---------- */
.unit-head { margin-bottom: 2.6rem; }

.unit-index {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.unit-num {
  font-family: var(--font-disp);
  font-size: clamp(2.6rem, 5vw, 4.1rem);
  font-weight: 700;
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1.4px rgba(140, 165, 220, 0.36);
}

.unit-tag {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  border-left: 2px solid var(--cyan);
  padding-left: 0.6rem;
  line-height: 1.5;
}

.unit-head h2 { margin-bottom: 0.6rem; }
.unit-head .lead { max-width: 74ch; }

.rule {
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
  margin: 1.6rem 0;
}

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.45rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.28s var(--ease), transform 0.28s var(--ease),
              background 0.28s var(--ease);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.card:hover {
  border-color: var(--line-strong);
  background: rgba(26, 36, 64, 0.72);
  transform: translateY(-3px);
}
.card:hover::before { opacity: 1; }

.card h4 { margin-bottom: 0.45rem; color: #fff; }
.card p:last-child { margin-bottom: 0; }
.card .small:last-child { margin-bottom: 0; }

.card-accent { border-left: 2px solid var(--cyan); }
.card-accent.v { border-left-color: var(--violet); }
.card-accent.a { border-left-color: var(--amber); }
.card-accent.r { border-left-color: var(--rose); }
.card-accent.g { border-left-color: var(--green); }

.card-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(79, 216, 232, 0.1);
  border: 1px solid rgba(79, 216, 232, 0.24);
  margin-bottom: 0.85rem;
  font-size: 1.05rem;
}

.card-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-4);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.24rem 0.6rem;
  border-radius: 7px;
  background: rgba(140, 165, 220, 0.1);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}

.chip.cy { color: #a9f2fa; background: rgba(79, 216, 232, 0.12); border-color: rgba(79, 216, 232, 0.3); }
.chip.vi { color: #d3c6ff; background: rgba(155, 123, 246, 0.14); border-color: rgba(155, 123, 246, 0.32); }
.chip.am { color: #ffd9a6; background: rgba(255, 180, 84, 0.13); border-color: rgba(255, 180, 84, 0.32); }
.chip.ro { color: #ffc0cf; background: rgba(255, 111, 145, 0.13); border-color: rgba(255, 111, 145, 0.3); }
.chip.gr { color: #a9f5d1; background: rgba(92, 225, 166, 0.12); border-color: rgba(92, 225, 166, 0.3); }

.chiprow { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ---------- lists ---------- */
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean > li {
  position: relative;
  padding-left: 1.35rem;
  margin-bottom: 0.6rem;
  color: var(--ink-2);
}
ul.clean > li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62em;
  width: 6px; height: 6px;
  border-radius: 2px;
  background: var(--cyan);
  transform: rotate(45deg);
}
ul.clean.vi > li::before { background: var(--violet); }
ul.clean.am > li::before { background: var(--amber); }
ul.clean.gr > li::before { background: var(--green); }
ul.clean.ro > li::before { background: var(--rose); }

ol.steps {
  counter-reset: s;
  list-style: none;
  padding: 0;
  margin: 0;
}
ol.steps > li {
  counter-increment: s;
  position: relative;
  padding-left: 2.35rem;
  margin-bottom: 0.85rem;
  color: var(--ink-2);
}
ol.steps > li::before {
  content: counter(s);
  position: absolute;
  left: 0; top: 0.08em;
  width: 1.55rem; height: 1.55rem;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(79, 216, 232, 0.1);
  border: 1px solid rgba(79, 216, 232, 0.3);
}

/* ---------- callout ---------- */
.callout {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 1.05rem 1.15rem 1.05rem 1.35rem;
  background: rgba(79, 216, 232, 0.055);
  border: 1px solid rgba(79, 216, 232, 0.2);
  color: var(--ink-2);
  font-size: 0.94rem;
}
.callout::before {
  content: "";
  position: absolute;
  left: 0; top: 0.9rem; bottom: 0.9rem;
  width: 2px;
  border-radius: 2px;
  background: var(--cyan);
}
.callout strong { color: #fff; }
.callout.warn { background: rgba(255, 180, 84, 0.06); border-color: rgba(255, 180, 84, 0.24); }
.callout.warn::before { background: var(--amber); }
.callout.tip { background: rgba(92, 225, 166, 0.055); border-color: rgba(92, 225, 166, 0.22); }
.callout.tip::before { background: var(--green); }
.callout.key { background: rgba(155, 123, 246, 0.07); border-color: rgba(155, 123, 246, 0.26); }
.callout.key::before { background: var(--violet); }
.callout p:last-child { margin-bottom: 0; }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(11, 16, 32, 0.6);
}

table.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.885rem;
  min-width: 520px;
}

table.dt th, table.dt td {
  padding: 0.72rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.dt thead th {
  font-family: var(--font-disp);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(79, 216, 232, 0.06);
  white-space: nowrap;
}

table.dt tbody tr:last-child td { border-bottom: 0; }
table.dt tbody tr:hover td { background: rgba(140, 165, 220, 0.045); }
table.dt td:first-child { color: #fff; font-weight: 500; }
table.dt code { font-size: 0.86em; }

/* ---------- code ---------- */
pre.code {
  margin: 0;
  padding: 1.05rem 1.15rem;
  background: #080d1a;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.795rem;
  line-height: 1.72;
  color: #c9d6f0;
  tab-size: 4;
}
pre.code .c { color: #5f7194; font-style: italic; }
pre.code .k { color: #c39bff; }
pre.code .s { color: #ffb98a; }
pre.code .n { color: #7fe3c0; }
pre.code .f { color: #7cc7ff; }
pre.code .o { color: #8fa2c4; }

.code-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: rgba(140, 165, 220, 0.07);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
}
.code-head + pre.code { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.code-head .dot {
  position: static;
  transform: none;
  flex: 0 0 auto;
  width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4);
}
.code-head .dot.r { background: #ff6f91; }
.code-head .dot.y { background: #ffb454; }
.code-head .dot.g { background: #5ce1a6; }

/* ---------- formula ---------- */
.formula {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1.15rem 1rem;
  background: linear-gradient(180deg, rgba(155, 123, 246, 0.07), rgba(79, 216, 232, 0.04));
  border: 1px solid rgba(155, 123, 246, 0.22);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #e6ecfb;
  text-align: center;
}
.formula .frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.18rem;
  line-height: 1.3;
}
.formula .frac .num { padding: 0 0.35rem 0.15rem; border-bottom: 1px solid rgba(230, 236, 251, 0.5); }
.formula .frac .den { padding: 0.15rem 0.35rem 0; }
.formula sub, .formula sup { font-size: 0.68em; }
.formula .op { color: var(--violet); }
.formula .lbl { color: var(--ink-3); font-size: 0.82em; }

/* ---------- stat tiles ---------- */
.stat {
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(11, 16, 32, 0.55);
}
.stat .v {
  font-family: var(--font-disp);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--cyan);
  margin-bottom: 0.3rem;
}
.stat .k {
  font-size: 0.73rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* ---------- viz panel ---------- */
.viz {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(79, 216, 232, 0.055), transparent 62%),
    rgba(9, 13, 26, 0.72);
  padding: 1.3rem 1.35rem 1.5rem;
  overflow: hidden;
}

.viz-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.viz-note { margin-left: auto; }
.viz-title {
  font-family: var(--font-disp);
  font-size: 0.94rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}
.viz-note { font-size: 0.73rem; color: var(--ink-4); }
.viz svg { width: 100%; height: auto; display: block; overflow: visible; }

.viz-caption {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--line);
  font-size: 0.815rem;
  color: var(--ink-3);
  line-height: 1.62;
}

.legend {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: 0.755rem;
  color: var(--ink-3);
  margin-top: 0.75rem;
}
.legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 0.4rem;
  vertical-align: -1px;
}

/* ---------- figure (source material) ---------- */
figure.fig {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #060a14;
}
figure.fig img {
  width: 100%;
  height: auto;
  display: block;
}
figure.fig figcaption {
  padding: 0.8rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  background: rgba(140, 165, 220, 0.05);
}
figure.fig figcaption b { color: var(--ink-2); font-weight: 600; }

/* ---------- reveal defaults ---------- */
.reveal { will-change: transform, opacity; }

/* ---------- footer ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  padding: 3rem 0 3.4rem;
  background: linear-gradient(rgba(7, 10, 18, 0), rgba(4, 6, 12, 0.9));
}
.foot-grid {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.foot-grid p { margin-bottom: 0.3rem; }

@media (max-width: 1200px) {
  .quiz-open.top {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    flex: 0 0 auto;
  }
  .quiz-open.top span { display: none; }
  .quiz-open.top svg { width: 15px; height: 15px; }
}

@media (max-width: 820px) {
  .navlinks { display: none; }
  .hero-meta { gap: 1.4rem; }
  .hero-meta div { min-width: 42%; }
}

/* unit picker (mobile) */
.unit-jump {
  display: none;
  margin-left: auto;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(20, 28, 51, 0.9);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0.42rem 1.7rem 0.42rem 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%),
                    linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
@media (max-width: 820px) {
  .unit-jump { display: block; }
}
