/* Atlas of Empires — "Data Story" editorial theme */
:root {
  --bg: #ffffff;
  --ink: #111111;
  --ink-2: #2b2b28;
  --ink-3: #6b6b66;
  --rule: #e6e6e1;
  --rule-strong: #111111;
  --highlight: #e5402a;
  --chip: #f0f0ec;
  /* map */
  --ocean: #ffffff;
  --grat: #f1f1ef;
  --unknown: #ececE8;
  --peoples-bg: #f2f1ec;
  --peoples-line: #e2e0d8;
  --other-1: #d3d3ce;
  --other-2: #c9c9c4;
  --other-3: #dadad5;
  --border: #ffffff;
  --label-soft: #4a4a45;
  --shadow: 0 10px 30px rgba(0, 0, 0, .12);
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --col-w: 470px;
  color-scheme: light;
}
/* Light is the default for everyone; the dark palette applies only when data-theme="dark" is set. */
:root[data-theme="dark"] {
  --bg: #121211; --ink: #f2f2ee; --ink-2: #d6d6d0; --ink-3: #9a9a93; --rule: #2a2a27; --rule-strong: #f2f2ee;
  --highlight: #ff5a43; --chip: #232321;
  --ocean: #121211; --grat: #1c1c1a; --unknown: #242422; --peoples-bg: #262624; --peoples-line: #33332f;
  --other-1: #3b3b37; --other-2: #45453f; --other-3: #34342f; --border: #121211; --label-soft: #b8b8b0;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--ink); }
a:hover { color: var(--highlight); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

#app {
  display: grid; height: 100dvh;
  grid-template-columns: var(--col-w) minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr) auto;
  grid-template-areas: "bar bar" "col stage" "dock dock";
}

/* ---------- top bar ---------- */
#bar { grid-area: bar; display: flex; align-items: center; gap: 24px; padding: 0 32px; border-bottom: 2px solid var(--rule-strong); }
.brand { font: 900 15px var(--display); letter-spacing: .06em; text-decoration: none; white-space: nowrap; }
.search { position: relative; margin-left: auto; display: flex; align-items: center; gap: 8px; width: min(420px, 50vw); height: 40px; padding: 0 12px; border: 1px solid var(--rule); background: var(--bg); }
.search:focus-within { border-color: var(--ink); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2; flex: none; }
#search { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font: 400 14px var(--sans); }
#results { position: absolute; z-index: 20; left: -1px; right: -1px; top: 40px; margin: 0; padding: 4px 0; list-style: none; background: var(--bg); border: 1px solid var(--ink); box-shadow: var(--shadow); max-height: 380px; overflow: auto; }
#results li { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
#results li:hover, #results li.active { background: var(--chip); }
#results li small { color: var(--ink-3); white-space: nowrap; }
.topnav { display: flex; gap: 20px; }
.topnav a { font: 500 14px var(--sans); text-decoration: none; }

