/* ==========================================================
   THEME — "blueprint at night". The skin lives in this block;
   everything below consumes these variables.
   Two neutrals (paper, ink) and one accent (redline, spent
   only on milestones). All grays sit on the paper–ink axis.
   ========================================================== */
:root {
  --paper:   #0D1620;                    /* Prussian near-black paper */
  --ink:     #D8E3ED;                    /* pale drafting ink */
  --muted:   #8CA0B3;                    /* secondary text */
  --faint:   rgba(216, 227, 237, 0.18);  /* hairline rules */
  --grid:    rgba(216, 227, 237, 0.06);  /* year gridlines */
  --leader:  rgba(216, 227, 237, 0.55);  /* leader linework */
  --spine:   #D8E3ED;                    /* timeline spine */
  --redline: #E8593F;                    /* THE accent — milestones only */
  --card:    #121D29;                    /* node card face */
  --slot:    #0F1924;                    /* image placeholder fill */
  --scrim:   rgba(3, 7, 11, 0.62);

  --font-display: "Libre Franklin", system-ui, sans-serif;
  --font-body:    "Libre Franklin", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  --ppm: 120px;             /* pixels per month — timeline scale */
  --card-w: min(340px, calc(100vw - 36px)); /* the ONE card width — every node */
  --ink2: rgba(216, 227, 237, 0.84);        /* long-form text, on the paper–ink axis */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden; /* the track scrolls, not the page */
}

::selection { background: rgba(216, 227, 237, 0.22); }

/* ---------- header ---------- */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 26px 13px;
  background: var(--paper);
  border-bottom: 1px solid var(--faint);
}
.who .name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.who .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.header-actions { display: flex; gap: 8px; }
.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--faint);
  padding: 6px 12px;
  background: transparent;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}
.btn:hover { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.btn:focus-visible, .node:focus-visible, .sheet-close:focus-visible, .sheet-nav button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- scroll progress ---------- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 1px;
  width: 0;
  background: rgba(216, 227, 237, 0.55);
  z-index: 50;
}

/* ---------- the scrolling track ---------- */
#viewport {
  position: absolute;
  inset: 0;
  overflow: auto; /* vertical kicks in only when the lanes outgrow the window */
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: rgba(216, 227, 237, 0.25) transparent;
}
#viewport.dragging { cursor: grabbing; user-select: none; }
#track {
  position: relative;
  height: 100vh;
  /* width and final height set by JS from the date domain + lane packing */
}
#leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- nodes ---------- */
.node {
  position: absolute;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--faint);
  font-family: var(--font-body);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  transition: border-color 180ms ease;
}
.node:hover { border-color: rgba(216, 227, 237, 0.7); }

/* THE uniform card — every node, same component, same width;
   height grows to fit the complete description. No ellipsis,
   no clamping, no internal scrollbars, ever. */
.node.card { width: var(--card-w); }
.node.card .thumb {
  height: 84px;
  background: var(--slot);
  border-bottom: 1px solid var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
}
.node.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.node.card .card-body { padding: 10px 13px 11px; }
.node.card .card-title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}
.node.card .card-desc {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink2);
  overflow: visible;
}
.node.card .card-desc p { margin: 0; }
.node.card .card-desc p + .card-sect { margin-top: 7px; }
.card-sect {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1px;
}
.node.card .tblock {
  display: flex;
  border-top: 1px solid var(--faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.node.card .tblock span {
  padding: 4px 8px;
  border-right: 1px solid var(--faint);
}
.node.card .tblock span:last-child { border-right: 0; }

/* milestones ride the same card — the accent alone marks them out */
.node.card.milestone .card-title { color: var(--redline); }

/* year labels drawn by JS into the track */
.year-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 7px; /* sits beside its gridline, not through it */
}

/* ---------- expanded sheet ---------- */
#sheet-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 60;
  display: none;
}
#sheet-scrim.open { display: block; }

#sheet {
  position: fixed;
  z-index: 61;
  inset: 5vh 0;
  width: min(1080px, 88vw);
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--faint);
  padding: 6px;
  display: none;
  transform-origin: top left;
}
#sheet.open { display: block; }
#sheet .frame {
  border: 1px solid var(--faint);
  height: 100%;
  padding: 22px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.sheet-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.sheet-close {
  flex: none;
  width: 30px; height: 30px;
  border: 1px solid var(--faint);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}
.sheet-close:hover { border-color: var(--ink); background: var(--ink); color: var(--paper); }

.sheet-cols { display: flex; gap: 26px; flex: 1; }
.sheet-notes { flex: 1.25; min-width: 0; }
.sheet-notes h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 4px;
}
.sheet-notes h3:first-child { margin-top: 0; }
.sheet-notes p { font-size: 14px; line-height: 1.65; max-width: 62ch; }

.sheet-gallery {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.detail { border: 0; }
.detail .ph {
  border: 1px dashed rgba(216, 227, 237, 0.35);
  background: var(--slot);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.detail img { width: 100%; display: block; border: 1px solid var(--faint); }
.detail figcaption {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.sheet-nav { display: flex; gap: 8px; }
.sheet-nav button {
  font-family: var(--font-mono);
  font-size: 11.5px;
  border: 1px solid var(--faint);
  background: transparent;
  color: var(--ink);
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}
.sheet-nav button:hover { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.titleblock {
  display: flex;
  border: 1px solid var(--faint);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.titleblock span { padding: 4px 10px; border-right: 1px solid var(--faint); }
.titleblock span:last-child { border-right: 0; }

/* ---------- hint ---------- */
#hint {
  position: fixed;
  bottom: 12px;
  left: 26px;
  z-index: 40;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  background: var(--paper);
  padding: 2px 6px;
}

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;
    padding: 12px 16px 11px;
  }
  .who .name { font-size: 13.5px; }
  #hint { left: 16px; }
  .who .tag { display: none; }
  #sheet { inset: 0; width: 100%; margin: 0; padding: 5px; }
  #sheet .frame { padding: 16px 14px; }
  .sheet-cols { flex-direction: column; }
  .node.card .tblock { font-size: 9px; letter-spacing: 0; }
  .node.card .tblock span { white-space: nowrap; }
  :root { --ppm: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
