/* Timeline page. Horizontal on wide screens, vertical below 760px. */

.intro { padding-top: 12px; }
.intro h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 900; margin-bottom: .2em; }
.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 46rem; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; margin: 10px 0 0; color: var(--ink-2); font-size: .9rem; }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.dot-ring { background: var(--surface) !important; box-shadow: inset 0 0 0 3px var(--dot); }
.legend-band { display: inline-block; width: 26px; height: 12px; border-radius: 4px; }
.legend-band.winter { background: var(--winter); box-shadow: inset 0 0 0 1px var(--winter-edge); }
.legend-band.hype { background: var(--hype); box-shadow: inset 0 0 0 1px var(--hype-edge); }

/* ---------- filters ---------- */
.filters {
  margin-top: 20px; padding-top: 16px; padding-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: calc(1280px - 32px);
}
@media (max-width: 1311px) { .filters { margin-left: 16px; margin-right: 16px; } }
.filter-row { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend, .era-filter > legend { font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 0; }
.search-field { flex: 1 1 240px; }
.field input[type="search"], .field select {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-width: 0; width: 100%;
}
.field select { padding-right: 32px; max-width: 280px; }
.seg-options { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-options label { position: relative; cursor: pointer; }
.seg-options input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-options span { display: inline-block; padding: 7px 13px; border-radius: 999px; font-weight: 650; font-size: .92rem; color: var(--ink-2); white-space: nowrap; }
.seg-options input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-options input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.check-field { justify-content: flex-end; height: 42px; }
.field > label.check { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--ink-2); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--accent-fill); }

.era-filter { border: 0; padding: 0; margin: 14px 0 0; }
.era-filter .hint { text-transform: none; letter-spacing: 0; font-weight: 500; }
.era-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.era-chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); border-radius: 999px;
  padding: 6px 12px; font-size: .88rem; font-weight: 650; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline;
}
.era-chip small { color: var(--ink-3); font-weight: 600; font-size: .78rem; }
.era-chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.era-chip[aria-pressed="true"] small { color: var(--bg); opacity: .75; }

.status-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; min-height: 32px; }
.count { margin: 0; color: var(--ink-2); font-weight: 600; }
.btn-small { padding: 5px 12px; font-size: .88rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }

/* ---------- minimap ---------- */
.timeline-wrap { margin-top: 18px; }
.minimap { display: flex; gap: 4px; }
.minimap button {
  flex: 1 1 0; min-width: 0; border: 0; border-radius: 8px; padding: 6px 8px 7px; cursor: pointer; text-align: left;
  background: var(--surface-2); color: var(--ink-2); font-size: .74rem; font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 3px solid transparent;
}
.minimap button span { display: block; font-weight: 600; opacity: .8; }
.minimap button:hover { background: var(--surface-3); color: var(--ink); }
.minimap button[aria-current="true"] { background: var(--surface); color: var(--ink); border-bottom-color: var(--accent-fill); box-shadow: var(--shadow); }

.scroll-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.kbd-hint { margin: 0; color: var(--ink-3); font-size: .85rem; text-align: center; }
kbd { font-family: var(--mono); font-size: .8em; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface); color: var(--ink-2); }

/* ---------- the track (horizontal) ---------- */
.scroller {
  overflow-x: auto; overflow-y: hidden; scroll-behavior: smooth; overscroll-behavior-x: contain;
  scrollbar-color: var(--line) transparent; padding-bottom: 8px;
}
.canvas { position: relative; width: max-content; min-width: 100%; }
.bands { position: absolute; inset: 0; pointer-events: none; }
.band {
  position: absolute; top: calc(50% - 26px); height: 52px; border-radius: 14px;
  display: flex; align-items: flex-start; padding: 2px 10px; font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.band.winter { background: var(--winter); box-shadow: inset 0 0 0 1px var(--winter-edge); color: var(--winter-ink); }
.band.hype { background: var(--hype); box-shadow: inset 0 0 0 1px var(--hype-edge); color: var(--hype-ink); }
.band span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.track {
  list-style: none; margin: 0; position: relative; display: flex; align-items: stretch;
  width: max-content; min-height: 600px;
  padding: 10px max(24px, calc((100vw - 1280px) / 2 + 24px));
}
.track:focus { outline: none; }
.track::before {
  content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 2px); height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--line), var(--ink-3) 30%, var(--accent-fill));
  opacity: .55;
}

