/* The Circadian Research Map — editorial, restrained.
   Type scale: 12 / 13 / 15 / 18 / 22 / 30 / 42.  Base spacing unit: 8px. */

:root {
  --paper: #f6f4ef;
  --surface: #fffdf8;
  --ink: #1d1c1a;
  --ink-2: #57534c;
  --ink-3: #8c877d;
  --line: #e3ded3;
  --line-2: #d3cdbe;
  --night: #2b3a55;

  --c-cardiology: #b4434f;
  --c-oncology: #7d6bb0;
  --c-metabolic: #b97e34;
  --c-immunology: #2f8f7f;
  --c-neurology: #41699f;

  --display: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 24px; padding: 28px 40px 20px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .wordmark { font-family: var(--display); font-size: clamp(22px, 6vw, 30px); line-height: 1.08; letter-spacing: -0.01em; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--ink-2); font-size: 14px; max-width: 560px; margin: 6px 0 0; }
.topbar .right { text-align: right; color: var(--ink-3); font-size: 12px; }
.topbar .mode { display: inline-block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 8px; }
.topbar .mode.internal { color: var(--c-cardiology); border-color: var(--c-cardiology); }

/* ---------- layout (rail on the right) ---------- */
.app { display: grid; grid-template-columns: 1fr 300px; gap: 0; align-items: stretch; min-height: calc(100vh - 92px); max-width: 1400px; margin: 0 auto; }
.stage { grid-column: 1; }
.rail { grid-column: 2; }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } .stage, .rail { grid-column: 1; } }

.rail { border-left: 1px solid var(--line); padding: 28px 24px; }
@media (max-width: 860px) { .rail { border-left: none; border-top: 1px solid var(--line); } }
.rail h2 { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; font-weight: 600; }
.grpbtn { display: inline-block; margin: 0 0 16px; font-size: 12px; font-weight: 600; color: var(--ink-2);
  background: none; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 11px; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease; }
.grpbtn:hover { background: rgba(0,0,0,0.04); border-color: var(--ink-3); }

.toggles { display: flex; flex-direction: column; gap: 2px; margin-bottom: 28px; }
.toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; cursor: pointer; text-align: left;
  padding: 8px 8px; border-radius: 6px; font: inherit; color: var(--ink);
  transition: background 120ms ease;
}
.toggle:hover { background: rgba(0,0,0,0.035); }
.toggle .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; transition: transform 120ms ease; }
.toggle .name { flex: 1; font-size: 14px; }
.toggle .n { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 12px; }
.toggle.off { color: var(--ink-3); }
.toggle.off .sw { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--line-2); }

.note { color: var(--ink-3); font-size: 12.5px; line-height: 1.5; }
.note .key { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.note .keyrow { display: flex; align-items: center; gap: 9px; }
.note .kdot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; }
.note .kdot.solid { background: var(--ink-2); }
.note .kdot.hollow { background: transparent; box-shadow: inset 0 0 0 2px var(--ink-2); }
.note .kdot.hub { background: transparent; box-shadow: inset 0 0 0 1px var(--ink-3); border: 1px dashed var(--ink-3); }

/* ---------- clock stage ---------- */
.stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px; }
.clockwrap { width: 100%; max-width: min(780px, 84vh); }
.clock { width: 100%; height: auto; display: block; overflow: visible; }

