@font-face { font-family: "Old Standard"; src: url("../fonts/OldStandard-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Old Standard"; src: url("../fonts/OldStandard-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Old Standard"; src: url("../fonts/OldStandard-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("../fonts/AlegreyaSans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("../fonts/AlegreyaSans-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("../fonts/AlegreyaSans-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("../fonts/AlegreyaSans-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --paper: #f0e2b6;
  --paper-hi: #faf2d6;
  --paper-2: #e6d4a0;
  --paper-3: #cdb97c;
  --ink: #221b13;
  --ink-2: #5a4b36;
  --red: #a8301f;
  --green: #4a7433;
  --ochre: #b9821b;
  --sienna: #8a4a20;
  --display: "Old Standard", "Bodoni 72", Georgia, serif;
  --text: "Alegreya Sans", "Gill Sans", "Trebuchet MS", sans-serif;
  --pane-w: 392px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  height: 100svh; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper); color: var(--ink);
  font: 400 18px/1.4 var(--text);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
[hidden] { display: none !important; }

/* masthead */
#masthead {
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 8px max(16px, env(safe-area-inset-left));
  background: var(--paper); border-top: 6px solid var(--red); border-bottom: 4px double var(--ink);
}
.title { margin: 0; font: 700 25px/1.1 var(--display); letter-spacing: 0.005em; flex: 1 1 auto; min-width: 0; }
.title i { font-weight: 400; }
.title span { display: block; font: italic 400 15px/1.2 var(--display); color: var(--ink-2); margin-top: 2px; }
#searchform { flex: 0 1 340px; }
#q {
  width: 100%; min-height: 44px; padding: 8px 12px; background: var(--paper-hi);
  border: 2px solid var(--ink); border-radius: 0; font-size: 18px;
}
#q::placeholder { color: #7a6a4e; }
nav { display: flex; gap: 4px; }
nav button {
  min-height: 44px; padding: 6px 14px; background: none; border: 0; border-bottom: 4px solid transparent;
  font: 500 18px var(--text);
}
nav button:hover { background: var(--paper-2); }
nav button[aria-pressed="true"] { border-bottom-color: var(--red); font-weight: 700; }

.btn {
  min-height: 44px; padding: 8px 18px; background: var(--paper-hi); border: 2px solid var(--ink); border-radius: 0;
  font: 700 17px var(--text);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--paper-hi); }
.btn.primary:hover { background: var(--ink); border-color: var(--ink); }
.link { background: none; border: 0; padding: 4px 0; color: var(--red); font: 500 17px var(--text); text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.link:hover { color: var(--ink); }

/* stage */
#stage { position: relative; display: flex; min-height: 0; }
#view { position: relative; flex: 1 1 auto; min-width: 0; background: var(--paper-3); }
#osd { position: absolute !important; inset: 0; width: auto !important; height: auto !important; background: #b3a276; }
.hotspots { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; }

#cursor { position: absolute; left: 50%; top: 0; bottom: 0; width: 0; z-index: 3; pointer-events: none; }
#cursor::before { content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--red); box-shadow: 0 0 0 1px rgba(250, 242, 214, 0.75); }
#readout {
  position: absolute; top: 0; left: 0; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; padding: 4px 14px 5px; min-width: 130px;
  background: var(--paper); border: 2px solid var(--ink); border-top: 0;
}
#readout-year { font: 700 30px/1.05 var(--display); white-space: nowrap; }
#readout-sub { font: italic 400 14px/1.2 var(--display); color: var(--ink-2); white-space: nowrap; }

#tip {
  position: absolute; z-index: 6; pointer-events: none; max-width: 280px; padding: 4px 10px;
  background: var(--ink); color: var(--paper-hi); font: 500 16px/1.25 var(--text);
}
#intro {
  position: absolute; left: 14px; bottom: 14px; z-index: 4; max-width: 330px; padding: 12px 14px;
  background: var(--paper); border: 2px solid var(--ink); border-left: 8px solid var(--red);
}
#intro p { margin: 0 0 4px; font-size: 17px; }