/* ---------- left column ---------- */
#col { grid-area: col; overflow: auto; padding: 28px 32px 40px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 18px; }
#col > * { flex-shrink: 0; } /* a scrolling flex column must not squash its charts/figures */
.kicker { font: 600 12px var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.year { font: 900 clamp(84px, 9vw, 132px)/.82 var(--display); letter-spacing: -.05em; font-variant-numeric: lining-nums; margin: 0; }
.year small { font: 800 .22em var(--display); letter-spacing: .02em; margin-left: .12em; color: var(--ink-3); }
h1.head { margin: 4px 0 0; font: 800 30px/1.1 var(--display); letter-spacing: -.01em; }
h2.realm { margin: 0; font: 800 40px/1 var(--display); letter-spacing: -.02em; }
.prose { margin: 0; font: 400 16px/1.6 var(--sans); color: var(--ink-2); }
.note { margin: 0; font-size: 13px; color: var(--ink-3); }
.mark { background: var(--highlight); color: #fff; padding: 0 4px; }
h3.sec { margin: 10px 0 0; font: 600 12px var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-decoration-color: var(--highlight); text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--highlight); }
.back { align-self: flex-start; border: 0; background: none; padding: 6px 0; font: 600 13px var(--sans); color: var(--ink-3); }
.back:hover { color: var(--highlight); }

table.rulers { border-collapse: collapse; width: 100%; font-size: 14px; }
table.rulers caption { text-align: left; padding-bottom: 8px; }
table.rulers th { text-align: left; padding: 6px 0; font-weight: 600; border-bottom: 2px solid var(--rule-strong); }
table.rulers th:last-child, table.rulers td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
table.rulers td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.rulers td:last-child { padding-right: 0; }
table.rulers td.who { color: var(--ink-3); }
table.rulers tr[data-key] { cursor: pointer; }
table.rulers tr[data-key]:hover td { background: var(--chip); }
table.rulers tr.sel td { font-weight: 600; }
.sq { display: inline-block; width: 10px; height: 10px; margin-right: 8px; }

details.region { border-bottom: 1px solid var(--rule); }
details.region summary { list-style: none; cursor: pointer; padding: 10px 0; display: flex; justify-content: space-between; font: 600 15px var(--display); }
details.region summary::-webkit-details-marker { display: none; }
details.region summary::after { content: "+"; color: var(--ink-3); font-weight: 400; }
details.region[open] summary::after { content: "−"; }
details.region p { margin: 0 0 10px; font-size: 15px; color: var(--ink-2); }
details.region .goto { border: 0; background: none; padding: 0 0 12px; font: 600 12px var(--sans); color: var(--highlight); }

ol.events { list-style: none; margin: 0; padding: 0; }
ol.events li { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
ol.events .y { font: 800 13px var(--display); text-align: left; text-decoration: none; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 2px solid var(--rule-strong); border-bottom: 1px solid var(--rule); }
.stats div { padding: 10px 10px 10px 0; display: flex; flex-direction: column; gap: 2px; }
.stats b { font: 800 22px var(--display); }
.stats span { font-size: 12px; color: var(--ink-3); }
.chart-s { width: 100%; height: 120px; display: block; cursor: crosshair; color: var(--ink-3); }
.chart-s text { fill: var(--ink-3); font: 11px var(--sans); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.toggle input { accent-color: var(--highlight); width: 16px; height: 16px; }
figure.ref { margin: 0; }
figure.ref img { width: 100%; display: block; border: 1px solid var(--rule); background: #fff; }
figure.ref figcaption { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.45; }
ul.rlist { list-style: none; margin: 0; padding: 0; }
ul.rlist li { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
ul.rlist b { font: 600 15px var(--sans); }
ul.rlist .r { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
ul.rlist .n { grid-column: 1 / -1; font-size: 13px; color: var(--ink-3); }
ul.terr { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 16px; font-size: 13.5px; }
ul.terr li { break-inside: avoid; padding: 3px 0; cursor: pointer; }
ul.terr li:hover { color: var(--highlight); }
ul.terr small { color: var(--ink-3); }
p.links { margin: 0; font-size: 14px; }
.sources-list { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.sources-list li { margin-bottom: 8px; }

/* ---------- map ---------- */
#stage { grid-area: stage; position: relative; overflow: hidden; background: var(--ocean); }
#gl, #map { position: absolute; inset: 0; width: 100%; height: 100%; }
#gl { pointer-events: none; }
#map { touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }
#mapTools { position: absolute; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 6px; }
#mapTools button { width: 38px; height: 38px; border: 1px solid var(--rule); background: var(--bg); font: 600 15px var(--sans); display: grid; place-items: center; }
#mapTools button:hover { border-color: var(--ink); }
#mapTools button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
#labelsBtn:not(.on), #peoplesBtn:not(.on) { opacity: .45; }
#mapTools .hatch { width: 16px; height: 16px; background: repeating-linear-gradient(135deg, var(--ink-3) 0 2px, transparent 2px 5px); }
#legend { position: absolute; left: 20px; bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-3); }
#legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; display: inline-block; }
.sw.others { background: var(--other-1); }
.sw.peoples { background: repeating-linear-gradient(135deg, var(--peoples-line) 0 2px, var(--peoples-bg) 2px 4px); }
.sw.unknown { background: var(--unknown); }
#tooltip { position: absolute; z-index: 5; pointer-events: none; max-width: 280px; padding: 8px 11px; background: var(--bg); border: 1px solid var(--ink); box-shadow: var(--shadow); font-size: 13px; transform: translate(14px, 14px); }
#tooltip b { display: block; font: 800 16px/1.2 var(--display); }
#tooltip .m { color: var(--ink-3); }
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); font: 800 20px var(--display); color: var(--ink-3); transition: opacity .3s; }
#loading.done { opacity: 0; pointer-events: none; }

/* ---------- dock: power chart timeline ---------- */
#dock { grid-area: dock; border-top: 2px solid var(--rule-strong); padding: 12px 32px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.dock-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: none; }
.play svg { width: 16px; height: 16px; fill: currentColor; }
.dock-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#chartTitle { font: 800 15px var(--display); }
.dock-title .sub { font-size: 12px; color: var(--ink-3); }
.chapnav { display: flex; gap: 6px; }
.chapnav button { height: 34px; padding: 0 12px; border: 1px solid var(--rule); background: var(--bg); font: 600 12px var(--sans); }
.chapnav button:hover { border-color: var(--ink); }
#strip { margin-left: auto; position: relative; width: min(440px, 36vw); height: 32px; cursor: pointer; touch-action: none; }
#strip .seg { position: absolute; top: 0; height: 10px; background: var(--chip); border-right: 2px solid var(--bg); }
#strip .seg:hover { background: var(--other-1); }
#strip .seg.on { background: var(--ink); }
#strip .now { position: absolute; top: -4px; width: 3px; height: 18px; margin-left: -1.5px; background: var(--highlight); pointer-events: none; }
#strip .lab { position: absolute; top: 14px; font-size: 11px; color: var(--ink-3); white-space: nowrap; pointer-events: none; }
#chart { position: relative; height: 152px; margin-top: 20px; user-select: none; touch-action: none; cursor: ew-resize; }
#chart svg.pc { display: block; width: 100%; height: 130px; overflow: visible; }
#chart .series:hover { opacity: .85; }
#chart .legend { position: absolute; left: 4px; top: 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; font: 500 11px var(--sans); color: var(--ink-2); pointer-events: none; max-width: 75%; }
#chart .legend span { display: inline-flex; align-items: center; gap: 5px; background: color-mix(in srgb, var(--bg) 80%, transparent); padding: 0 3px; }
#chart .legend i { width: 10px; height: 10px; display: inline-block; }
#chart .cur { position: absolute; top: -22px; transform: translateX(-50%); font: 800 13px var(--display); background: var(--ink); color: var(--bg); padding: 2px 8px; white-space: nowrap; pointer-events: none; }
#chart .axis { position: relative; height: 16px; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
#chart .axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#chart .axis span:first-child { transform: none; }
#chart .axis span:last-child { transform: translateX(-100%); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100dvh; grid-template-columns: 1fr; grid-template-rows: 56px max(62vw, 260px) auto auto; grid-template-areas: "bar" "stage" "dock" "col"; }
  #bar { padding: 0 16px; gap: 12px; }
  .brand { font-size: 13px; }
  .topnav a#sourcesLink { display: none; }
  .search { width: auto; flex: 1; }
  #col { border-right: 0; padding: 20px 16px 40px; overflow: visible; }
  #dock { padding: 10px 16px; }
  #strip { width: 100%; margin-left: 0; }
  .dock-title .sub, .chapnav { display: none; }
  #legend { display: none; }
  #mapTools { right: 8px; top: 8px; }
  #mapTools button { width: 34px; height: 34px; }
  #chart { height: auto; }
  #chart .legend { position: static; max-width: none; margin-top: 8px; }
}

ol.refs { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink-3); }
ol.refs li { margin-bottom: 4px; overflow-wrap: anywhere; }
ol.refs a { color: var(--ink-2); }

aside.mapnote { border-left: 3px solid var(--highlight); background: var(--chip); padding: 10px 14px; font-size: 13.5px; color: var(--ink-2); }
aside.mapnote b { display: block; font: 600 11px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--highlight); margin-bottom: 4px; }
aside.mapnote p { margin: 4px 0 0; }

/* ---------- defining moments ---------- */
.year.mom { font-size: clamp(30px, 3.2vw, 44px); letter-spacing: -.02em; line-height: 1; }
ul.mlist { list-style: none; margin: 0; padding: 0; }
ul.mlist li { border-bottom: 1px solid var(--rule); }
.mrow { width: 100%; display: grid; grid-template-columns: 128px 1fr; gap: 12px; text-align: left; border: 0; background: none; padding: 9px 0; font-size: 14px; }
.mrow:hover { color: var(--highlight); }
.mrow .my { font: 800 12.5px var(--display); color: var(--ink-3); }
.mrow:hover .my { color: var(--highlight); }
.mnav { display: flex; justify-content: space-between; gap: 10px; border-top: 2px solid var(--rule-strong); padding-top: 10px; }
.mstep { border: 1px solid var(--rule); background: var(--bg); padding: 8px 12px; font: 600 13px var(--sans); max-width: 48%; text-align: left; }
.mstep:last-child { text-align: right; }
.mstep:hover { border-color: var(--ink); }
#chart .marks { position: absolute; left: 0; right: 0; top: 123px; height: 0; } /* on the chart's baseline */
#chart .mk { position: absolute; top: 0; width: 14px; height: 14px; margin-left: -7px; padding: 0; border: 2px solid var(--bg); background: var(--ink); transform: rotate(45deg); cursor: pointer; z-index: 3; }
#chart .mk:hover, #chart .mk.on { background: var(--highlight); }
#chart .mk .tipm { display: none; position: absolute; left: 50%; bottom: 14px; transform: rotate(-45deg); transform-origin: left bottom; white-space: nowrap; background: var(--ink); color: var(--bg); font: 600 11px var(--sans); padding: 3px 7px; pointer-events: none; }
#chart .mk:hover .tipm { display: block; }
#strip .mdot { position: absolute; top: 2px; width: 4px; height: 6px; margin-left: -2px; background: var(--highlight); opacity: .7; pointer-events: none; }

/* ---------- empire journeys ---------- */
#chart .reigns { position: absolute; left: 0; right: 0; top: 136px; height: 18px; }
#chart .reign { position: absolute; top: 0; height: 18px; border: 0; border-right: 1px solid var(--bg); background: var(--other-1); padding: 0 4px; font: 600 10.5px/18px var(--sans); color: var(--ink-2); text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
#chart .reign.alt { background: var(--other-3); }
#chart .reign:hover { background: var(--ink); color: var(--bg); }
#chart .reign span { pointer-events: none; }
#dock:has(.reigns) #chart { height: 176px; }
#dock:has(.reigns) #chart .axis { margin-top: 26px; }
.exitj { margin-left: 10px; border: 1px solid var(--rule); background: var(--bg); font: 600 12px var(--sans); padding: 3px 8px; vertical-align: 2px; }
.exitj:hover { border-color: var(--ink); }
ol.jtl li.future { opacity: .55; }
ol.jtl li.now span { font-weight: 600; }
ol.jtl li.now { background: var(--chip); }
ul.rlist li.cur b, ul.rlist li.cur button { font-weight: 700; color: var(--highlight); }
ul.rlist li button.linkish { text-decoration: none; font: 600 15px var(--sans); text-align: left; }
.playj { align-self: flex-start; border: 2px solid var(--ink); background: var(--ink); color: var(--bg); font: 700 13px var(--sans); padding: 9px 14px; }
.playj:hover { background: var(--highlight); border-color: var(--highlight); }
aside.mapnote p.msrc { font-size: 12px; color: var(--ink-3); }
aside.mapnote p.msrc a { color: var(--ink-3); }
p.refyear { margin: 0; font-size: 13px; color: var(--ink-2); background: var(--chip); padding: 8px 10px; }

aside.evnow p.evt { font-weight: 600; color: var(--ink); }
aside.evnow p + p { line-height: 1.55; }
ol.jtl li > div { min-width: 0; }
ol.jtl details { margin-top: 4px; }
ol.jtl details summary { cursor: pointer; font: 600 12px var(--sans); color: var(--highlight); list-style: none; }
ol.jtl details summary::-webkit-details-marker { display: none; }
ol.jtl details[open] summary { color: var(--ink-3); }
ol.jtl details p { margin: 4px 0 2px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }

/* ---------- war playback ---------- */
#chart .warbar { position: absolute; left: 0; right: 0; top: 40px; height: 34px; }
#chart .warbar .wy { position: absolute; top: 0; height: 34px; background: var(--chip); border-right: 1px solid var(--bg); font: 600 11px/34px var(--sans); color: var(--ink-3); padding-left: 6px; overflow: hidden; white-space: nowrap; }
#chart .warbar .wy.alt { background: color-mix(in srgb, var(--chip) 55%, var(--bg)); }
#chart .wsides { position: absolute; left: 4px; top: 2px; display: flex; gap: 14px; font: 600 12px var(--sans); }
#chart .wsides span { display: inline-flex; align-items: center; gap: 6px; }
#chart .wsides i { width: 12px; height: 12px; display: inline-block; }
#chart .wmarks { position: absolute; left: 0; right: 0; top: 50px; height: 0; }
#chart .wmarks .mk { top: 0; }
#chart .wmarks .mk.wk-battle { background: var(--ink); }
#chart .wmarks .mk.wk-treaty { background: #2F7D6D; }
#chart .wmarks .mk.wk-turning-point { background: #E9A93B; }
#chart .wmarks .mk.wk-atrocity { background: #7A1F2B; }
#chart .wmarks .mk.on { background: var(--highlight); transform: rotate(45deg) scale(1.35); }
#chart .wnow { position: absolute; right: 4px; top: 2px; font: 500 12px var(--sans); color: var(--ink-3); }
#chart .wnow b { color: var(--ink); }
.wside-list p { margin: 0 0 6px; font-size: 14px; }

/* ---------- period newspapers & photos ---------- */
.media { display: grid; gap: 12px; }
.mfig { margin: 0; }
.mfig img { width: 100%; display: block; border: 1px solid var(--rule); background: #f6f3ea; }
.mfig.news img { filter: contrast(1.05); }
.mfig figcaption { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; line-height: 1.45; }

/* ---- war cinema: date clock, scene caption, subtitles, playhead */
#cine { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#cine .cdate { position: absolute; left: 22px; top: 14px; display: flex; align-items: baseline; gap: 12px; font-family: var(--display); color: var(--ink);
  text-shadow: 0 0 3px var(--bg), 0 0 8px var(--bg), 0 0 14px var(--bg); }
#cine .cdate b { font-weight: 900; font-size: 44px; line-height: 1; letter-spacing: .01em; text-transform: uppercase; }
#cine .cdate span { font-weight: 800; font-size: 44px; line-height: 1; color: var(--highlight); font-variant-numeric: tabular-nums; }
#cShot { position: absolute; left: 24px; top: 66px; max-width: min(520px, 60%); font: 600 13px/1.4 var(--sans); color: var(--ink-2);
  text-shadow: 0 0 3px var(--bg), 0 0 8px var(--bg); }
#cSub { position: absolute; left: 50%; bottom: 46px; transform: translate(-50%, 8px); max-width: min(760px, 86%); padding: 10px 16px;
  background: rgba(17, 17, 17, .86); color: #fff; font: 600 16px/1.35 var(--sans); text-align: center; opacity: 0; transition: opacity .45s, transform .45s; }
#cSub b { display: block; font: 800 11px/1.4 var(--display); letter-spacing: .1em; text-transform: uppercase; color: #ffb4a8; margin-bottom: 2px; }
#cSub.on { opacity: 1; transform: translate(-50%, 0); }
#chart .wcur { position: absolute; top: 34px; height: 46px; width: 2px; margin-left: -1px; background: var(--highlight); pointer-events: none; }
#chart .wcur::before { content: ""; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--highlight); }
#chart .wsides .wl { color: var(--ink-3); font-weight: 500; }
#chart .wsides .wl i.occ { background: repeating-linear-gradient(135deg, #E5402A 0 2px, transparent 2px 5px); outline: 1px dashed #E5402A; }
#chart .wsides .wl i.fl { height: 3px; width: 16px; background: var(--ink); }
#chart .wsides .wl i.ar { height: 4px; width: 14px; background: #2B59D9; clip-path: polygon(0 25%, 70% 25%, 70% 0, 100% 50%, 70% 100%, 70% 75%, 0 75%); height: 10px; }
#chart .wsides .wl i.bt { border-radius: 50%; border: 1.5px solid var(--ink); background: rgba(17, 17, 17, .2); }
@media (max-width: 760px) { #cine .cdate b, #cine .cdate span { font-size: 28px; } #cShot { top: 48px; font-size: 12px; } #cSub { font-size: 14px; bottom: 16px; } }
/* war mode: quieter dock, legend on the map, alliance banner */
.warmode #strip, .warmode .chapnav, .warmode .dock-title .sub { display: none; }
.warmode #legend { background: color-mix(in srgb, var(--bg) 85%, transparent); padding: 4px 8px; color: var(--ink-2); max-width: calc(100% - 120px); }
.warmode #legend .wl i { display: inline-block; width: 12px; height: 12px; }
.warmode #legend .wl i.occ { background: repeating-linear-gradient(135deg, #E5402A 0 2px, transparent 2px 5px); outline: 1px dashed #E5402A; }
.warmode #legend .wl i.fl { height: 3px; width: 16px; background: var(--ink); }
.warmode #legend .wl i.ar { width: 14px; height: 10px; background: #2B59D9; clip-path: polygon(0 25%, 70% 25%, 70% 0, 100% 50%, 70% 100%, 70% 75%, 0 75%); }
.warmode #legend .wl i.bt { border-radius: 50%; border: 1.5px solid var(--ink); background: rgba(17, 17, 17, .2); }
#cJoin { position: absolute; left: 22px; top: 92px; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; background: var(--bg); border-left: 4px solid var(--ink);
  box-shadow: var(--shadow); font: 600 13px/1.35 var(--sans); color: var(--ink); opacity: 0; transform: translateX(-10px); transition: opacity .4s, transform .4s; max-width: min(420px, 60%); }
#cJoin.on { opacity: 1; transform: none; }
#cJoin b { font: 900 11px/1.2 var(--display); letter-spacing: .1em; color: var(--highlight); }
#cJoin span { display: flex; align-items: center; gap: 7px; }
#cJoin span i { width: 10px; height: 10px; flex: none; }
#cJoin span.out { color: var(--ink-3); }
.warmode #chart { height: 96px; }
.warmode #chart .warbar { top: 26px; }
.warmode #chart .wmarks { top: 36px; }
.warmode #chart .wcur { top: 20px; }
.warmode #chart .wnow { top: 0; }
/* war cinema v2: caption, "now" line and alliance banner stacked under the date */
#cine .cinfo { position: absolute; left: 22px; top: 66px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: min(480px, 58%); }
#cine .cinfo #cShot, #cine .cinfo #cJoin { position: static; max-width: none; }
#cNow { display: flex; flex-direction: column; gap: 3px; font: 500 12px/1.35 var(--sans); color: var(--ink-2); text-shadow: 0 0 3px var(--bg), 0 0 6px var(--bg); }
#cNow:empty { display: none; }
#cNow span { display: flex; align-items: center; gap: 7px; }
#cNow b { font-weight: 700; color: var(--ink); }
#cNow i { flex: none; display: inline-block; }
#cNow i.ar { width: 14px; height: 10px; clip-path: polygon(0 35%, 60% 25%, 60% 0, 100% 50%, 60% 100%, 60% 75%, 0 65%); }
#cNow i.bt { width: 10px; height: 10px; background: var(--ink); clip-path: polygon(50% 0, 62% 35%, 100% 50%, 62% 65%, 50% 100%, 38% 65%, 0 50%, 38% 35%); }
.warmode #legend .wl i.occ { background: #f2b3a9; outline: none; background-image: repeating-linear-gradient(135deg, rgba(229,64,42,.45) 0 1px, transparent 1px 4px); }
.warmode #legend .wl i.fl { height: 2px; }
.warmode #legend .wl i.ar { clip-path: polygon(0 35%, 60% 25%, 60% 0, 100% 50%, 60% 100%, 60% 75%, 0 65%); }
.warmode #legend .wl i.bt { border: 0; border-radius: 0; background: var(--ink); clip-path: polygon(50% 0, 62% 35%, 100% 50%, 62% 65%, 50% 100%, 38% 65%, 0 50%, 38% 35%); }
.warmode #cSub { bottom: 70px; }
/* theatre lens */
#cThe { font: 700 11px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); text-shadow: 0 0 3px var(--bg), 0 0 6px var(--bg); }
#cThe:empty { display: none; }
#cine .cinfo #cShot { font: 800 22px/1.15 var(--display); color: var(--ink); max-width: 360px; text-shadow: 0 0 3px var(--bg), 0 0 8px var(--bg); }
#cine .cinfo { gap: 6px; top: 70px; }
#cNow { display: none !important; }
#cCall { position: absolute; left: 0; top: 0; max-width: 250px; padding: 8px 11px; background: var(--bg); border: 1px solid var(--ink); font: 500 13px/1.38 var(--sans); color: var(--ink);
  opacity: 0; transition: opacity .35s; pointer-events: none; }
