/* history-ab.css
 *
 * Scoped to the Before & After map. Chrome matches the Map Trainer
 * (Fraunces + Inter, the History amber) so the two tools read as a pair.
 * The stage is dark because the maps themselves are dark: a light frame
 * around a navy map fights it, and these are made to be projected.
 */

.ab-page {
  --ab-ink: #1b1a19;
  --ab-muted: #6b6560;
  --ab-line: #e4ded5;
  --ab-amber: #b45309;
  --ab-amber-soft: #fbf1e4;
  --ab-stage: #0e1220;

  background: #fbfaf8;
  color: var(--ab-ink);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 1rem; top: 1rem; z-index: 60;
  padding: 0.55rem 0.9rem; background: var(--ab-amber); color: #fff;
  border-radius: 8px; font-weight: 600; text-decoration: none;
  transform: translateY(-160%); transition: transform 0.15s ease;
}
.skip-link:focus { transform: translateY(0); }

.ab-page button, .ab-page select, .ab-page input { font: inherit; }
.ab-page :focus-visible {
  outline: 3px solid var(--ab-amber); outline-offset: 2px; border-radius: 4px;
}

/* ------------------------------------------------------------------ header */

.ab-header { border-bottom: 1px solid var(--ab-line); background: #fff; }
.ab-header-inner {
  max-width: 1240px; margin: 0 auto; padding: 1rem 1.25rem 1.15rem;
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 1rem 1.4rem;
}
.ab-back { color: var(--ab-amber); font-weight: 600; text-decoration: none; white-space: nowrap; }
.ab-back:hover { text-decoration: underline; }

.ab-eyebrow {
  margin: 0; font-size: 0.76rem; letter-spacing: 0.09em;
  text-transform: uppercase; font-weight: 700; color: var(--ab-amber);
}
.ab-ident h1 {
  margin: 0.1rem 0 0.15rem; font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.5rem, 3.4vw, 2.05rem); line-height: 1.1;
}
.ab-status { margin: 0; font-size: 0.88rem; color: var(--ab-muted); }
.ab-status strong { color: var(--ab-ink); }