#skeleton {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  background:
    linear-gradient(90deg, transparent, rgba(250, 242, 214, 0.55), transparent) 0 0 / 40% 100% no-repeat,
    linear-gradient(180deg, var(--paper-3) 0 14%, rgba(74, 116, 51, 0.35) 14% 18%, var(--paper-3) 18% 24%, rgba(185, 130, 27, 0.4) 24% 29%, var(--paper-3) 29% 34%, rgba(138, 74, 32, 0.38) 34% 40%, var(--paper-3) 40% 48%, rgba(168, 48, 31, 0.3) 48% 53%, var(--paper-3) 53% 100%);
  animation: sweep 1.6s linear infinite;
}
#skeleton p { margin: 0; padding: 10px 18px; background: var(--paper); border: 2px solid var(--ink); font: italic 400 20px var(--display); }
@keyframes sweep { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

#errorbox {
  position: absolute; z-index: 9; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(440px, calc(100% - 32px));
  padding: 20px; background: var(--paper); border: 3px double var(--ink); border-left: 10px solid var(--red);
}
#errorbox h2 { margin: 0 0 6px; font: 700 24px var(--display); }
#errorbox p { margin: 0 0 14px; }
#toast {
  position: absolute; z-index: 10; left: 12px; right: 12px; bottom: 12px; max-width: 520px; display: flex; gap: 14px; align-items: center;
  padding: 10px 14px; background: var(--paper-hi); border: 2px solid var(--ink); border-left: 8px solid var(--red);
}
#toast .toast-text { flex: 1; }

/* pane */
#pane {
  flex: 0 0 var(--pane-w); width: var(--pane-w); display: flex; flex-direction: column; min-height: 0;
  background: var(--paper); border-left: 4px double var(--ink); z-index: 5;
}
.pane-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px; background: var(--paper-2); border-bottom: 1px solid var(--ink); font: 700 17px var(--text); }
.pane-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 24px; overscroll-behavior: contain; }
.kicker { margin: 10px 0 0; font: italic 400 17px var(--display); color: var(--red); }
.moment-year { margin: 0; font: 700 40px/1.05 var(--display); }
.moment-sub { margin: 2px 0 8px; color: var(--ink-2); font-size: 16px; }
.moment-head { padding-bottom: 6px; border-bottom: 3px solid var(--ink); margin-bottom: 8px; }
.pane-body h3 { margin: 18px 0 4px; font: 700 21px var(--display); }
.nation { margin: 10px 0 12px; }
.nation h4 { margin: 0 0 2px; padding-bottom: 2px; font: 700 18px var(--display); border-bottom: 4px solid var(--sw, var(--paper-3)); }
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; flex-direction: column; width: 100%; min-height: 44px; padding: 6px 10px 6px 12px; margin: 3px 0;
  background: none; border: 0; border-left: 8px solid var(--sw, var(--paper-3)); text-align: left;
}
.row:hover { background: var(--paper-2); }
.row-name { font: 500 18px/1.2 var(--text); }
.row-years { font: italic 400 15px/1.2 var(--text); color: var(--ink-2); }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.thumb { display: block; padding: 0; background: none; border: 0; text-align: left; }
.thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-2); border: 1px solid var(--ink); }
.thumb span { display: block; margin-top: 3px; font: 500 15px/1.2 var(--text); }
.thumb:hover span { color: var(--red); text-decoration: underline; }
.empty { padding: 14px 0; }
.empty-title { margin: 0 0 4px; font: 700 20px var(--display); }
.empty p { margin: 0 0 8px; }
.examples { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.count { margin: 4px 0; color: var(--ink-2); font-style: italic; }
.results { list-style: none; margin: 0; padding: 0; }
.result { display: flex; gap: 12px; width: 100%; padding: 6px 4px; background: none; border: 0; text-align: left; align-items: center; }
.result:hover { background: var(--paper-2); }
.result img, .result .noimg { flex: 0 0 64px; width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--ink); background: var(--paper-2); }
.result-text { display: flex; flex-direction: column; min-width: 0; }
.result-name { font: 700 17px/1.2 var(--text); }
.result-sub { font-size: 15px; color: var(--ink-2); }