.ev { flex: 0 0 150px; position: relative; display: grid; grid-template-rows: 1fr 56px 1fr; }
.ev .card { grid-row: 1; align-self: end; margin-bottom: 6px; }
.ev.below .card { grid-row: 3; align-self: start; margin-top: 6px; margin-bottom: 0; }
.ev .pin {
  grid-row: 2; align-self: center; position: relative; width: 22px; height: 22px; margin-left: 14px; border-radius: 50%;
  background: var(--tc); box-shadow: 0 0 0 4px var(--bg); z-index: 1;
}
.ev.branch .pin { background: var(--surface); box-shadow: 0 0 0 4px var(--bg), inset 0 0 0 5px var(--tc); }
.ev .stem { position: absolute; left: 24px; width: 2px; background: var(--tc); opacity: .45; }
.ev .stem { top: calc(50% - 34px); height: 24px; }
.ev.below .stem { top: calc(50% + 10px); }

.card {
  width: 240px; position: relative; z-index: 2; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
  border-top: 5px solid var(--tc); transition: transform .15s ease, box-shadow .15s ease;
}
.ev.branch .card { border-top-style: dashed; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.card .yr { font-family: var(--font); font-size: 1.5rem; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.card .ttl { font-family: var(--font); font-size: 1.02rem; font-weight: 750; line-height: 1.25; }
.card .who { font-size: .84rem; color: var(--ink-2); line-height: 1.3; }
.card .chip { align-self: flex-start; margin-top: 4px; font-size: .74rem; }
.card .badges { position: absolute; top: 8px; right: 10px; display: flex; gap: 4px; font-size: .95rem; }

.era-mark { flex: 0 0 132px; position: relative; display: flex; align-items: flex-start; justify-content: center; }
.era-mark::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 2px dashed var(--line); }
.era-mark h2 {
  position: relative; margin: 0; background: var(--bg); padding: 8px 6px; text-align: center;
  font-size: .95rem; font-weight: 850; color: var(--ink); max-width: 128px;
}
.era-mark h2 span { display: block; font-size: .78rem; font-weight: 700; color: var(--ink-3); margin-top: 2px; }

.period-mark { flex: 0 0 120px; position: relative; display: grid; grid-template-rows: 1fr auto 1fr; justify-items: center; }
.period-btn {
  grid-row: 3; align-self: start; margin-top: 40px; position: relative; z-index: 2;
  border-radius: 12px; padding: 7px 10px; font-size: .8rem; font-weight: 750; cursor: pointer; line-height: 1.2; max-width: 116px;
}
.period-btn.winter { background: var(--winter); color: var(--winter-ink); border: 1px solid var(--winter-edge); }
.period-btn.hype { background: var(--hype); color: var(--hype-ink); border: 1px solid var(--hype-edge); }
.period-btn small { display: block; font-weight: 600; opacity: .85; }

.empty, .load-error { padding: 30px 16px; text-align: center; color: var(--ink-2); font-size: 1.05rem; }

/* ---------- vertical layout (phones) ---------- */
@media (max-width: 760px) {
  .minimap, .scroll-controls { display: none; }
  .scroller { overflow: visible; padding: 0; }
  .canvas { width: auto; }
  .track { flex-direction: column; width: auto; min-height: 0; padding: 0 16px 0 16px; }
  .track::before { left: 30px; right: auto; top: 0; bottom: 0; width: 4px; height: auto; background: linear-gradient(180deg, var(--line), var(--ink-3) 30%, var(--accent-fill)); }
  .band { top: 0; left: 18px; width: 28px; height: 0; padding: 0; border-radius: 14px; }
  .band span { display: none; }

  .ev, .ev.below { display: block; flex: none; padding: 8px 0 8px 46px; }
  .ev .card, .ev.below .card { width: 100%; margin: 0; }
  .ev .pin { position: absolute; left: 7px; top: 24px; margin: 0; width: 20px; height: 20px; }
  .ev .stem, .ev.below .stem { display: none; }

  .era-mark { flex: none; display: block; position: sticky; top: 0; z-index: 5; margin: 10px -16px 4px; padding: 0 16px; background: var(--bg); }
  .era-mark::before { display: none; }
  .era-mark h2 { max-width: none; text-align: left; padding: 10px 0 8px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .era-mark h2 span { display: inline; margin: 0; }

  .period-mark { display: block; flex: none; padding: 6px 0 6px 46px; }
  .period-btn { margin: 0; max-width: none; width: 100%; text-align: left; }
  .period-btn small { display: inline; margin-left: 6px; }

  .card:hover { transform: none; }
}

/* ---------- detail dialog ---------- */
dialog#detail {
  position: fixed; inset: 0 0 0 auto; padding: 0; border: 0; margin: 0;
  height: 100vh; height: 100dvh; max-height: none; width: min(640px, 100vw); max-width: 100vw;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog#detail[open] { animation: slide-in .22s ease-out; }
dialog#detail::backdrop { background: rgba(8, 8, 16, .5); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet { display: flex; flex-direction: column; height: 100%; }
.d-head { position: relative; padding: 20px 64px 14px 24px; border-bottom: 1px solid var(--line); border-top: 6px solid var(--tc, var(--t-main)); }
.d-head h2 { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 900; margin: 6px 0 0; outline: none; }
.d-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.d-meta .d-date { font-family: var(--font); font-weight: 850; font-size: 1.05rem; margin-right: 4px; }
.d-close { position: absolute; top: 16px; right: 16px; }
.d-body { flex: 1; overflow-y: auto; padding: 18px 24px 28px; overscroll-behavior: contain; }
.d-body section { margin-bottom: 22px; }
.d-body h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 800; margin-bottom: 8px; }
.d-body p { line-height: 1.65; }
.kidline { font-family: var(--font); font-size: 1.2rem; font-weight: 700; line-height: 1.4; margin: 0 0 10px; }
.callout { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; border-left: 5px solid var(--tc, var(--t-main)); }
.callout p:last-child { margin-bottom: 0; }
.move { background: var(--hype); color: var(--ink); border-left-color: var(--hype-edge); }
.move h3 { color: var(--hype-ink); }
.d-body ul.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.d-body ul.links li { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.d-body ul.links a { font-weight: 650; }
.d-body ul.links .sub { display: block; color: var(--ink-2); font-size: .86rem; margin-top: 2px; }
.d-body .people { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.d-body .people li { display: grid; gap: 1px; }
.d-body .people .role { color: var(--ink-2); font-size: .92rem; }
.badge-kid { display: inline-block; font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--t-branch-reinforcement-learning); color: #04140a; margin-left: 6px; vertical-align: 1px; }
.d-period { margin-bottom: 16px; font-size: .92rem; padding: 10px 12px; border-radius: 10px; }
.d-period.winter { background: var(--winter); color: var(--winter-ink); }
.d-period.hype { background: var(--hype); color: var(--hype-ink); }
.d-foot { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.d-foot .btn[disabled] { opacity: .4; cursor: default; }
.d-foot .btn-primary { flex: 1 1 auto; justify-content: center; text-align: center; }
@media (max-width: 520px) {
  .d-head { padding: 16px 60px 12px 16px; }
  .d-body { padding: 16px 16px 24px; }
  .d-foot .lbl { display: none; }
}
