/* ==========================================================================
   Gravity is Light — the DFD guide.
   Builds on /assets/dfd.css (tokens, nav, buttons, cosmic hero).
   ========================================================================== */

.gd-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, #c47a1c, #f2b45a);
  z-index: 60;
  pointer-events: none;
}

/* Chapter rail */
.gd-rail {
  position: fixed;
  left: max(16px, calc((100vw - var(--container)) / 2 - 150px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: grid;
  gap: 14px;
  list-style: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s var(--ease);
}
.gd-rail.is-on { opacity: 1; pointer-events: auto; }
.gd-rail a { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); text-decoration: none; }
.gd-rail a::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--ink-3); transition: all .3s var(--ease); }
.gd-rail a span { opacity: 0; transform: translateX(-4px); transition: all .3s var(--ease); white-space: nowrap; }
.gd-rail:hover a span, .gd-rail a[aria-current="true"] span { opacity: 1; transform: none; }
.gd-rail a[aria-current="true"] { color: var(--ink); }
.gd-rail a[aria-current="true"]::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
@media (max-width: 1380px) { .gd-rail { display: none; } }

/* Hero tweaks */
.gd-hero .cosmic__title { max-width: 9ch; }
.gd-chapters { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.gd-chapters a {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; text-decoration: none;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.gd-chapters a:hover { border-color: var(--line-strong); color: var(--ink); }
.gd-chapters b { font-family: var(--font-mono); font-weight: 400; font-size: 11px; color: var(--accent); }

/* Chapter heads */
.gd-chapter { position: relative; }
.gd-chead { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 28px; align-items: end; margin-bottom: clamp(28px, 5vh, 52px); }
.gd-roman { font-family: var(--font-display); font-style: italic; font-size: clamp(4rem, 10vw, 8rem); line-height: .8; color: var(--accent); opacity: .9; }
.gd-chead .eyebrow { margin-bottom: 10px; }
.gd-chead h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.4rem, 5.4vw, 4.4rem); line-height: 1; letter-spacing: -0.02em; }
.gd-chead h2 em { color: var(--ink-2); }
@media (max-width: 640px) { .gd-chead { grid-template-columns: 1fr; } .gd-roman { font-size: 3.6rem; } }

.gd-prose { max-width: 42rem; font-size: 1.125rem; line-height: 1.7; color: var(--ink-2); }
.gd-prose p + p { margin-top: 16px; }
.gd-prose strong { color: var(--ink); font-weight: 500; }
.gd-h3 { margin: clamp(56px, 9vh, 96px) 0 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.9rem, 3.4vw, 2.7rem); line-height: 1.05; letter-spacing: -0.015em; }
.gd-h3 + .gd-prose { margin-top: 16px; }

/* Figures */
.gd-figure { margin: 32px 0 0; padding: clamp(18px, 2.6vw, 28px); border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--bg-elev); box-shadow: var(--shadow-md); }
.gd-figure figcaption { margin-top: 14px; font-size: 13px; color: var(--ink-3); line-height: 1.55; }
.gd-figure figcaption b { color: var(--ink-2); font-weight: 500; }
.gd-fighead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; }
.gd-fighead h4 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.gd-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.gd-tab { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); font: 500 13px var(--font-sans); cursor: pointer; transition: all .2s var(--ease); }
.gd-tab:hover { border-color: var(--line-strong); color: var(--ink); }
.gd-tab[aria-pressed="true"] { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }
.gd-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; list-style: none; font-size: 12.5px; color: var(--ink-2); }
.gd-legend li { display: inline-flex; align-items: center; gap: 8px; }
.gd-key { display: inline-block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink-3); }
.gd-key--obs { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.gd-key--newton { background: repeating-linear-gradient(90deg, var(--ink-3) 0 4px, transparent 4px 7px); }
.gd-key--dfd { background: var(--series-accent); height: 2.5px; }
.gd-plot { margin-top: 12px; width: 100%; }
.gd-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.gd-plot text { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-3); }
.gd-plot .grid line { stroke: var(--grid); shape-rendering: crispEdges; }
.gd-plot .axis line { stroke: var(--axis); shape-rendering: crispEdges; }
.gd-plot .obs { fill: var(--ink); stroke: var(--bg-elev); stroke-width: 1.5; }
.gd-plot .err { stroke: var(--ink); stroke-width: 1.2; opacity: .55; }
.gd-plot .newton { fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-dasharray: 5 4; }
.gd-plot .dfd { fill: none; stroke: var(--series-accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; transition: opacity .5s var(--ease); }
.gd-plot .dfd.is-hidden { opacity: 0; }
.gd-plot .lbl { fill: var(--ink-2); font-size: 11px; }
.gd-plot .lbl--dfd { fill: var(--ink); font-weight: 500; }
.gd-controls { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }

/* Timeline */
.gd-timeline { margin-top: 36px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); }
@media (max-width: 760px) { .gd-timeline { grid-template-columns: 1fr 1fr; } }
.gd-timeline li { list-style: none; position: relative; padding: 22px 16px 0 0; }
.gd-timeline li::before { content: ""; position: absolute; top: -5px; left: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.gd-timeline b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 2rem; line-height: 1; letter-spacing: -0.01em; }
.gd-timeline span { display: block; margin-top: 8px; font-size: 14px; color: var(--ink-2); line-height: 1.45; }

