/* A Wesley Chronology — the journal timeline's chart system, extended.
   Palette: Lamp Black #171E28 · Chart Linen #EFE6D0 · Candle #D9A441
            Oxblood #8C3B34 · Sea Grey #7C8B96
   Type: EB Garamond (prose) / Inter (chrome). The map is the page;
   panels are ink glass laid over the chart. */

:root {
  --ink: #171E28;
  --ink-2: #232D3A;
  --glass: rgba(17, 22, 30, 0.92);
  --glass-soft: rgba(17, 22, 30, 0.74);
  --linen: #EFE6D0;
  --linen-dim: #B9AD92;
  --candle: #D9A441;
  --oxblood: #8C3B34;
  --sea: #7C8B96;
  --hairline: rgba(239, 230, 208, 0.16);
  --serif: "EB Garamond", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;

  /* category families */
  --f-road: #D9A441;
  --f-society: #8FB3C9;
  --f-pen: #E4D9BE;
  --f-opposition: #C9665A;
  --f-life: #A3B98C;
  --f-context: #7C8B96;

  --top: 52px;
  --years: 84px;
  --ledger-w: 440px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--linen);
  font-family: var(--serif);
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
a { color: var(--candle); }
:focus-visible { outline: 2px solid var(--candle); outline-offset: 2px; }

/* ---------- the chart ---------- */
#map { position: fixed; top: var(--top); left: 0; bottom: var(--years); right: var(--ledger-w); z-index: 0; background: var(--ink); }
#map .leaflet-tile-pane { filter: saturate(0.5) sepia(0.30) brightness(0.92) contrast(1.02); }
.leaflet-container { font-family: var(--sans); background: var(--ink); }
.leaflet-control-attribution { background: var(--glass-soft) !important; color: var(--linen-dim) !important; font-size: 9.5px; }
.leaflet-control-attribution a { color: var(--sea) !important; }
.leaflet-control-zoom a { background: var(--glass) !important; color: var(--linen) !important; border-color: var(--hairline) !important; }

.chart-tip {
  background: var(--glass); border: 1px solid var(--hairline); color: var(--linen);
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.04em; border-radius: 2px;
  padding: 3px 8px; box-shadow: none;
}
.chart-tip::before { display: none; }

.pulse { pointer-events: none; border-radius: 50%; background: var(--candle);
  border: 2px solid rgba(23, 30, 40, 0.85);
  box-shadow: 0 0 0 3px rgba(217,164,65,.35), 0 0 18px 4px rgba(217,164,65,.45); }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: breathe 3.2s ease-in-out infinite; }
  @keyframes breathe {
    0%, 100% { box-shadow: 0 0 0 3px rgba(217,164,65,.35), 0 0 14px 3px rgba(217,164,65,.4); }
    50%      { box-shadow: 0 0 0 4px rgba(217,164,65,.25), 0 0 24px 7px rgba(217,164,65,.55); }
  }
}

.route-toggle {
  position: fixed; top: calc(var(--top) + 10px); right: calc(var(--ledger-w) + 16px); z-index: 15;
  font-family: var(--sans); font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--linen-dim); background: var(--glass-soft); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 7px 14px; backdrop-filter: blur(3px);
}
.route-toggle:hover { color: var(--candle); border-color: var(--candle); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top); z-index: 40;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: linear-gradient(to bottom, rgba(17,22,30,.95), rgba(17,22,30,.82));
  border-bottom: 1px solid var(--hairline);
}
.wordmark { font-family: var(--serif); font-style: italic; font-size: 21px; color: var(--linen); text-decoration: none; white-space: nowrap; }
.wordmark .span { font-family: var(--sans); font-style: normal; font-size: 10px; letter-spacing: 0.2em; color: var(--candle); margin-left: 10px; vertical-align: 3px; }
.spacer { flex: 1; }
.bar-btn { font-family: var(--sans); font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--linen-dim); text-decoration: none; white-space: nowrap; }
.bar-btn:hover { color: var(--candle); }

