/* The original design's paper, ink and serif headings, with blue in place of green. */
:root {
  color-scheme: light;
  --ink: #1c2c47;
  --muted: #5b6577;
  --paper: #f6f3eb;
  --band: #fbf9f4;
  --line: #c4c9d2;
  --blue: #1f4f99;
  --menu: 88px;
  --rail: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--blue); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
button, select, input { font: inherit; color: var(--ink); }

/* Header: title and eras on one line, filters and status on another */
#menu {
  position: fixed; inset: 0 0 auto 0; z-index: 30; background: var(--paper); border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 16px; row-gap: 7px; padding: 9px 20px;
}
#menu h1 { font: 700 24px/1.15 Georgia, serif; margin: 0; white-space: nowrap; }
#status { grid-column: 3; grid-row: 2; white-space: nowrap; font-size: 13px; text-align: right; }
#status b { font-weight: 700; }
#eras { grid-column: 2 / -1; grid-row: 1; display: flex; gap: 5px; overflow-x: auto; align-items: center; scrollbar-width: none; min-width: 0; }
#eras::-webkit-scrollbar { display: none; }
#menu button, #menu select, #menu input[type=search] { border: 1px solid var(--line); border-radius: 7px; background: #fff; height: 31px; font-size: 13px; }
#menu button { cursor: pointer; white-space: nowrap; padding: 0 10px; }
#menu button:hover { border-color: var(--ink); }
#menu button[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: #fff; }
#eras button { padding: 0 8px; font-size: 12.5px; flex: none; }
.controls { grid-column: 1 / 3; grid-row: 2; display: flex; align-items: center; gap: 6px; min-width: 0; }
.controls select { padding: 0 4px; max-width: 124px; }
.controls #calendar { max-width: 165px; }
.controls input[type=search] { flex: 1 1 100px; min-width: 80px; padding: 0 9px; }
#lenses { display: flex; gap: 3px; flex: none; }
#lenses button { padding: 0 7px; font-size: 12.5px; }
.controls > button { flex: none; }
#menu-toggle { display: none; }