/* Donut */
.gd-budget { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 32px; align-items: center; }
@media (max-width: 720px) { .gd-budget { grid-template-columns: 1fr; } }
.gd-donut svg { width: 100%; height: auto; display: block; }
.gd-donut .seg { fill: none; stroke-width: 26; }
.gd-donut text { font-family: var(--font-sans); fill: var(--ink); }
.gd-budget-list { list-style: none; display: grid; gap: 14px; }
.gd-budget-list li { display: grid; grid-template-columns: auto 64px minmax(0, 1fr); gap: 14px; align-items: baseline; font-size: 15px; color: var(--ink-2); }
.gd-budget-list i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; transform: translateY(1px); }
.gd-budget-list b { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.03em; color: var(--ink); }

/* Equation duo */
.gd-eqs { margin-top: 32px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 700px) { .gd-eqs { grid-template-columns: 1fr; } }
.gd-eq { padding: 28px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-elev); }
.gd-eq .principle__math { font-size: clamp(2.4rem, 4vw, 3.2rem); }
.gd-eq p { margin-top: 14px; color: var(--ink-2); font-size: 15.5px; line-height: 1.6; }

/* Light lab */
.gd-lab { position: relative; margin-top: 12px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: radial-gradient(900px 400px at 60% 50%, #111522, #06070c 70%); touch-action: none; }
.gd-lab canvas { display: block; width: 100%; height: clamp(280px, 42vw, 440px); cursor: grab; }
.gd-lab canvas:active { cursor: grabbing; }
.gd-lab__hint { position: absolute; left: 14px; top: 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: rgba(241, 239, 233, .55); pointer-events: none; }
.gd-range { display: inline-flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--ink-2); }
.gd-range input[type="range"] { width: min(260px, 60vw); accent-color: var(--accent); }
.gd-range output { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); min-width: 7ch; }

/* μ panel */
.gd-mu { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: center; }
@media (max-width: 820px) { .gd-mu { grid-template-columns: 1fr; } }
.gd-mu__readout { display: grid; gap: 12px; }
.gd-mu__big { font-family: var(--font-display); font-style: italic; font-size: clamp(2.2rem, 4vw, 3rem); line-height: 1; }
.gd-mu__regime { font-size: 15px; color: var(--ink-2); line-height: 1.55; }
.gd-mu .curve { fill: none; stroke: var(--series-accent); stroke-width: 2.5; }
.gd-mu .guide { stroke: var(--ink-3); stroke-dasharray: 3 4; }
.gd-mu .marker { fill: var(--accent); stroke: var(--bg-elev); stroke-width: 2; }

/* Callout */
.gd-callout { margin-top: 36px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: center; padding: clamp(22px, 3vw, 32px); border-radius: var(--radius-lg); background: radial-gradient(120% 100% at 0% 0%, var(--accent-soft), transparent 60%), var(--bg-elev); border: 1px solid var(--line); }
.gd-callout__n { font-size: clamp(3.6rem, 8vw, 5.6rem); font-weight: 600; letter-spacing: -0.05em; line-height: .9; color: var(--accent-ink); }
.gd-callout p { font-size: 1.05rem; color: var(--ink-2); line-height: 1.6; }
.gd-callout strong { color: var(--ink); font-weight: 500; }
@media (max-width: 560px) { .gd-callout { grid-template-columns: 1fr; } }