.ring { fill: none; stroke: var(--line-2); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.ring.hl { stroke: var(--ink-3); }
.tick { stroke: var(--line-2); }
.spoke { stroke: var(--line); stroke-dasharray: 2 5; }
.hourlabel { fill: var(--ink-2); font-size: 11px; font-family: Helvetica, var(--sans); font-weight: 700; }
.hubsketch { pointer-events: none; opacity: 0; transition: opacity 320ms ease; }
.hubsketch.show { opacity: 0.92; }
.nightband { fill: var(--night); opacity: 0.05; }
.node { cursor: pointer; }
.node path { transition: opacity 160ms ease; stroke-linejoin: round; stroke-linecap: round; }
.node.human path { stroke: none; }   /* no outline unless active/clicked */
.node.dim path { opacity: 0.14; }
.node.active.human path { stroke: var(--hl, var(--ink)); stroke-width: 3.5; }
.node:hover path { opacity: 0.9; }

/* load reveal: rings draw in first, then dots */
@keyframes nodein { from { opacity: 0; } to { opacity: 1; } }
.intro-ring { animation: nodein 400ms ease both; }
.node.intro path { animation: nodein 320ms ease both; animation-delay: 0.45s; }

/* ---------- hover card ---------- */
.card {
  position: absolute; z-index: 20; width: 320px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(40,34,20,0.14); padding: 16px 16px 12px;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}
.card.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.card .ctop { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; flex-wrap: wrap; }
.card .cdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.card .csys { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); flex: 1; }
.card .basis { font-size: 10.5px; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.card .basis.human { color: #2f6d4f; background: #e6f0e8; }
.card .basis.mouse { color: var(--ink-2); background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
.card .bnote { font-size: 12px; color: var(--ink-3); font-style: italic; margin: 0 0 10px; line-height: 1.4; }
.card h3 { margin: 2px 0 2px; font-size: 17px; font-family: var(--display); font-weight: 700; line-height: 1.2; }
.card .cmeta { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 10px; }
.card .cmeta b { color: var(--ink); font-weight: 600; }
.card .cdetail { font-size: 13px; color: var(--ink-2); margin: 0 0 10px; }
.card .papers { display: flex; flex-direction: column; gap: 1px; max-height: 230px; overflow-y: auto; margin: 0 -6px; }
.card .paper {
  display: block; text-decoration: none; padding: 6px 6px; border-radius: 6px;
  font-size: 12.5px; line-height: 1.35; color: var(--ink);
  transition: background 110ms ease;
}
.card .paper:hover { background: rgba(0,0,0,0.04); }
.card .paper .pjy { color: var(--ink-3); font-size: 11.5px; }
.card .paper .star { color: var(--ink-3); }
.card .cmore { font-size: 11.5px; color: var(--ink-3); padding: 6px; }
.card .readart { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 600; text-decoration: none; }

/* ---------- article pages ---------- */
.article-page { background: var(--surface); }
.prose { max-width: 720px; margin: 0 auto; padding: 24px 24px 90px; }
.prose .kicker { letter-spacing: 0.18em; text-transform: uppercase; font-size: 11px; color: var(--ink-3); }
.prose h1 { font-family: var(--display); font-size: 34px; line-height: 1.1; letter-spacing: -0.01em; font-weight: 700; }
.prose h2 { font-family: var(--display); font-size: 22px; margin-top: 34px; font-weight: 700; }
.prose h3 { font-size: 16px; color: var(--ink-2); }
.prose p, .prose li { color: var(--ink); }
.prose a { color: var(--c-neurology); }
.prose blockquote { border-left: 3px solid var(--line-2); margin: 16px 0; padding: 4px 16px; color: var(--ink-2); }
.prose .tablewrap { overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 16px 0; }
.prose td { border: 1px solid var(--line); padding: 7px 10px; }
.prose tr:first-child td { color: var(--ink-2); font-weight: 700; background: rgba(0,0,0,0.02); }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 40px 0 16px; }
.src-note { font-size: 12px; color: var(--ink-3); }
.back { display: inline-block; padding: 24px 24px 0; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .topbar { padding: 18px 18px 12px; gap: 10px; }
  .topbar .sub { font-size: 13px; }
  .rail { padding: 20px 16px; }
  .stage { padding: 12px 10px; }
  .clockwrap { max-width: 100%; }
  .card { width: min(340px, calc(100vw - 24px)); }
  .prose { padding: 20px 18px 70px; }
  .prose h1 { font-size: 27px; }
}

/* ===================== ZT/CT Atlas (zt.html) ===================== */
@font-face { font-family: "IMFell"; src: url("fonts/IMFellEnglish-Italic.ttf") format("truetype"); font-style: italic; font-display: swap; }
.zt-day { fill: #ddd08b; opacity: 0.5; }   /* light warm-yellow day tint (value pair with the darker night) */
.zt-night { fill: var(--night); opacity: 0.22; }
.zt-band { fill: none; stroke-width: 1.2; stroke-opacity: 0.32; transition: stroke-opacity 140ms ease, stroke-width 140ms ease; animation: ztfadein 800ms ease backwards; }
.zt-band.hl { stroke-opacity: 0.85; stroke-width: 2.2; }
.zt-tick { stroke: var(--line-2); }
.zt-hourlabel { fill: var(--ink-3); font-size: 11px; font-family: Helvetica, var(--sans); }
.zt-hourlabel.major { fill: var(--ink-2); font-weight: 700; font-size: 12px; }
.zt-cap { fill: var(--ink-3); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.zt-dot { cursor: pointer; transition: opacity 400ms ease; }
.zt-dot.hidden { opacity: 0; pointer-events: none; }
/* paper search: dim non-matches, pop the matches (reveals them even if a system is off/filtered) */
.zt-dot.searchdim { opacity: 0.05; }
.zt-dot.match { opacity: 1; pointer-events: auto; }
.zt-dot.match .zt-mark { transform: scale(2); stroke-width: 3; }
.zt-dot .zt-mark { stroke-linejoin: miter; transform-box: fill-box; transform-origin: center;
  transition: transform 160ms cubic-bezier(.34,1.56,.64,1), opacity 140ms ease;
  animation: ztfadein 460ms ease backwards; }
.zt-dot:hover .zt-mark { opacity: 0.96; transform: scale(1.3); }
.zt-dot.active .zt-mark { stroke-width: 3; transform: scale(1.3); }
.zt-dot.dim { opacity: 0.10; }
@keyframes ztfadein { from { opacity: 0; } to { opacity: 1; } }
.note .kg { width: 13px; height: 13px; flex: none; overflow: visible; }

.zt-sum { font-size: 13px; line-height: 1.5; color: var(--ink); margin: 8px 0 10px; }
.railcount { color: var(--ink-3); font-size: 12px; margin-top: 4px; }

/* control pills anchored to the chart zone TOP corners (scroll with the plot) */
.floatctl { position: absolute; left: 24px; top: 24px; z-index: 12;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.nullfloat { font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 13px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(40,34,20,0.08);
  transition: color 130ms ease, background 130ms ease, border-color 130ms ease; }
.nullfloat:hover { color: var(--ink); border-color: var(--ink-3); }
.nullfloat.on { color: var(--surface); background: var(--ink-2); border-color: var(--ink-2); }

.nulldot .zt-mark { animation: none; }   /* null dots start hidden; skip the entrance so no load flash */
.floatctl.right { left: auto; right: 24px; align-items: flex-end; }

/* day/night labels filling the empty space left and right of the circle */
.phaseside { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; pointer-events: none;
  font-family: "IMFell", var(--display); font-style: italic; color: var(--ink-3); font-size: 33px; line-height: 1.05; }
.phaseside.left { left: 16px; text-align: left; }
.phaseside.right { right: 30px; text-align: right; }
.phaseside em { display: inline-block; margin-top: 6px; font-size: 21px; opacity: 0.85; }
.phaseside .phdir { display: block; font-family: var(--sans); font-style: normal; font-weight: 700;
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }
/* when the side gap shrinks, drop the labels into the empty bottom corners instead of the circle */
@media (max-width: 1320px) {
  .phaseside { top: auto; bottom: 12px; transform: none; font-size: 25px; line-height: 1.02; }
  .phaseside.left { left: 14px; }
  .phaseside.right { right: 14px; }
  .phaseside em { margin-top: 4px; font-size: 17px; }
}

.howto { color: var(--ink-3); font-size: 12px; line-height: 1.5; margin-top: 16px; }
.papersearch { width: 100%; margin-top: 12px; padding: 8px 11px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); }
.papersearch::placeholder { color: var(--ink-3); }
.papersearch:focus { outline: none; border-color: var(--ink-3); }
.searchsuggest { margin-top: 4px; }
.sgrow { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-top: none; padding: 7px 10px; cursor: pointer; font: inherit; }
.sgrow:first-child { border-top: 1px solid var(--line); border-radius: 7px 7px 0 0; }
.sgrow:last-child { border-radius: 0 0 7px 7px; }
.sgrow:hover { background: rgba(0,0,0,0.04); }
.sgrow .sga { font-weight: 600; font-size: 11.5px; color: var(--ink); }
.sgrow .sgy { font-size: 11px; color: var(--ink-3); }
.sgrow .sgt { display: block; font-size: 11px; color: var(--ink-2); line-height: 1.3; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sgnone { padding: 7px 10px; font-size: 11.5px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 7px; }

.seerefs { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: none; border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 16px; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease; }
.seerefs:hover { background: rgba(0,0,0,0.04); border-color: var(--ink-3); color: var(--ink); }

.refs { max-width: 1400px; margin: 0 auto; padding: 40px 40px 100px; border-top: 1px solid var(--line); }
.refs:empty { display: none; }
.refs h2 { font-family: var(--display); font-size: 20px; margin: 0 0 18px; font-weight: 700; }
.refs h2 .rc { font-family: var(--sans); font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 8px; }
.reflist { column-width: 330px; column-gap: 30px; }
.ref { display: block; break-inside: avoid; margin: 0 0 12px; font-size: 12.5px; line-height: 1.45; color: #45464a; text-decoration: none; }
.ref:hover { color: #1f2023; }
.ref .ra { font-weight: 600; color: #2c2d30; }
.ref .rj { font-style: italic; }

/* teeny idle wiggle so the picture doesn't feel static (per-dot delay/duration desync it) */
.wig { transform-box: fill-box; transform-origin: center; animation: ztwiggle 5s ease-in-out infinite; }
@keyframes ztwiggle {
  0%   { transform: translate(0, 0); }
  30%  { transform: translate(1.9px, -1.6px); }
  60%  { transform: translate(-1.7px, 1.4px); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) { .wig { animation: none; } }
/* freeze only the hovered dot (its wiggle here, its shape-boil paused in JS) so it holds still to click */
.zt-dot.frozen .wig { animation-play-state: paused; }

/* touch devices: no idle wiggle (and the SMIL boil is skipped in JS) */
@media (pointer: coarse) { .wig { animation: none; } }

/* mobile: the hover card becomes a bottom sheet, and taps use tap-nearest */
@media (max-width: 700px) {
  .card { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-width: 100%;
    border-radius: 16px 16px 0 0; transform: translateY(115%); opacity: 1;
    box-shadow: 0 -6px 28px rgba(40,34,20,0.22); padding: 22px 18px max(26px, env(safe-area-inset-bottom));
    transition: transform 280ms cubic-bezier(.22,1,.36,1); }
  .card.show { transform: translateY(0); }
  .card::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 42px; height: 4px; border-radius: 2px; background: var(--line-2); }
  .card .zt-sum { font-size: 15px; }
  /* reserve a band above the dial so the two original button stacks (filters left,
     contribute right) sit above the ring instead of covering dots */
  .stage { padding-top: 84px; }
  .floatctl { top: 12px; left: 12px; }
  .floatctl.right { top: 12px; right: 12px; }
}