.ab-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.ab-btn {
  border: 1px solid #d8d1c7; background: #fff; color: var(--ab-ink);
  padding: 0.46rem 0.85rem; border-radius: 8px;
  font-size: 0.86rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ab-btn:hover { border-color: var(--ab-amber); color: var(--ab-amber); }
.ab-btn[aria-pressed="true"] { background: var(--ab-amber); border-color: var(--ab-amber); color: #fff; }
.ab-btn-quiet { background: transparent; border-color: transparent; color: var(--ab-muted); }
.ab-btn-quiet:hover { border-color: #d8d1c7; }
.ab-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.ab-btn:disabled:hover { border-color: #d8d1c7; color: var(--ab-ink); }

/* ------------------------------------------------------------- edition rail */

.ab-rail-wrap {
  border-bottom: 1px solid var(--ab-line); background: #fff;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.ab-rail {
  max-width: 1240px; margin: 0 auto; padding: 0.7rem 1.25rem;
  display: flex; gap: 0.5rem;
}
.ab-tab {
  border: 1px solid #ded7cd; background: #fff; border-radius: 10px;
  padding: 0.5rem 0.85rem; cursor: pointer; text-align: left;
  display: grid; gap: 0.1rem; min-width: 11rem; flex: 0 0 auto;
}
.ab-tab:hover { border-color: #c3a882; }
.ab-tab[aria-current="page"] { border-color: var(--ab-amber); background: var(--ab-amber-soft); }
.ab-tab-name { font-weight: 700; font-size: 0.92rem; }
.ab-tab-meta {
  font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ab-muted); font-weight: 600;
}

/* -------------------------------------------------------------------- main */

.ab-main {
  max-width: 1240px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1.25rem; align-items: start;
}

/* ------------------------------------------------------------------- stage */

.ab-stage { min-width: 0; display: grid; gap: 0.75rem; }

.ab-stage-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
}
.ab-modes { display: flex; gap: 0.4rem; }
.ab-mode {
  border: 1px solid #ded7cd; background: #fff; color: var(--ab-ink);
  padding: 0.4rem 0.8rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.ab-mode:hover { border-color: #c3a882; }
.ab-mode[aria-pressed="true"] { background: var(--ab-amber); border-color: var(--ab-amber); color: #fff; }
.ab-mode:disabled { opacity: 0.38; cursor: not-allowed; }
.ab-mode:disabled:hover { border-color: #ded7cd; }

.ab-years { display: flex; gap: 0.4rem; align-items: center; }
.ab-years[hidden] { display: none; }
.ab-year {
  border: 1px solid #ded7cd; background: #fff; color: var(--ab-muted);
  padding: 0.35rem 0.8rem; border-radius: 8px;
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.ab-year[aria-pressed="true"] { background: var(--ab-amber); border-color: var(--ab-amber); color: #fff; }
.ab-year:hover { border-color: #c3a882; }

/* the frame */

.ab-frame {
  position: relative; background: var(--ab-stage);
  border: 1px solid #d8d1c7; border-radius: 12px; overflow: hidden;
  touch-action: pan-y;
}
.ab-frame img {
  display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none;
}
.ab-layer {
  position: absolute; inset: 0;
}
.ab-layer img { width: 100%; height: 100%; object-fit: contain; }

/* wipe */
.ab-frame[data-mode="wipe"] .ab-layer-after { clip-path: inset(0 0 0 var(--wipe, 50%)); }

.ab-handle {
  position: absolute; top: 0; bottom: 0; left: var(--wipe, 50%);
  width: 2px; background: rgba(255,255,255,0.85);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  transform: translateX(-1px); cursor: ew-resize; z-index: 3;
}
.ab-handle::after {
  content: "";
  position: absolute; top: 50%; left: 50%;
  width: 2.6rem; height: 2.6rem; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(255,255,255,0.95);
  box-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
.ab-handle::before {
  content: "‹ ›";
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1; font-size: 1.15rem; font-weight: 700; color: #1b1a19;
  letter-spacing: 0.12em; line-height: 1;
}
.ab-frame:not([data-mode="wipe"]) .ab-handle { display: none; }

/* Year stamp on the wipe. Only the later map needs one: the earlier map's own
   title block sits top-left and stays visible, while the later map's title is
   hidden behind the wipe until the handle reaches the far left. */
.ab-stamp {
  position: absolute; top: 0.7rem; z-index: 2;
  font-family: Fraunces, Georgia, serif; font-weight: 700;
  font-size: clamp(0.85rem, 1.7vw, 1.15rem);
  color: #fff; background: rgba(14,18,32,0.72);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 0.2rem 0.7rem; border-radius: 999px;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.ab-stamp-after { right: 0.7rem; }
.ab-frame:not([data-mode="wipe"]) .ab-stamp { display: none; }

/* flip */
.ab-frame[data-mode="flip"] .ab-layer-after { opacity: 0; }
.ab-frame[data-mode="flip"][data-year="after"] .ab-layer-after { opacity: 1; }
.ab-frame[data-mode="flip"] .ab-layer { transition: opacity 0.12s linear; }
@media (prefers-reduced-motion: reduce) {
  .ab-frame[data-mode="flip"] .ab-layer { transition: none; }
}

/* side by side */
.ab-pair { display: none; gap: 0.6rem; }
.ab-frame[data-mode="pair"] { background: transparent; border: 0; }
.ab-frame[data-mode="pair"] .ab-single { display: none; }
.ab-frame[data-mode="pair"] .ab-pair { display: grid; grid-template-columns: 1fr 1fr; }
.ab-pair figure { margin: 0; display: grid; gap: 0.35rem; }
.ab-pair img {
  border: 1px solid #d8d1c7; border-radius: 10px; background: var(--ab-stage);
}
.ab-pair figcaption {
  font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* the wipe slider (keyboard + a11y path) */
.ab-slider-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 0.7rem; font-size: 0.82rem; color: var(--ab-muted); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ab-frame:not([data-mode="wipe"]) ~ .ab-slider-row { display: none; }
.ab-slider-row input[type="range"] { width: 100%; accent-color: var(--ab-amber); }

.ab-hint { margin: 0; font-size: 0.84rem; color: var(--ab-muted); }
.ab-hint kbd {
  font: inherit; font-weight: 700; background: #fff; border: 1px solid #ded7cd;
  border-bottom-width: 2px; border-radius: 5px; padding: 0.02rem 0.34rem;
}

.ab-warn {
  margin: 0; font-size: 0.84rem; color: #7c2d12;
  background: var(--ab-amber-soft); border: 1px solid #e7cfae;
  border-radius: 8px; padding: 0.55rem 0.75rem;
}

/* ------------------------------------------------------------------- aside */

.ab-aside { display: grid; gap: 1rem; align-content: start; }

.ab-card {
  background: #fff; border: 1px solid var(--ab-line);
  border-radius: 12px; padding: 1rem 1.1rem;
}
.ab-card h2 {
  margin: 0 0 0.5rem; font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem; line-height: 1.25;
}
.ab-card p { margin: 0 0 0.6rem; font-size: 0.9rem; line-height: 1.6; }
.ab-card p:last-child { margin-bottom: 0; }
.ab-card .ab-thesis {
  font-family: Fraunces, Georgia, serif; font-size: 0.98rem;
  line-height: 1.5; color: var(--ab-ink);
}

.ab-changes { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.65rem; }
.ab-changes li { font-size: 0.88rem; line-height: 1.55; }
.ab-changes b {
  display: block; font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ab-amber); font-weight: 700;
}

.ab-colophon {
  grid-column: 1 / -1; margin: 1.5rem 0 0; padding-top: 1rem;
  border-top: 1px solid var(--ab-line);
  font-size: 0.82rem; color: var(--ab-muted); line-height: 1.6;
}
.ab-colophon a { color: var(--ab-amber); }

/* ----------------------------------------------------------------- present */

.ab-page.present .ab-header,
.ab-page.present .ab-rail-wrap,
.ab-page.present .ab-aside,
.ab-page.present .ab-colophon,
.ab-page.present .ab-hint { display: none; }
.ab-page.present { background: #0e1220; }
.ab-page.present .ab-main {
  max-width: none; padding: 0.75rem; grid-template-columns: 1fr;
  min-height: 100vh; align-content: center;
}
.ab-page.present .ab-frame { border-color: #2a3348; }
.ab-page.present .ab-mode,
.ab-page.present .ab-year {
  background: #1a2036; border-color: #2f3a52; color: #e8e6e1;
}
.ab-page.present .ab-mode[aria-pressed="true"],
.ab-page.present .ab-year[aria-pressed="true"] {
  background: var(--ab-amber); border-color: var(--ab-amber); color: #fff;
}
.ab-page.present .ab-slider-row { color: #9aa3b8; }
.ab-page.present .ab-warn { background: #2a2010; border-color: #4d3a17; color: #f0d9b5; }
.ab-page.present .ab-pair figcaption { color: #e8e6e1; }
.ab-present-exit { display: none; }
.ab-page.present .ab-present-exit {
  display: inline-block; position: fixed; top: 0.8rem; right: 0.9rem; z-index: 50;
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 960px) {
  .ab-main { grid-template-columns: 1fr; }
  .ab-header-inner { grid-template-columns: 1fr; gap: 0.55rem; }
  .ab-toolbar { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .ab-frame[data-mode="pair"] .ab-pair { grid-template-columns: 1fr; }
  .ab-stage-top { align-items: flex-start; flex-direction: column; }
  .ab-modes { flex-wrap: wrap; }
}