#cCall.on { opacity: 1; }
#cCall b { display: block; font: 800 11px/1.4 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--highlight); margin-bottom: 2px; }
#cMini { position: absolute; right: 66px; top: 14px; width: 220px; height: 140px; border: 1px solid var(--rule); background: var(--bg); }
#chart.has-the { height: 156px; }
#chart .wthe { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
#chart .wthe button { text-align: left; padding: 6px 9px; border: 0; border-top: 3px solid var(--rule); background: var(--bg); font: 500 12px/1.3 var(--sans); color: var(--ink-3); cursor: pointer; min-height: 52px; overflow: hidden; }
#chart .wthe button b { display: block; font: 800 11px/1.4 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
#chart .wthe button .st { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#chart .wthe button:hover { border-top-color: var(--ink); }
#chart .wthe button.on { border-top-color: var(--highlight); background: var(--chip); color: var(--ink-2); }
.warmode #chart.has-the .warbar { top: 92px; }
.warmode #chart.has-the .wmarks { top: 102px; }
.warmode #chart.has-the .wcur { top: 86px; }
.warmode #chart.has-the .wnow { top: 66px; }
@media (max-width: 760px) { #cMini { display: none; } #chart .wthe { grid-template-columns: repeat(5, minmax(120px, 1fr)); overflow-x: auto; } }
@media (max-width: 1100px) { #cine .cinfo #cShot { font-size: 16px; max-width: 300px; } #cine .cdate b, #cine .cdate span { font-size: 34px; } #cine .cinfo { top: 56px; } }
/* war storyboard: chapter strip in the dock, chapter column */
#chart.story { height: 150px; }
#chart .wchap { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 10px; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; scroll-snap-type: x proximity; }
#chart .wchap button { scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font: 500 12px/1.25 var(--sans); color: var(--ink-2); }
#chart .wchap canvas { width: 132px; height: 79px; display: block; border: 1px solid var(--rule); box-sizing: border-box; background: var(--bg); }
#chart .wchap button:hover canvas { border-color: var(--ink); }
#chart .wchap button.on canvas { border: 3px solid var(--highlight); }
#chart .wchap b { font: 800 10px/1.3 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
#chart .wchap button.on b { color: var(--highlight); }
#chart .wchap button.on span { color: var(--ink); font-weight: 700; }
.chapdate { margin: -6px 0 8px; font: 700 12px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--highlight); }
.mstep.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
ul.changed { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; font-size: 13px; }
ul.changed li { display: flex; align-items: center; gap: 10px; }
ul.changed i { flex: none; width: 24px; display: inline-block; }
ul.changed i.ghost { border-top: 1.5px dashed var(--ink); opacity: .6; }
ul.changed i.solid { height: 2px; background: var(--ink); }
ul.changed i.newg { height: 12px; background: #E5402A; opacity: .7; }
ul.changed i.arr { height: 10px; background: #2B59D9; clip-path: polygon(0 35%, 60% 25%, 60% 0, 100% 50%, 60% 100%, 60% 75%, 0 65%); }
ol.events .det { margin: 4px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
ol.chaps { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
ol.chaps button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 4px 0; font: 500 13px var(--sans); }
ol.chaps button span { width: 76px; flex: none; color: var(--ink-3); font-size: 12px; }
ol.chaps li.now button { font-weight: 700; color: var(--highlight); }
.mnav { flex-wrap: wrap; gap: 8px; } .mnav .mstep.primary { max-width: none; }
/* before the first states: no-records chip, evidence badges, site panel */
#noRecords { position: absolute; left: 20px; top: 16px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--rule); font: 500 12px/1.3 var(--sans); color: var(--ink-2); box-shadow: var(--shadow); }
#noRecords b { color: var(--highlight); font-weight: 700; }
.evb { display: inline-block; padding: 1px 7px; border-radius: 10px; font: 700 10px/1.6 var(--sans); letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; white-space: nowrap; }
.ev-written { background: #dfeee3; color: #1d6b3a; }
.ev-arch { background: #ecebe4; color: #55534a; }
.ev-disputed { background: #fbecd2; color: #8a5a00; }
.ev-legend { background: #f8dcd6; color: #9b2c1a; }
[data-theme="dark"] .ev-written { background: #1f3a29; color: #9fd9b2; }
[data-theme="dark"] .ev-arch { background: #2c2c28; color: #c9c7bd; }
[data-theme="dark"] .ev-disputed { background: #3d3018; color: #f0c674; }
[data-theme="dark"] .ev-legend { background: #43221c; color: #f2a493; }
.mapnote.evnote .evb { margin-bottom: 6px; }
.mapnote.norecords { border-left-color: var(--highlight); }
.mlist .mt .evb { margin-left: 6px; }
.sw.site { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid var(--ink); background: none; }
#chart .nochart { margin: 24px 0 0; max-width: 720px; font-size: 13px; line-height: 1.5; color: var(--ink-3); }

/* list timelines in the bottom section (Wars, Empires, Moments) */
#chart .lchart { position: relative; height: 130px; cursor: pointer; }
#chart .lbar { position: absolute; display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; white-space: nowrap; cursor: pointer; font: 600 11px var(--sans); color: var(--ink-2); }
#chart .lchart.empires .lbar { font-size: 10.5px; font-weight: 500; }
#chart .lbar i { display: block; height: 100%; min-width: 3px; background: var(--other-1); }
#chart .lchart.empires .lbar i { background: var(--other-3); }
#chart .lbar.hot i { background: var(--highlight); }
#chart .lbar:hover i { background: var(--ink); }
#chart .lbar:hover span { color: var(--ink); text-decoration: underline; }
#chart .lmk { position: absolute; width: 10px; height: 10px; margin-left: -5px; padding: 0; border: 1.5px solid var(--bg); background: var(--ink-2); transform: rotate(45deg); cursor: pointer; }
#chart .lmk:hover { background: var(--highlight); z-index: 3; }
#chart .lmk .tipm { display: none; position: absolute; left: 50%; bottom: 10px; transform: rotate(-45deg); transform-origin: left bottom; white-space: nowrap; background: var(--ink); color: var(--bg); font: 600 11px var(--sans); padding: 3px 7px; pointer-events: none; }
#chart .lmk:hover .tipm { display: block; }
#chart .lcur { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--ink); pointer-events: none; opacity: .5; }
#chart:has(.lchart) .legend { left: auto; right: 4px; }
#chart .lbar.flip { flex-direction: row-reverse; }
#chart .lbar.in { display: block; background: var(--other-1); border-right: 1px solid var(--bg); overflow: hidden; text-overflow: ellipsis; padding: 0 4px; font: 500 10px/11px var(--sans); text-align: left; color: var(--ink-2); }
#chart .lbar.in:nth-child(odd) { background: var(--other-3); }
#chart .lbar.in:hover { background: var(--ink); }
#chart .lbar.in:hover span { color: var(--bg); text-decoration: none; }
/* "read more" folds: chapter overviews, map notes */
details.more { margin: 6px 0 0; }
details.more summary { list-style: none; cursor: pointer; font: 600 13px var(--sans); color: var(--highlight); padding: 4px 0; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: " +"; }
details.more[open] summary::after { content: " −"; }
details.more > .prose { margin-top: 6px; }
details.more > aside.mapnote { margin-top: 6px; }
details.more.mapacc { margin-top: 20px; }
#legend span[hidden] { display: none; }
#toast { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -8px); max-width: min(460px, calc(100% - 32px)); padding: 10px 14px; background: var(--ink); color: var(--bg);
  font: 500 13.5px/1.4 var(--sans); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; z-index: 5; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
:root { --water: #9cc0dc; --water-label: #6f93ad; }
:root[data-theme="dark"] { --water: #35566e; --water-label: #7f9fb8; }
/* empire lead picture and ruler portraits */
figure.lead { margin: 14px 0 4px; }
figure.lead img { width: 100%; height: 240px; object-fit: cover; display: block; background: var(--chip); }
figure.lead figcaption { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.45; }
figure.lead figcaption a { color: var(--ink-3); }
ul.rlist.withpic li { grid-template-columns: 44px 1fr auto; align-items: center; }
ul.rlist.withpic .pp { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--chip); display: grid; place-items: center; align-self: start; }
ul.rlist.withpic .pp img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; display: block; }
ul.rlist.withpic .pp.none { font: 800 16px var(--display); color: var(--ink-3); }
ul.rlist.withpic .n { grid-column: 2 / -1; }
details.credits .note { font-size: 12px; }

/* ---------- phones ---------- */
@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto max(62vw, 260px) auto auto; }
  #bar { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 8px; }
  .topnav { margin-left: auto; gap: 14px; }
  .search { order: 3; flex: 1 0 100%; width: 100%; height: 38px; }
  #dock, #col, #stage { min-width: 0; }
  .dock-title { flex: 1; }
  .dock-title > span:first-child { font-size: 14px; overflow-wrap: anywhere; }
  #chart { overflow: hidden; }
  #col .year { font-size: clamp(56px, 18vw, 96px); }
  h2.realm, h1.head { overflow-wrap: anywhere; }
  figure.lead img { height: 200px; }
  #results { max-height: 60vh; }
}
@media (max-width: 420px) {
  .brand { font-size: 12px; letter-spacing: .04em; }
  .topnav { gap: 12px; }
  .topnav a { font-size: 13px; }
  .topnav a#sourcesLink { display: none; }
}
@media (max-width: 900px) { #app { grid-template-rows: auto max(82vw, 300px) auto auto; } }
@media (max-width: 420px) {
  #cine .cdate b, #cine .cdate span { font-size: 22px; }
  #cine .cinfo { top: 40px; }
  #cine #cShot { font-size: 11px; max-width: 70%; }
}
#results li i.kind { font: 600 10px var(--sans); font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--rule); padding: 1px 4px; margin-right: 4px; vertical-align: 1px; }
/* this place through time */
.placebtn { align-self: flex-start; border: 1px solid var(--ink); background: var(--bg); padding: 8px 12px; font: 600 13px var(--sans); }
.placebtn:hover { background: var(--ink); color: var(--bg); }
ol.placetl { list-style: none; margin: 0 0 0 6px; padding: 0; border-left: 2px solid var(--rule); }
ol.placetl li { position: relative; }
ol.placetl li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ink-3); }
ol.placetl li.now::before { background: var(--highlight); border-color: var(--highlight); }
ol.placetl li.gap::before { border-style: dashed; }
ol.placetl .prow { display: grid; grid-template-columns: 128px 1fr; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 0 8px 16px; }
ol.placetl .prow:hover .pn { color: var(--highlight); }
ol.placetl li.gap { display: grid; grid-template-columns: 128px 1fr; gap: 10px; padding: 8px 0 8px 16px; color: var(--ink-3); font-size: 13px; font-style: italic; }
ol.placetl .py { font: 600 12px var(--sans); color: var(--ink-3); font-variant-numeric: tabular-nums; }
ol.placetl .pn { font: 600 14px var(--sans); }
ol.placetl .pn .sq { display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: 0; }
ol.placetl li.now .pn { color: var(--highlight); }
#tooltip .m.disp { margin-top: 4px; border-top: 1px solid var(--rule); padding-top: 4px; }
/* on this day */
aside.today { border: 1px solid var(--ink); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
aside.today .kicker { color: var(--highlight); }
aside.today .tt { margin: 0; font: 700 18px/1.3 var(--display); }
aside.today .note { margin: 0; }
aside.today .playj { align-self: flex-start; margin-top: 4px; }