/* Timeline */
#stage {
  position: relative; margin-top: var(--menu); background: #fff;
  height: calc(100vh - 2 * var(--menu)); height: calc(100dvh - 2 * var(--menu));
  min-height: 380px; overflow: hidden;
}
#scroller { position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; cursor: grab; touch-action: pan-x pan-y; }
#scroller::-webkit-scrollbar { display: none; }
#scroller.dragging { cursor: grabbing; user-select: none; }
#world { position: relative; height: 100%; }
.band { position: absolute; top: 0; bottom: 0; }
.band.alt { background: var(--band); }
#axis { position: absolute; left: 0; height: 2px; background: var(--ink); transform: translateY(-1px); z-index: 2; }
.tick { position: absolute; width: 1px; height: 8px; background: var(--ink); transform: translateY(-4px); z-index: 2; }
.tick.major { height: 13px; transform: translateY(-6px); }
.tick-label { position: absolute; transform: translateX(-50%); font-size: 11px; line-height: 14px; color: var(--muted); white-space: nowrap; z-index: 3; pointer-events: none; padding: 0 3px; background: #fff; }
.tick-label.major { font-size: 12.5px; color: var(--ink); }
#boundary { position: absolute; width: 2px; background: var(--blue); z-index: 3; pointer-events: none; }
.boundary-label { position: absolute; transform: translateX(-50%); font-size: 12px; font-weight: 600; line-height: 18px; color: #fff; background: var(--blue); padding: 0 8px; border-radius: 4px; white-space: nowrap; z-index: 4; pointer-events: none; }
#today { position: absolute; width: 2px; background: var(--ink); z-index: 3; }
#today-label { position: absolute; font-size: 12px; font-weight: 600; line-height: 18px; color: #fff; background: var(--ink); padding: 0 8px; border-radius: 4px; white-space: nowrap; z-index: 4; }

.line { position: absolute; width: 1px; background: #8d94a3; pointer-events: none; }
.dot { position: absolute; width: 7px; height: 7px; background: var(--ink); border-radius: 50%; transform: translate(-3px, -3px); z-index: 3; pointer-events: none; }
.dot.big { background: var(--blue); width: 9px; height: 9px; transform: translate(-4px, -4px); }
.line.on, .line.hot { width: 2px; background: var(--blue); z-index: 4; }
.dot.on, .dot.hot { background: var(--blue); width: 11px; height: 11px; transform: translate(-5px, -5px); z-index: 5; }

.ev {
  position: absolute; display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; cursor: pointer; z-index: 1;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 7px;
}
.ev:hover { border-color: var(--ink); z-index: 6; }
.ev-label { display: block; flex: none; padding: 4px 7px 5px; }
.ev-title {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--c, 2); overflow: hidden;
  font: 700 var(--t, 12px)/1.18 Georgia, serif;
}
.ev-date { display: block; margin-top: 1px; font-size: var(--d, 11px); line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.on { background: var(--blue); border-color: var(--blue); color: #fff; z-index: 6; }
.ev.on .ev-date { color: #fff; }
.ev-mark { color: var(--blue); }
.ev.on .ev-mark { color: #fff; }
.ev-image { display: block; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--paper); }
.ev-image img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }

.end { position: absolute; top: 50%; z-index: 8; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 0 7px; font-size: 11px; font-weight: 700; letter-spacing: .12em; line-height: 20px; transform: translateY(-50%); pointer-events: none; }
#end-past { left: 6px; }
#end-present { right: 6px; }
.edge { position: absolute; top: 0; bottom: var(--rail); width: 10%; z-index: 7; pointer-events: none; display: flex; align-items: flex-start; padding-top: 8px; opacity: 0; color: var(--blue); font-size: 30px; font-weight: 700; line-height: 1; }
.edge.on { opacity: 1; }
#edge-left { left: 0; justify-content: flex-start; padding-left: 12px; }
#edge-right { right: 0; justify-content: flex-end; padding-right: 12px; }
#rail { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: var(--rail); margin: 0; -webkit-appearance: none; appearance: none; background: var(--paper); border-top: 1px solid var(--line); cursor: ew-resize; z-index: 9; }
#rail::-webkit-slider-runnable-track { height: 100%; background: transparent; }
#rail::-moz-range-track { height: 100%; background: transparent; }
#rail::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb, 40px); height: var(--rail); background: var(--blue); border-radius: 3px; }
#rail::-moz-range-thumb { width: var(--thumb, 40px); height: var(--rail); background: var(--blue); border: 0; border-radius: 3px; }

/* List view */
#list-view { position: absolute; inset: 0; overflow: auto; background: #fff; z-index: 10; padding: 8px 28px; }
#list-view table { border-collapse: collapse; width: 100%; }
#list-view th { text-align: left; position: sticky; top: 0; background: #fff; }
#list-view td, #list-view th { padding: 10px 12px; border-bottom: 1px solid var(--line); }
#list-view button { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; text-align: left; cursor: pointer; }
#list-view button:hover { border-color: var(--ink); }
#empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: #fff; z-index: 10; text-align: center; padding: 16px; }
#empty h2 { margin: 0; font: 700 26px/1.2 Georgia, serif; }
#empty p { margin: 0; }
#empty button { border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; background: #fff; cursor: pointer; }

/* Selected event, laid out like the original slide */
#panel { background: #fff; border-top: 1px solid var(--line); min-height: var(--menu); }
#panel-inner { display: grid; grid-template-columns: minmax(240px, 34%) minmax(0, 1fr); gap: 36px; max-width: 1240px; margin: 0 auto; padding: 10px 28px 36px; }
#panel-inner.solo { grid-template-columns: minmax(0, 1fr); }
#figure { margin: 0; }
#figure img { display: block; width: 100%; height: auto; }
#figure figcaption { font-size: 12px; line-height: 1.35; color: var(--muted); margin-top: 6px; }
#figure figcaption > * { display: block; margin-top: 3px; }
#peek-date { margin: 0; font-size: 15px; color: var(--muted); }
#peek-title { margin: 0 0 4px; font: 700 26px/1.15 Georgia, serif; }
#peek-summary { margin: 0 0 8px; }
#peek-hint { display: inline-block; font-size: 13px; font-weight: 600; color: var(--blue); margin-bottom: 8px; }
#article p { margin: 0 0 12px; }
#article h3 { font: 700 18px/1.25 Georgia, serif; margin: 22px 0 6px; }
.tags { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 5px; list-style: none; padding: 0; }
.tag { display: inline-block; padding: 1px 7px; font-size: 13px; border: 1px solid var(--line); border-radius: 4px; }
.tag.mark { border-color: var(--blue); color: var(--blue); font-weight: 600; }
#languages { margin: 4px 0 14px; padding: 10px 12px; background: var(--paper); border-radius: 7px; }
#languages p { margin: 0 0 5px; font-size: 12px; font-weight: 600; }
.lang-row { display: flex; flex-wrap: wrap; gap: 4px; }
.lang-row button { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.lang-row button:hover { border-color: var(--ink); }
.lang-row button[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: #fff; }
.note { border-left: 3px solid var(--blue); padding: 2px 0 2px 10px; font-size: 14px; }
.small { font-size: 13px; }

#about { display: flex; gap: 24px; padding: 8px 28px; font-size: 12px; background: var(--paper); border-top: 1px solid var(--line); }
#about details { flex: 1; }
#about summary { cursor: pointer; }
#about p { max-width: 900px; }

dialog { border: 1px solid var(--line); border-radius: 7px; padding: 20px; max-width: 460px; width: calc(100% - 32px); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(28, 44, 71, .5); }
dialog h2 { margin: 0 0 6px; font: 700 22px/1.2 Georgia, serif; }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 3px; font-size: 12px; font-weight: 600; }
dialog input, dialog select { height: 34px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; background: #fff; font-size: 14px; font-weight: 400; }
dialog ul { margin: 12px 0 0; padding: 0; list-style: none; font-size: 14px; }
dialog li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
dialog button { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 6px 10px; cursor: pointer; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
dialog button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
#error { color: var(--blue); font-size: 13px; font-weight: 600; margin: 0; }

/* Smaller windows: the filters fold behind the Menu button */
@media (max-width: 1360px) {
  #menu { grid-template-columns: auto minmax(0, 1fr) auto; }
  #status { grid-column: 2; grid-row: 1; }
  #menu-toggle { display: inline-block; grid-column: 3; grid-row: 1; }
  #eras { grid-column: 1 / -1; grid-row: 2; }
  .controls { grid-column: 1 / -1; grid-row: 3; flex-wrap: wrap; }
  #menu .controls { display: none; }
  #menu.open .controls { display: flex; }
  #menu.open { max-height: 100dvh; overflow: auto; }
  #panel-inner { gap: 24px; }
}
@media (max-width: 850px) {
  :root { --menu: 44px; }
  #menu { padding: 6px 12px; }
  #menu h1 { font-size: 18px; }
  #status { font-size: 11.5px; }
  #menu #eras { display: none; }
  #menu.open #eras { display: flex; flex-wrap: wrap; }
  #panel-inner, #panel-inner.solo { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 8px 14px 28px; }
  #panel { min-height: var(--menu); }
  #peek-title { font-size: 22px; }
  #peek-date { font-size: 13px; }
  #about { padding: 12px 14px; }
  #about > span { display: none; }
  #list-view { padding: 6px 10px; }
  #list-view td, #list-view th { padding: 6px; }
}