.detail-media { margin: 10px 0 12px; background: var(--paper-2); border: 1px solid var(--ink); }
.detail-media img { display: block; width: 100%; max-height: 38vh; max-height: 38svh; object-fit: contain; }
.detail-media.plain { display: grid; place-items: center; height: 56px; background: var(--sw, var(--paper-2)); font: italic 400 20px var(--display); }
.detail-title { margin: 0; font: 700 28px/1.1 var(--display); }
.detail-date { margin: 4px 0 10px; font: italic 400 19px var(--display); color: var(--red); }
.detail-caption { margin: 0 0 12px; white-space: pre-line; font-size: 18px; }
.faint { color: var(--ink-2); font-style: italic; }
.meta { margin: 0 0 14px; display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 16px; }
.meta dt { color: var(--ink-2); font-style: italic; }
.meta dd { margin: 0; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.layer-list { list-style: none; margin: 0; padding: 0; }
.layer-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0 10px 10px; border-left: 8px solid var(--sw); margin: 6px 0; }
.layer-list input { width: 22px; height: 22px; margin: 3px 0 0; accent-color: var(--ink); flex: none; }
.layer-list label { display: flex; flex-direction: column; font-size: 16px; }
.layer-list b { font: 700 19px var(--text); }
.skel-rows i { display: block; height: 44px; margin: 10px 0; background: linear-gradient(90deg, var(--paper-2), var(--paper-hi), var(--paper-2)) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* gallery */
#gallery { position: absolute; inset: 0; z-index: 12; overflow-y: auto; background: var(--paper); padding: 0 max(20px, env(safe-area-inset-left)) 40px; }
.gallery-bar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding: 16px 0 8px; }
.gallery-bar h2 { margin: 0; font: 700 32px/1.1 var(--display); }
.era-tabs { display: flex; flex-wrap: wrap; gap: 2px 6px; padding-bottom: 8px; border-bottom: 3px solid var(--ink); margin-bottom: 20px; position: sticky; top: 0; background: var(--paper); z-index: 2; padding-top: 6px; }
.era-tabs button { min-height: 44px; padding: 4px 12px; background: none; border: 0; border-bottom: 4px solid transparent; font: 500 17px var(--text); }
.era-tabs button:hover { background: var(--paper-2); }
.era-tabs button[aria-pressed="true"] { border-bottom-color: var(--red); font-weight: 700; }
.era-tabs .n { color: var(--ink-2); font-weight: 400; }
.plates { column-width: 220px; column-gap: 22px; }
.plate { display: block; width: 100%; margin: 0 0 22px; padding: 0; background: none; border: 0; text-align: left; break-inside: avoid; }
.plate-img { display: block; width: 100%; background: var(--paper-2); border: 1px solid var(--ink); overflow: hidden; }
.plate-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.plate-name { display: block; margin-top: 5px; font: 700 17px/1.2 var(--text); }
.plate-date { display: block; font: italic 400 15px var(--text); color: var(--ink-2); }
.plate:hover .plate-name { color: var(--red); text-decoration: underline; }