/* ---------- the ledger ---------- */
.ledger {
  position: fixed; top: var(--top); right: 0; bottom: 0; width: var(--ledger-w); z-index: 20;
  display: flex; flex-direction: column;
  background: var(--glass); border-left: 1px solid var(--hairline);
}
.ledger-head { padding: 12px 16px 8px; border-bottom: 1px solid var(--hairline); }
.search-row { display: flex; gap: 8px; }
#q {
  flex: 1; min-width: 0; font: 15px var(--serif); color: var(--linen);
  background: rgba(239,230,208,.06); border: 1px solid var(--hairline); border-radius: 2px; padding: 7px 10px;
}
#q::placeholder { color: var(--linen-dim); opacity: .7; font-style: italic; }
#q:focus { outline: none; border-color: var(--candle); }
.chip-toggle { font-family: var(--sans); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--linen-dim); border: 1px solid var(--hairline); border-radius: 2px; padding: 0 12px; }
.chip-toggle[aria-expanded="true"], .chip-toggle.active { color: var(--candle); border-color: var(--candle); }
.filters { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 10px; }
.filters .fam-label { width: 100%; font-family: var(--sans); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--sea); margin-top: 4px; }
.chip { font-family: var(--sans); font-size: 11px; color: var(--linen-dim); border: 1px solid var(--hairline); border-radius: 999px; padding: 3px 9px; }
.chip::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.chip[aria-pressed="true"] { color: var(--ink); background: var(--c); border-color: var(--c); }
.chip[aria-pressed="true"]::before { background: var(--ink); }
.chip.clear { border-style: dashed; }
.chip.clear::before { display: none; }
.count { font-family: var(--sans); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--sea); padding-top: 8px; }

