/* ════════════════════════════════════════
   MAP — "Portugal Through Time" (full page)
   Same page/panel shell as At a Glance (.ag-page/.ag-panel); the map,
   chapter panel and year slider are driven by js/portugal-map.js.
   Layout and controls mirror the christianity-history map page; loaded
   after style.css, so these rules win over its world-map (.cm-*) styles.
════════════════════════════════════════ */
body.map-page-open #app,
body.map-page-open #scroll-hint { display:none; }

.cm-header { margin-bottom:30px; }
.cm-subtitle { max-width:760px; }

/* The map spans the full width; the chapter panel (.cm-side) floats over
   its right side. fitAspect() in js/portugal-map.js measures the panel
   so chapter views are framed in the uncovered area to its left. */
.cm-body {
  --cm-side-w:clamp(449px, calc(33.35% + 58px), 633px); /* +15% */
  position:relative;
  isolation:isolate; /* keeps the overlays below the sticky .cm-controls */
  container-type:inline-size; /* lets .cm-stage size its height off this width */
}

/* ── Map stage ── */
.cm-stage {
  position:relative;
  height:calc(100cqw * 5.95 / 16 + 50px); /* 16 / 5.95 plus 50px */
  min-height:484px;
  max-height:max(484px, calc(70vh + 8px));
  background:#0b0913;
  overflow:hidden;
  touch-action:none;
  user-select:none;
}
.cm-stage svg { display:block; width:100%; height:100%; cursor:grab; }
.cm-stage svg.is-dragging { cursor:grabbing; }
.cm-loading {
  position:absolute; inset:0; display:grid; place-items:center;
  font-family:var(--f-ui); font-size:15px; color:var(--white-dim);
}
.cm-sphere { fill:#0d0b16; }
.cm-stage svg path { vector-effect:non-scaling-stroke; }
.cm-grat { fill:none; stroke:rgba(201,168,68,0.08); stroke-width:0.6; vector-effect:non-scaling-stroke; }
.cm-land { fill:#1b1822; stroke:#2e2a36; stroke-width:0.6; vector-effect:non-scaling-stroke; pointer-events:none; }
.cm-reg {
  --c:#2a2633; --e:#4a4555;
  fill:var(--c); stroke:var(--e); stroke-width:0.5; vector-effect:non-scaling-stroke;
  opacity:0; transition:opacity 0.45s ease, fill 0.45s ease, stroke 0.45s ease;
}
.cm-reg.on { opacity:0.9; }
.cm-reg--lin { --c:#6e8290; --e:#8fa3b0; }
.cm-reg--lin.on { opacity:0.6; }
.cm-reg--emp   { --c:#94762e; --e:#c9a844; stroke-width:0.6; }
.cm-reg--union { --c:#d2bd85; --e:#f0e0b7; stroke-width:0.6; }
.cm-reg--pt    { --c:var(--gold); --e:#f1dda0; stroke-width:0.8; }
.cm-reg:not(.on) { pointer-events:none; }
.cm-reg:hover { opacity:1; stroke:var(--gold); stroke-width:1.4; }
.cm-reg--pt:hover { stroke:#fff; }
.cm-ref {
  fill:none; stroke:#fff; stroke-width:0.9; stroke-dasharray:4 3;
  vector-effect:non-scaling-stroke; pointer-events:none; transition:opacity 0.5s;
}
/* Legend / tooltip swatches share the region colours. */
.cm-sw { display:inline-block; width:11px; height:11px; flex:none; }
.cm-sw--pt { background:var(--gold); }
.cm-sw--emp { background:#94762e; }
.cm-sw--union { background:#d2bd85; }
.cm-sw--lin { background:#6e8290; }
.cm-sw--other { background:#2a2633; box-shadow:inset 0 0 0 1px #5a5565; }
.cm-sw--ref { background:none; border:1.5px dashed #fff; }
.cm-sw--ot { background:#f4ecd6; border-radius:50%; box-shadow:0 0 0 1.5px var(--gold); }

.cm-place { cursor:pointer; transition:opacity 0.6s ease; }
.cm-place .cm-dot { fill:#f4ecd6; stroke:#08060f; stroke-width:1.2; vector-effect:non-scaling-stroke; }
.cm-place .cm-halo { fill:none; stroke:var(--gold); stroke-width:1.2; vector-effect:non-scaling-stroke; opacity:0.8; }
.cm-place.new .cm-halo { animation:cm-pulse 1.8s ease-out 2; }
@keyframes cm-pulse { 0% { stroke-width:1; opacity:1; } 100% { stroke-width:9; opacity:0; } }
.cm-place.past .cm-dot { fill:#8f8a82; }
.cm-place text {
  font-family:var(--f-heading); font-weight:600; fill:var(--white);
  paint-order:stroke; stroke:#08060f; stroke-linejoin:round;
  pointer-events:none;
}

.cm-year-badge {
  position:absolute; left:20px; top:20px; z-index:3; pointer-events:none;
  padding:14px 22px 14px 20px;
  background:rgba(8,6,16,0.62);
  border:1px solid rgba(255,255,255,0.12);
  border-radius:6px;
  -webkit-backdrop-filter:blur(5px); backdrop-filter:blur(5px);
}
.cm-year {
  font-family:var(--f-heading); font-weight:600;
  font-size:clamp(30px, 4vw, 48px); line-height:1.05;
  color:var(--white);
}
.cm-era {
  margin-top:6px;
  font-family:var(--f-ui); font-size:15px; font-weight:500;
  letter-spacing:2px; text-transform:uppercase; color:var(--gold);
}
/* Kings / presidents in power for the shown year. */
.cm-pop {
  display:flex; align-items:center; gap:10px;
  margin-top:10px;
  font-family:var(--f-ui); font-size:17px; font-weight:500; color:var(--white);
  font-variant-numeric:tabular-nums;
}
.cm-pop[hidden] { display:none; }
/* Beats .cm-stage svg's full-size map rule. */
.cm-stage .cm-pop svg { width:22px; height:22px; cursor:inherit; }
.cm-pop-icon { flex:none; color:var(--gold); }
.cm-pop-info {
  display:grid; place-items:center; flex:none;
  margin-left:2px; padding:0; color:var(--gold);
  pointer-events:auto; cursor:help; border-radius:50%;
  transition:color 0.2s;
}
.cm-pop-info:hover, .cm-pop-info:focus-visible { color:var(--white); outline:none; }

.cm-map-btns { position:absolute; right:calc(var(--cm-side-w) + 44px); top:16px; display:flex; flex-direction:column; gap:6px; }
.cm-map-btns button {
  display:grid; place-items:center;
  width:38px; height:38px;
  background:rgba(8,6,16,0.85);
  border:1px solid rgba(201,168,68,0.35);
  color:var(--gold);
  transition:background 0.2s, color 0.2s, border-color 0.2s;
}
.cm-map-btns button:hover,
.cm-map-btns button:focus-visible { background:var(--gold); border-color:var(--gold); color:var(--dark); outline:none; }

.cm-hint {
  position:absolute; left:calc((100% - var(--cm-side-w) - 44px) / 2); top:16px; transform:translateX(-50%);
  padding:8px 14px;
  background:rgba(8,6,16,0.88); border:1px solid rgba(201,168,68,0.3);
  font-family:var(--f-ui); font-size:14px; color:var(--white);
  white-space:nowrap; pointer-events:none;
  opacity:0; transition:opacity 0.25s ease;
}
.cm-hint.is-visible { opacity:1; }
@media (hover:none) { .cm-hint { display:none; } }

.cm-tip {
  position:absolute; z-index:5; max-width:290px;
  padding:10px 12px;
  background:rgba(15,11,25,0.97);
  border:1px solid rgba(201,168,68,0.3);
  box-shadow:0 10px 28px rgba(0,0,0,0.5);
  font-family:var(--f-ui); font-size:14px; line-height:1.4; color:var(--white-mid);
  pointer-events:none; opacity:0; transition:opacity 0.15s;
}
.cm-tip.is-visible { opacity:1; }
.cm-tip b { display:block; margin-bottom:4px; font-family:var(--f-heading); font-size:16px; font-weight:600; color:var(--white); }
.cm-tip-status { display:flex; align-items:center; gap:7px; color:var(--white-mid); }
.cm-tip-swatch { width:11px; height:11px; flex:none; }
.cm-tip-note { margin-top:6px; color:var(--white-dim); }

/* ── Chapter panel — a translucent overlay on the right of the map. Its
   height follows the map; long chapters scroll inside it. ── */
.cm-side {
  position:absolute; top:16px; right:32px; bottom:16px; z-index:4;
  width:var(--cm-side-w);
  display:flex; flex-direction:column;
  padding:24px 40px 36px 42px;
  background:rgba(8,6,16,0.62);
  border:1px solid rgba(255,255,255,0.12);
  border-radius:6px;
  -webkit-backdrop-filter:blur(5px); backdrop-filter:blur(5px);
}
/* Only the Key Events list scrolls; the chapter text above it stays put.
   The inner wrapper only scrolls as a fallback when the text alone leaves
   the list less than its min-height (very short maps). */
.cm-side-inner {
  flex:1 1 auto; min-height:0; overflow-x:hidden; overflow-y:auto;
  display:flex; flex-direction:column;
  scrollbar-width:thin; scrollbar-color:rgba(201,168,68,0.35) transparent;
}
.cm-side-inner > * { flex:none; }
/* Key Events use the At a Glance rows (.ag-events / .ag-event) as-is; here
   the list just fills the panel's remaining height and scrolls. */
.cm-side-inner > .cm-events {
  flex:1 1 auto; min-height:80px; margin-bottom:0; padding-right:6px;
  overflow-x:hidden; overflow-y:auto;
  scrollbar-width:thin; scrollbar-color:rgba(201,168,68,0.35) transparent;
}
.cm-events .ag-event { flex:none; }
/* Timeline variant matching the pope modal's "Events During Pontificate"
   (.rp-events-item): year · dim-white dot on a thin vertical line · title.
   Rows touch (padding, no gap) so each row's line segment joins the next;
   x = 50px year + 20px gap + 4px (half the 9px dot). The line fades in/out
   at the ends. Same-year rows (--grouped) drop the year and dot. */
.cm-events { gap:0; }
.cm-events .ag-event {
  display:grid; grid-template-columns:58px 9px minmax(0, 1fr);
  align-items:start; column-gap:20px;
  margin:0; padding:8px 8px 8px 0; border-bottom:none; border-radius:3px;
}
.cm-events .ag-event::before {
  display:block; content:''; position:absolute;
  top:0; bottom:0; width:1px; left:82px; border-left:none;
  background:rgba(255,255,255,0.25);
}
.cm-events .ag-event:first-child::before { background:linear-gradient(to bottom, transparent, rgba(255,255,255,0.25) 18px); }
.cm-events .ag-event:last-child::before { display:block; background:linear-gradient(to bottom, rgba(255,255,255,0.25) calc(100% - 12px), transparent); }
.cm-events .ag-event:only-child::before { display:none; }
.cm-events .ag-event--grouped { padding-top:0; }
.cm-events .ag-event-dot {
  position:relative; z-index:1;
  margin-top:7px; width:9px; height:9px; border-radius:50%;
  background:var(--white-dim);
}
.cm-events .ag-event--grouped .ag-event-dot { visibility:hidden; }
.cm-events .ag-event-year { font-family:var(--f-heading); font-size:17px; line-height:1.3; white-space:nowrap; color:var(--white-dim); }
.cm-events .ag-event-body { min-width:0; }
.cm-events .ag-event-text { font-family:var(--f-ui); font-weight:400; font-size:17px; line-height:1.3; color:var(--white); }
.cm-events-heading { margin:42px 0 6px; }
.cm-side-inner.is-fading { animation:cm-fade 0.5s ease; }
@keyframes cm-fade { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
.cm-chapter-kicker {
  font-family:var(--f-ui); font-size:14px; font-weight:500;
  letter-spacing:2px; text-transform:uppercase; color:var(--gold);
}
.cm-chapter-title {
  margin:6px 0 10px;
  font-family:var(--f-heading); font-weight:600; font-size:25.5px; line-height:1.15;
  color:var(--white);
}
.cm-chapter-text { font-size:16px; line-height:1.55; color:var(--white-mid); }
.cm-chapter-stat {
  margin-top:10px; padding:6px 12px;
  border-left:2px solid var(--gold);
  background:rgba(201,168,68,0.06);
  font-family:var(--f-ui); font-size:14px; line-height:1.4; color:var(--white);
}
.cm-chapter-stat:not([hidden]) { display:flex; align-items:flex-start; gap:8px; }
.cm-chapter-stat[hidden] { display:none; }
/* Same open-book glyph as the event modal's "Why it matters" heading. */
.cm-chapter-stat-icon {
  flex:none; width:16px; height:16px; margin-top:2px;
  fill:none; stroke:var(--gold); stroke-width:1.6; stroke-linejoin:round;
}

.cm-side-nav {
  display:flex; align-items:center; gap:12px;
  margin-top:20px;
}
.cm-chapter-count {
  flex:1; text-align:center;
  font-family:var(--f-ui); font-size:15px; color:var(--white-dim); font-variant-numeric:tabular-nums;
}
.cm-btn {
  display:inline-flex; align-items:center; gap:10px;
  padding:12px 22px;
  border:1px solid rgba(201,168,68,0.75); border-radius:4px;
  font-family:var(--f-ui); font-size:16px; font-weight:600; color:var(--gold);
  transition:background 0.2s, color 0.2s, border-color 0.2s;
}
.cm-btn:hover:not(:disabled),
.cm-btn:focus-visible { background:var(--gold); border-color:var(--gold); color:var(--dark); outline:none; }
.cm-btn:disabled { opacity:0.3; cursor:default; }

/* ── Timeline controls ── */
/* Sits above the map so the era buttons and slider are visible without
   scrolling. All ten era buttons share one row (names wrap, years sit
   on their own line below). */
/* Desktop/tablet: pins just below the title bar once scrolled (same offset,
   edge-to-edge bleed and .is-stuck shadow as .ag-era-list), so the eras and
   slider stay reachable while reading further down. main.js also snaps the
   first scroll down from the header straight to this position. */
.cm-controls {
  position:sticky; top:18px; z-index:4;
  margin:0 -56px 22px; padding:10px 56px 4px;
  background:rgba(8,6,16,0.97);
  border-bottom:1px solid transparent;
  box-shadow:0 8px 14px -8px rgba(0,0,0,0);
  transition:border-color 0.3s ease, box-shadow 0.3s ease;
}
.cm-controls.is-stuck {
  border-bottom-color:rgba(255,255,255,0.14);
  box-shadow:0 8px 14px -8px rgba(0,0,0,0.5);
}
.cm-eras {
  display:grid; grid-template-columns:repeat(var(--cm-era-count, 10), minmax(0, 1fr)); gap:6px;
}
.cm-eras button {
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  min-width:0; padding:8px 10px;
  border:1px solid rgba(255,255,255,0.14);
  font-family:var(--f-ui); font-size:14px; line-height:1.25; color:var(--white-mid); text-align:center;
  transition:border-color 0.2s, background 0.2s, color 0.2s;
}
.cm-era-name { display:block; font-family:var(--f-heading); font-size:13px; color:var(--gold); }
.cm-eras button small { font-size:12.5px; color:var(--white-dim); font-variant-numeric:tabular-nums; }
.cm-eras button:hover { border-color:rgba(201,168,68,0.45); color:var(--white); }
.cm-eras button.on { border-color:rgba(201,168,68,0.6); background:rgba(201,168,68,0.1); color:var(--white); }

/* Top-aligned so the slider line (22px into .cm-track) can sit level with
   the 48px Play button's centre: track 2px down, options as tall as the button. */
.cm-bar { display:flex; align-items:flex-start; gap:16px; margin-top:12px; }
.cm-play {
  display:inline-flex; align-items:center; gap:12px; flex:none;
  height:48px; padding:0 22px 0 18px;
  background:var(--gold); border:1px solid var(--gold); border-radius:4px; color:var(--dark);
  font-family:var(--f-ui); font-size:17px; font-weight:600; white-space:nowrap;
  transition:background 0.2s, border-color 0.2s;
}
.cm-play:hover { background:var(--gold-dim); border-color:var(--gold-dim); }
.cm-play .cm-icon-pause,
.cm-play.is-playing .cm-icon-play { display:none; }
.cm-play.is-playing .cm-icon-pause { display:block; }

.cm-track { position:relative; flex:1; height:60px; margin-top:2px; }
.cm-segs { position:absolute; left:0; right:0; top:19px; height:6px; display:flex; overflow:hidden; }
.cm-segs div { height:100%; background:rgba(201,168,68,0.35); transition:background 0.3s; }
.cm-segs div.on { background:var(--gold); }
.cm-ticks { position:absolute; left:0; right:0; top:0; height:44px; pointer-events:none; }
.cm-ticks i { position:absolute; top:15px; width:2px; height:14px; margin-left:-1px; background:var(--white); opacity:0.3; }
.cm-ticks i.cur { opacity:1; background:var(--gold); }
/* Chapter years under the ticks (below the slider's 44px hit area). */
.cm-tick-labels { position:absolute; left:0; right:0; top:36px; height:18px; }
.cm-tick-labels button {
  position:absolute; top:0; transform:translateX(-50%);
  padding:1px 2px;
  font-family:var(--f-ui); font-size:10.5px; line-height:1.4; color:var(--white-dim);
  font-variant-numeric:tabular-nums; white-space:nowrap;
  transition:color 0.2s;
}
.cm-tick-labels button:hover { color:var(--white); }
.cm-tick-labels button.cur { color:var(--gold); z-index:1; background:rgba(8,6,16,0.97); }
/* Thinned by thinTickLabels() in js/portugal-map.js. */
.cm-tick-labels button.is-thin:not(.cur) { display:none; }
.cm-track input {
  position:absolute; left:0; right:0; top:0; width:100%; height:44px; margin:0;
  background:transparent; -webkit-appearance:none; appearance:none; cursor:pointer;
}
.cm-track input:focus { outline:none; }
.cm-track input::-webkit-slider-runnable-track { height:44px; background:transparent; }
.cm-track input::-moz-range-track { height:44px; background:transparent; }
.cm-track input::-webkit-slider-thumb {
  -webkit-appearance:none; width:20px; height:20px; margin-top:12px; border-radius:50%;
  background:var(--dark); border:3px solid var(--gold);
  box-shadow:0 2px 8px rgba(0,0,0,0.5);
}
.cm-track input::-moz-range-thumb { width:15px; height:15px; border-radius:50%; background:var(--dark); border:3px solid var(--gold); }
.cm-track input:focus-visible::-webkit-slider-thumb { box-shadow:0 0 0 4px var(--gold-glow); }

.cm-options { display:flex; align-items:center; gap:10px; flex:none; height:48px; }
.cm-speed { display:flex; }
.cm-speed button,
.cm-follow {
  padding:6px 10px;
  border:1px solid rgba(255,255,255,0.14);
  font-family:var(--f-ui); font-size:14px; color:var(--white-mid);
  transition:border-color 0.2s, color 0.2s, background 0.2s;
}
.cm-speed button + button { border-left:none; }
.cm-speed button:hover,
.cm-follow:hover { color:var(--white); border-color:rgba(201,168,68,0.45); }
.cm-speed button.on { color:var(--gold); background:rgba(201,168,68,0.1); }
.cm-follow[aria-pressed="true"] { color:var(--dark); background:var(--gold); border-color:var(--gold); }

/* ── Legend — overlays the bottom of the map. fitAspect() in
   js/portugal-map.js measures it so chapter views frame the map area
   above it rather than disappearing behind it. ── */
.cm-legend {
  /* Sized to its content (not the full map width), capped at the map. */
  position:absolute; left:12px; bottom:12px; z-index:3;
  max-width:calc(100% - var(--cm-side-w) - 56px);
  display:grid; grid-template-columns:auto auto;
  padding:12px 16px 14px;
  background:rgba(8,6,16,0.4);
  border:1px solid rgba(255,255,255,0.12);
  border-radius:6px;
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
}
.cm-legend-col { min-width:0; }
.cm-legend-col + .cm-legend-col {
  margin-left:20px; padding-left:20px;
  border-left:1px solid rgba(255,255,255,0.14);
}
.cm-legend-heading {
  margin:0 0 8px;
  font-family:var(--f-heading); font-size:14px; font-weight:600;
  letter-spacing:1.5px; text-transform:uppercase; color:var(--gold);
}
.cm-lg { display:flex; flex-direction:column; gap:5px; }
.cm-lg span { display:flex; align-items:center; gap:7px; font-family:var(--f-ui); font-size:12.5px; line-height:1.3; color:var(--white-mid); }

.cm-notes {
  display:grid; gap:10px;
  margin-top:20px; max-width:1000px;
  font-family:var(--f-ui); font-size:13.5px; line-height:1.55; color:var(--white-dim);
}

@media (max-width:1100px) {
  .cm-body { --cm-side-w:clamp(426px, calc(39.1% + 58px), 518px); }
  .cm-stage { min-height:470px; }
  .cm-eras { gap:4px; }
  .cm-eras button { padding:7px 7px; font-size:13px; }
  .cm-era-name { font-size:12px; }
  .cm-eras button small { font-size:12px; }
}
@media (max-width:900px) {
  .cm-body { --cm-side-w:0px; }
  .cm-stage { height:auto; min-height:0; max-height:none; }
  .cm-map-btns { right:12px; }
  .cm-hint { left:50%; }
  /* Too tall to pin on phones (eras wrap to two rows, the bar wraps too). */
  .cm-controls { position:static; margin:0 0 22px; padding:0; background:none; box-shadow:none; border-bottom:none; }
  .cm-stage svg { height:auto; aspect-ratio:4 / 2.46; }
  .cm-legend {
    position:static; grid-template-columns:1fr;
    border:none; border-top:1px solid rgba(255,255,255,0.12); border-radius:0;
    -webkit-backdrop-filter:none; backdrop-filter:none;
  }
  .cm-legend-col + .cm-legend-col { margin:16px 0 0; padding:16px 0 0; border-left:none; border-top:1px solid rgba(255,255,255,0.1); }
  .cm-side {
    position:static; width:auto; padding:0; margin-top:28px;
    background:none; border:none; border-radius:0;
    -webkit-backdrop-filter:none; backdrop-filter:none;
  }
  .cm-side-inner { overflow:visible; }
  .cm-side-inner > .cm-events { min-height:0; overflow:visible; }
  .cm-bar { flex-wrap:wrap; }
  .cm-eras { grid-template-columns:repeat(5, minmax(0, 1fr)); }
  .cm-track { flex:1 1 calc(100% - 64px); }
  .cm-options { width:100%; justify-content:space-between; }
}
@media (max-width:560px) {
  .cm-year-badge { left:10px; top:10px; padding:8px 14px 10px 12px; }
  .cm-map-btns button { width:34px; height:34px; }
  .cm-chapter-title { font-size:19.5px; }
  .cm-eras { gap:4px; }
  .cm-eras button { padding:6px 5px; font-size:12px; border-top:2px solid rgba(201,168,68,0.25); }
  .cm-eras button.on { border-top-color:var(--gold); }
  .cm-eras button small { padding-left:0; font-size:11px; }
}

/* ── Site shell differences ── */
/* Same 1770px width as the At a Glance panel and every modal. */
.ag-panel.cm-panel { max-width:1770px; }
.cm-subtitle { color:var(--white-mid); font-size:17px; line-height:1.6; margin-top:11px; }

/* Source footer: one-line slider, same as the event modal's footer. */
.cm-panel .cm-footer { flex-wrap:nowrap; }
.cm-footer .modal-source-links { flex:1 1 auto; min-width:0; flex-wrap:nowrap; }
.cm-footer .modal-source-label { flex:0 0 auto; margin-bottom:0; }
.cm-footer .modal-source-slider { flex:1 1 auto; min-width:0; overflow-x:hidden; scroll-behavior:smooth; scrollbar-width:none; }
.cm-footer .modal-source-slider::-webkit-scrollbar { display:none; }
.cm-footer .modal-source-slider .modal-source-list { width:max-content; margin-left:0; flex-wrap:nowrap; white-space:nowrap; }

/* .ag-panel drops to 22px side padding below 1350px; the sticky controls'
   edge-to-edge bleed follows it. */
@media (max-width:1350px) {
  .cm-controls { margin:0 -22px 22px; padding:10px 22px 4px; }
}
@media (max-width:900px) {
  .cm-controls { margin:0 0 22px; padding:0; }
}
@media (max-width:760px) {
  .cm-panel .cm-footer { display:grid; grid-template-columns:minmax(0, 1fr) 34px 34px; gap:10px 8px; }
  .cm-footer .modal-source-links { display:grid; gap:4px; }
  .cm-footer .modal-mistake-btn { grid-column:1 / -1; justify-self:start; white-space:normal; }
}
@media (max-width:560px) {
  .cm-eras { grid-template-columns:repeat(3, minmax(0, 1fr)); }
}
@media (min-width:761px) and (max-width:1200px) {
  .cm-controls.is-stuck .cm-eras button small { display:none; }
  .cm-play { height:38px; gap:10px; padding:0 18px 0 14px; font-size:14px; }
  .cm-play svg { width:16px; height:16px; }
  .cm-options { height:38px; }
  .cm-track { margin-top:-3px; }
}
@media (prefers-reduced-motion: reduce) {
  .cm-reg, .cm-ref, .cm-place, .cm-side-inner.is-fading { transition:none; animation:none; }
}

/* The event modal's / timeline's "Portugal in YEAR" cards (.em-map-card)
   are styled in style.css. */

/* "Who was in power" line in the year badge: the ruler for the shown year. */
.cm-pop-n { max-width:300px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cm-stage .cm-pop .cm-pop-icon { width:20px; height:20px; }

/* Key Events rows that link to a timeline entry. */
.cm-events .ag-event--linked { cursor:pointer; }
.cm-events .ag-event--linked:hover .ag-event-text,
.cm-events .ag-event--linked:focus-visible .ag-event-text { color:var(--gold); }
.cm-events .ag-event--linked:hover,
.cm-events .ag-event--linked:focus-visible { background:rgba(201,168,68,0.05); outline:none; }

/* First / last chapter year sit inside the track instead of centred on its
   ends (the first one would otherwise run under the Play button). */
.cm-tick-labels button:first-child { transform:none; }
.cm-tick-labels button:last-child { transform:translateX(-100%); }