/* dock */
#dock {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 20px; align-items: end;
  padding: 6px max(16px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 4px double var(--ink);
}
#jump { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: center; padding-bottom: 2px; }
#jump label { font: 500 16px var(--text); grid-column: 1 / -1; }
#jump input { width: 170px; min-height: 44px; padding: 6px 10px; background: var(--paper-hi); border: 2px solid var(--ink); border-radius: 0; font-size: 18px; }
#jump input[aria-invalid="true"] { border-color: var(--red); background: #f7dcc8; }
.jump-msg { grid-column: 1 / -1; color: var(--red); font-size: 15px; min-height: 0; }
.jump-msg:empty { display: none; }
#scrub { min-width: 0; }
.ticks { position: relative; height: 26px; margin: 0 2px; }
.tick { position: absolute; bottom: 0; width: 1px; height: 6px; background: var(--ink); }
.tick.big { height: 12px; }
.tick i { position: absolute; bottom: 14px; left: 0; transform: translateX(-50%); font: normal 400 14px/1 var(--text); color: var(--ink); white-space: nowrap; }
.tick.mega i { font-weight: 700; }
.strip {
  position: relative; height: clamp(44px, 8svh, 74px); border: 2px solid var(--ink); touch-action: none; cursor: ew-resize;
  background: var(--paper-3) url("../strip.webp") 0 0 / 100% 100% no-repeat;
}
.win { position: absolute; top: -2px; bottom: -2px; border: 3px solid var(--red); background: rgba(168, 48, 31, 0.14); pointer-events: none; }
.line { position: absolute; top: -8px; bottom: -2px; width: 3px; margin-left: -1px; background: var(--ink); pointer-events: none; }
#credits { grid-column: 1 / -1; margin: 2px 0 0; font-size: 14.5px; line-height: 1.25; color: var(--ink-2); }

@media (max-width: 1100px) { .tick.big:not(.mega) i { display: none; } }
@media (max-width: 760px) {
  .title { font-size: 21px; flex-basis: 100%; }
  .title span { font-size: 14px; }
  #searchform { flex: 1 1 100%; order: 2; }
  nav { order: 3; flex: 1 1 100%; justify-content: space-between; }
  nav button { flex: 1; padding: 6px 4px; }
  #pane { position: absolute; inset: 0; width: 100%; flex: none; border-left: 0; z-index: 15; }
  #dock { grid-template-columns: 1fr; }
  #jump { grid-template-columns: auto minmax(0, 1fr) auto; }
  #jump label { grid-column: auto; }
  #jump input { width: 100%; }
  .jump-msg { grid-column: 1 / -1; }
  #credits { font-size: 13px; }
  #readout-year { font-size: 24px; }
  #readout { min-width: 100px; }
  #intro { right: 14px; max-width: none; }
  .gallery-bar { flex-direction: column; gap: 8px; }
  .gallery-bar h2 { font-size: 26px; }
  .plates { column-width: 150px; column-gap: 14px; }
  .detail-media img { max-height: 32svh; }
}
@media (max-height: 560px) { .title span { display: none; } #credits { display: none; } }
@media (prefers-reduced-motion: reduce) { #skeleton, .skel-rows i { animation: none; } }

#q::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

body:not([data-ready]) #cursor, body:not([data-ready]) #intro { display: none; }
.tick:first-child i { transform: none; }
.tick:last-child i { transform: translateX(-100%); }
#masthead { position: relative; }
#masthead::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; z-index: 6;
  background: linear-gradient(90deg, var(--green) 0 22%, var(--ochre) 22% 41%, var(--sienna) 41% 63%, var(--red) 63% 78%, var(--ink) 78% 100%);
}
@media (max-width: 760px) {
  #masthead { gap: 6px 10px; padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .title { font-size: 19px; }
  .title span { display: none; }
  #q, nav button, #jump input { min-height: 40px; }
  #readout-sub { display: none; }
  #readout { padding: 2px 10px 3px; min-width: 0; }
  #readout-year { font-size: 22px; }
  #credits { font-size: 12px; line-height: 1.2; }
  #jump label { font-size: 15px; }
}
.nation-sub { margin: 2px 0 2px; font: italic 400 15px/1.25 var(--text); color: var(--ink-2); }
@media (max-width: 760px) { .tick:first-child i { display: none; } }