.events { list-style: none; margin: 0; padding: 0 0 40vh; overflow-y: auto; flex: 1; scrollbar-color: var(--ink-2) transparent; }
.year-h {
  position: sticky; top: 0; z-index: 2; padding: 14px 16px 6px;
  background: linear-gradient(to bottom, rgba(17,22,30,1) 70%, rgba(17,22,30,0));
  display: flex; align-items: baseline; gap: 10px;
}
.year-h .y { font-size: 30px; font-style: italic; color: var(--candle); line-height: 1; }
.year-h .age { font-family: var(--sans); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--sea); }
.ev {
  position: relative; padding: 9px 16px 10px 22px; border-top: 1px solid rgba(239,230,208,.06); cursor: pointer;
}
.ev::before { content: ""; position: absolute; left: 10px; top: 13px; bottom: 13px; width: 2px; background: var(--c, var(--sea)); opacity: .7; border-radius: 1px; }
.ev:hover { background: rgba(239,230,208,.035); }
.ev.current { background: rgba(217,164,65,.09); }
.ev.current::before { opacity: 1; width: 3px; }
.ev .meta { font-family: var(--sans); font-size: 10.5px; letter-spacing: .06em; color: var(--linen-dim); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ev .date { color: var(--linen); font-weight: 500; }
.ev .place { color: var(--sea); }
.ev .place.unpinned { font-style: italic; }
.ev .text { font-size: 16.5px; line-height: 1.38; margin: 3px 0 4px; }
.ev .foot { font-family: var(--sans); font-size: 10px; color: var(--sea); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.ev .cat { letter-spacing: .1em; text-transform: uppercase; }
.ev .cite { color: var(--sea); text-decoration: none; border-bottom: 1px dotted rgba(124,139,150,.6); }
.ev .cite:hover { color: var(--candle); border-color: var(--candle); }
.ev .flag { color: var(--candle); }
.ev .note { display: none; font-size: 14px; font-style: italic; color: var(--linen-dim); margin-top: 6px; padding-left: 10px; border-left: 1px solid var(--hairline); line-height: 1.35; }
.ev.open .note { display: block; }
.empty { padding: 30px 16px; font-style: italic; color: var(--linen-dim); }
mark { background: rgba(217,164,65,.3); color: inherit; }

/* ---------- year strip ---------- */
.years {
  position: fixed; left: 0; right: var(--ledger-w); bottom: 0; height: var(--years); z-index: 18;
  display: flex; align-items: stretch; gap: 14px; padding: 10px 16px 10px 14px;
  background: var(--glass); border-top: 1px solid var(--hairline);
}
.play { width: 38px; flex: none; align-self: center; height: 38px; border-radius: 50%; border: 1px solid var(--hairline); color: var(--candle); font-size: 13px; }
.play:hover, .play.on { border-color: var(--candle); }
.year-readout { flex: none; width: 74px; display: flex; flex-direction: column; justify-content: center; }
#cur-year { font-size: 30px; font-style: italic; color: var(--candle); line-height: 1; }
#cur-age { font-family: var(--sans); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--sea); margin-top: 3px; }
.bars { flex: 1; display: flex; align-items: flex-end; gap: 2px; min-width: 0; position: relative; }
.bar { flex: 1; min-width: 2px; height: 100%; display: flex; align-items: flex-end; position: relative; }
.bar i { display: block; width: 100%; background: var(--linen-dim); opacity: .45; border-radius: 1px 1px 0 0; min-height: 2px; }
.bar:hover i { opacity: .8; }
.bar.cur i { background: var(--candle); opacity: 1; }
.bar.dim i { opacity: .15; }
.bar .tick { position: absolute; bottom: -1px; left: 0; font-family: var(--sans); font-size: 9px; color: var(--sea); transform: translateY(100%); pointer-events: none; }
.bars { padding-bottom: 12px; }

/* ---------- place drawer ---------- */
.drawer {
  position: fixed; top: calc(var(--top) + 52px); left: 16px; width: 360px; max-height: calc(100% - var(--top) - var(--years) - 72px);
  z-index: 22; display: flex; flex-direction: column;
  background: var(--glass); border: 1px solid var(--hairline); border-radius: 3px; backdrop-filter: blur(3px);
}
.drawer header { padding: 14px 16px 10px; border-bottom: 1px solid var(--hairline); position: relative; }
.drawer .eyebrow, .modal .eyebrow { font-family: var(--sans); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--sea); margin: 0 0 4px; }
.drawer h2 { margin: 0; font-size: 26px; font-style: italic; font-weight: 400; color: var(--candle); }
.drawer .pnote { font-size: 13.5px; font-style: italic; color: var(--linen-dim); margin: 6px 0 0; }
.drawer ol { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.drawer li { padding: 8px 16px; border-top: 1px solid rgba(239,230,208,.06); cursor: pointer; font-size: 15px; line-height: 1.3; }
.drawer li:hover { background: rgba(239,230,208,.04); }
.drawer li .date { display: block; font-family: var(--sans); font-size: 10px; letter-spacing: .06em; color: var(--linen-dim); }
.close { position: absolute; top: 8px; right: 10px; font-size: 22px; color: var(--linen-dim); line-height: 1; padding: 4px; }
.close:hover { color: var(--candle); }

/* ---------- about ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10,13,18,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { position: relative; max-width: 620px; max-height: 100%; overflow-y: auto; background: var(--ink); border: 1px solid var(--hairline); padding: 28px 32px; font-size: 17px; line-height: 1.5; }
.modal h2 { margin: 0 0 12px; font-weight: 400; font-style: italic; font-size: 30px; color: var(--candle); }
.modal p { margin: 0 0 12px; }
.modal strong { font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--linen-dim); font-weight: 600; }
.modal .small { font-size: 14px; color: var(--linen-dim); }

/* ---------- narrow screens: chart above, ledger below ---------- */
@media (max-width: 820px) {
  :root { --ledger-w: 0px; --years: 64px; }
  .hide-sm { display: none; }
  .wordmark { font-size: 18px; }
  #map { right: 0; bottom: auto; height: 40vh; top: var(--top); }
  .years { top: calc(var(--top) + 40vh); bottom: auto; right: 0; height: var(--years); padding: 8px 16px; gap: 10px; }
  .play { width: 32px; height: 32px; }
  .year-readout { width: 56px; }
  #cur-year { font-size: 24px; }
  .ledger { top: calc(var(--top) + 40vh + var(--years)); width: 100%; border-left: none; }
  .route-toggle { right: 16px; top: calc(var(--top) + 8px); }
  .drawer { left: 16px; right: 16px; width: auto; top: calc(var(--top) + 8px); max-height: calc(40vh - 16px); }
  .modal-card { padding: 22px 20px; }
}