/* Tests grid */
.gd-tests { margin-top: 28px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .gd-tests { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .gd-tests { grid-template-columns: 1fr; } }
.gd-test { padding: 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-elev); }
.gd-test__h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gd-test__h h4 { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.gd-pass { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; background: rgba(52, 168, 110, .12); color: #2f9e67; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; }
:root[data-theme="dark"] .gd-pass { color: #4fd49a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .gd-pass { color: #4fd49a; } }
.gd-test p { margin-top: 8px; font-size: 14px; color: var(--ink-2); line-height: 1.55; }

/* α */
.gd-alpha { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: center; }
@media (max-width: 880px) { .gd-alpha { grid-template-columns: 1fr; } }
.gd-alpha__value { font-family: var(--font-sans); font-weight: 600; font-size: clamp(2.2rem, 5.4vw, 4rem); letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.gd-alpha__value .dim { color: var(--ink-3); }
.gd-alpha__cmp { margin-top: 14px; display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.gd-alpha__cmp span { font-family: var(--font-mono); color: var(--ink); }
.gd-quote { margin: 28px 0 0; padding-left: 20px; border-left: 2px solid var(--accent); font-family: var(--font-display); font-style: italic; font-size: 1.6rem; line-height: 1.3; color: var(--ink); max-width: 36rem; }
.gd-quote cite { display: block; margin-top: 8px; font-family: var(--font-sans); font-style: normal; font-size: 13px; color: var(--ink-3); }

/* Mass ladder */
.gd-ladder svg { display: block; width: 100%; height: auto; }
.gd-ladder text { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-3); }
.gd-ladder .tick line { stroke: var(--grid); }
.gd-ladder .rung { fill: var(--series-accent); stroke: var(--bg-elev); stroke-width: 2; }
.gd-ladder .rung-lbl { font-family: var(--font-display); font-style: italic; font-size: 17px; fill: var(--ink); }
.gd-ladder .lepton { fill: var(--ink); }

/* Cosmos cards */
.gd-cards { margin-top: 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .gd-cards { grid-template-columns: 1fr; } }
.gd-card { padding: 26px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-elev); }
.gd-card__k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.gd-card h4 { margin: 12px 0 0; font-family: var(--font-display); font-weight: 400; font-size: 1.7rem; line-height: 1.1; letter-spacing: -0.01em; }
.gd-card__v { margin-top: 14px; font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; color: var(--accent-ink); }
.gd-card p { margin-top: 10px; color: var(--ink-2); font-size: 15px; line-height: 1.6; }

.gd-compare { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 760px) { .gd-compare { grid-template-columns: 1fr; } .gd-compare__arrow { transform: rotate(90deg); justify-self: center; } }
.gd-compare__col { padding: 24px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-elev); }
.gd-compare__col h4 { margin: 0 0 14px; font-size: 13px; font-family: var(--font-mono); font-weight: 400; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.gd-compare__col ul { list-style: none; display: grid; gap: 10px; }
.gd-compare__col li { font-size: 15px; color: var(--ink-2); line-height: 1.5; }
.gd-compare__col li b { color: var(--ink); font-weight: 500; }
.gd-compare__arrow { align-self: center; font-size: 28px; color: var(--accent); }

/* Falsification map */
.gd-kill { margin-top: 28px; display: grid; gap: 10px; counter-reset: k; }
.gd-kill li { list-style: none; display: grid; grid-template-columns: 3rem minmax(0, 1fr) minmax(0, 0.9fr); gap: 18px; align-items: baseline; padding: 20px 22px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-elev); }
.gd-kill li::before { counter-increment: k; content: counter(k, decimal-leading-zero); font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.gd-kill h4 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.gd-kill p { margin-top: 6px; font-size: 14.5px; color: var(--ink-2); line-height: 1.55; }
.gd-kill .dies { font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.gd-kill .dies b { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #d0574f; margin-bottom: 4px; }
@media (max-width: 760px) { .gd-kill li { grid-template-columns: 2.4rem minmax(0, 1fr); } .gd-kill .dies { grid-column: 2; } }

.gd-first { margin-top: 28px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .gd-first { grid-template-columns: 1fr; } }
.gd-first div { padding: 22px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-elev); text-align: center; }
.gd-first b { display: block; font-size: 2.4rem; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.gd-first span { display: block; margin-top: 8px; font-size: 13px; color: var(--ink-3); }

/* Closing */
.gd-close { text-align: center; }
.gd-close h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.8rem, 7vw, 5.6rem); line-height: .98; letter-spacing: -0.02em; max-width: 16ch; margin: 0 auto; }
.gd-close h2 em { color: var(--accent-ink); }
.gd-close p { margin: 22px auto 0; max-width: 36rem; font-size: 1.1rem; color: var(--ink-2); line-height: 1.6; }
.gd-close .btn-row { justify-content: center; margin-top: 32px; }
.gd-note { margin-top: 28px; font-size: 13px; color: var(--ink-3); }
