/* Preservation-only fixes. Original New York Times styles are stored in assets/. */

:root {
  --preserved-masthead-height: 43px;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  min-height: 100%;
  height: auto !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
}

body {
  position: static !important;
}

/* ── Collapse all reserved advertising space ───────────────────────────── */
#top-wrapper,
#top-slug,
#after-top,
#bottom-wrapper,
#bottom-slug,
#after-bottom,
.ad.top-wrapper,
.ad.bottom-wrapper,
[data-testid*="ad-slot"],
[id^="ad-slot"],
.ad-slot,
.ad-container,
.place-ad {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* The captured modern masthead leaves a 43px spacer after the masthead is
   fixed. It is only a layout reservation, so collapse it with the removed
   banner rather than leaving a blank strip above the election navigation. */
#interactive-masthead-spacer,
.ZYn2Zq_mastheadSpacer,
[class*="mastheadSpacer"] {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ── Hide inert modern-page shells ─────────────────────────────────────── */
[data-testid="vi-gateway-container"],
.vi-gateway-container,
#gateway-content,
#google-one-tap-container,
[data-testid*="recirc-"][data-testid*="-placeholder"],
[data-testid="recirc-defaultPackage-placeholder"],
[data-testid="recirc-rightRail-placeholder"],
section[data-testid="recirc-defaultPackage-placeholder"],
section[data-testid="recirc-rightRail-placeholder"],
[data-testid="cookie-policy-banner"],
[data-testid="inline-message"],
[data-testid="onsite-messaging-unit"],
[id*="fides"],
[id*="consent"],
.expanded-dock,
#lngt-main-container {
  display: none !important;
}

/* The gift-article, save, and share-more buttons have no backend.
   Hide them to avoid confusing click targets. */
button[data-testid="gift-article-button"],
button[data-testid="save-article-button"],
.actionbar-button:not(.e-map-btn):not(.e-nav-dropdown-btn):not(.e-nav-dropdown-close):not(.e-auto-update-switch) {
  display: none !important;
}
.save-button,
li:has(> div > div > button[data-testid="gift-article-button"]),
li:has(> button[data-testid="save-article-button"]) {
  display: none !important;
}

/* Collapse standalone sharetools row if all children are hidden. */
#interactive-standalone-sharetools {
  display: none !important;
}

/* ── Remove the modern "past election results" banner ────────────────────
   It was injected years after this 2020 page was published. Removing the
   entire region also removes its reserved vertical space. */
html #NYT_TOP_BANNER_REGION,
html #NYT_TOP_BANNER_REGION > section,
html #NYT_TOP_BANNER_REGION nav.svelte-dlsnh0 {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* ── Masthead tightening ───────────────────────────────────────────────── */
/* The captured 2022 shell changes the original fixed masthead to relative
   positioning but leaves its 43px spacer in flow, creating a duplicate band
   above the election navigation on desktop. */
@media (min-width: 1024px) {
  body [data-testid="masthead-container"].Wr7_RG_stickyContainer {
    position: fixed !important;
    top: 0;
    left: 0;
  }
}

/* Compact election-year mark restored as live text/CSS so it remains crisp at
   every size and does not add another raster asset to the preservation. */
.preservation-election-year {
  display: inline-grid;
  grid-template-columns: repeat(4, 22px);
  gap: 0;
  width: max-content;
  margin-right: 7px;
  vertical-align: middle;
  flex: 0 0 auto;
}

.preservation-election-year-tile {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  box-sizing: border-box;
  color: #fff;
  font: 700 16px/1 nyt-franklin, helvetica, sans-serif;
}

.preservation-election-year-tile:nth-child(odd) {
  background: #ff5a52;
}

.preservation-election-year-tile:nth-child(even) {
  background: #2f8edb;
}

/* These controls belong to the live 2020 page and have no meaning in a
   finalized, offline preservation. Keep the historical update copy itself. */
.e-auto-update-wrap,
.e-push-alert-wrapper,
#notifications-button {
  display: none !important;
}

/* The historical page keeps these labels in its election menu, but their
   destinations and state-results dialog are not part of this preservation. */
.e-nav-item.preservation-nav-disabled,
.e-nav-item[aria-disabled="true"] {
  cursor: default !important;
  opacity: 0.55;
  pointer-events: none !important;
  text-decoration: none !important;
}

/* The requested preservation stops at the 2020 result visualization. */
.e-map-btn.e-bubbles,
.e-map-btn.e-arrows,
.e-map-btn[data-type="leader-margin-bubbles"],
.e-map-btn[data-type="change-arrows"],
.e-footer-nav,
#interactive-footer-container,
#interactive-footer,
#interactive-source,
#interactive-credit {
  display: none !important;
}

/* ── Collapse the hidden duplicate election-navigation shell ─────────────
   The captured modern masthead already supplies the visible Elections/NYT
   header. The historical election nav remains in the DOM for editing and
   accessibility audits, but its duplicate reserved height is not rendered. */
.e-nav-container {
  position: static !important;
  z-index: auto !important;
  display: block !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  box-shadow: none !important;
}

.e-nav-container .e-navigation,
.e-nav-container .e-inner {
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  box-shadow: none !important;
}

#site-content {
  padding-top: 0 !important;
}

@media (min-width: 1024px) {
  #site-content {
    padding-top: var(--preserved-masthead-height) !important;
  }
}

/* The vote-count module depended on a live payload that is not in the
   capture. Keep any late bundle insertion from resurrecting a blank shell. */
.e-cmp-timeseries-multiples,
.g-timeseries-multiples-container {
  display: none !important;
}

/* ── Latest-updates rail ──────────────────────────────────────────────────
   The original rail was fixed, but its height included padding and pushed
   the scrollable feed below the viewport. Make the rail a precise viewport
   column and contain wheel momentum inside the journalist commentary. */
@media (min-width: 765px) {
  .e-right-column {
    position: fixed !important;
    top: var(--preserved-masthead-height) !important;
    right: 0 !important;
    bottom: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin-top: 0 !important;
    padding: 15px 0 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
  }

  .e-right-column .e-cmp-reporter-updates,
  .e-right-column .e-cmp-inner,
  .e-right-column .e-cmp-content,
  .e-right-column .e-cmp-box {
    min-height: 0 !important;
  }

  .e-right-column .e-cmp-reporter-updates,
  .e-right-column .e-cmp-inner {
    height: 100% !important;
  }

  .e-right-column .e-cmp-inner {
    display: flex !important;
    flex-direction: column !important;
  }

  .e-right-column .e-cmp-header {
    flex: 0 0 auto !important;
  }

  .e-right-column .e-cmp-content,
  .e-right-column .e-cmp-box {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  #all-reporter-updates-limit-20 {
    height: 100% !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    scrollbar-gutter: stable;
  }
}

/* Portraits are decorative in this preservation. Keep their containing
   nodes so author text keeps the same deterministic editor path. */
.e-reporter-update .e-left,
.e-reporter-update .e-left img,
.e-race-call-update .e-left,
.e-race-call-update .e-left img {
  display: none !important;
}

.e-desktop-cmp .e-reporter-update:not(.e-pinned) .e-non-image-content,
.e-mobile-cmp .e-reporter-update:not(.e-pinned) .e-non-image-content {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  row-gap: 4px;
}

.e-reporter-update:not(.e-pinned) .e-attribution {
  grid-column: 1;
  grid-row: 1;
}

.e-reporter-update:not(.e-pinned) .e-right {
  grid-column: 1;
  grid-row: 2;
}

/* ── Related analysis previews ─────────────────────────────────────────── */
.e-cmp-related-coverage {
  border-top: 1px solid #e2e2e2;
  padding-top: 12px;
}

#e-related-coverage .e-article-promo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  min-height: 108px;
  overflow: hidden;
  border-top: 4px solid #326891;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 65%), transparent 48%),
    #e8eef3;
}

#e-related-coverage .e-related-article:nth-child(2) .e-article-promo {
  border-top-color: #b3564d;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 65%), transparent 48%),
    #f2e9e5;
}

#e-related-coverage .e-related-article:nth-child(3) .e-article-promo {
  border-top-color: #58715c;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 65%), transparent 48%),
    #e8eee7;
}

#e-related-coverage .e-related-article:nth-child(4) .e-article-promo {
  border-top-color: #71658a;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 65%), transparent 48%),
    #eceaf1;
}

#e-related-coverage .e-article-promo::before {
  position: absolute;
  top: 8px;
  left: 10px;
  color: rgb(18 18 18 / 60%);
  content: attr(data-preview-state);
  font: 700 10px/1 nyt-franklin, helvetica, sans-serif;
  letter-spacing: 0.08em;
}

#e-related-coverage .e-article-promo img {
  display: block;
  width: 58%;
  height: 78%;
  object-fit: contain;
  opacity: 0.82;
}

@media (max-width: 764px) {
  .e-mobile-cmp #all-reporter-updates-limit-1,
  .e-mobile-cmp .e-all-reporter-updates {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    overscroll-behavior: auto !important;
  }
}

/* ── Site Index & footer spacing ───────────────────────────────────────── */
nav#site-index .css-uc4bdz:empty {
  display: none !important;
}

/* ── Keep keyboard navigation visible ──────────────────────────────────── */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #567b95 !important;
  outline-offset: 3px !important;
}

/* Focus ring for election map mode buttons */
.e-map-btn:focus-visible {
  outline: 3px solid #567b95 !important;
  outline-offset: 2px !important;
}

/* ── Responsive fixes ──────────────────────────────────────────────────── */

/* Prevent horizontal overflow from wide election content */
.e-content,
.e-national-map-page,
.e-results-map,
.e-map {
  max-width: 100%;
  box-sizing: border-box;
}

/* Latest-updates sidebar becomes full-width on narrow viewports */
@media (max-width: 740px) {
  .e-side-column,
  .e-latest-updates {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
  }
  .e-main-column {
    width: 100% !important;
  }
}

/* Map-mode controls: prevent clipping, allow wrapping */
.e-map-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* State names and result cells remain part of the preserved visualization, but
   are deliberately plain text. Match the captured anchor box model after the
   runtime and build-time link removal. */
[data-preservation-static-state] {
  cursor: default !important;
  pointer-events: none !important;
  text-decoration: none !important;
}

/* Runtime/static fallback for preserved copy that must retain its text and
   layout without exposing an unavailable destination. Analysis cards are
   intentionally outside these scopes and remain clickable. */
#all-reporter-updates-limit-20 [data-preservation-static-update],
[data-preservation-static-brand] {
  cursor: default !important;
  pointer-events: none !important;
  text-decoration: none !important;
}

#all-reporter-updates-limit-20 > [data-preservation-static-update].e-race-call-refer {
  display: block;
}

.e-big-board-table td.e-swatch [data-preservation-static-state] {
  color: #fff !important;
}

.e-big-board-table td.e-swatch-light [data-preservation-static-state] {
  color: #333 !important;
}

.e-big-board-table td:first-of-type [data-preservation-static-state] {
  display: block;
  box-sizing: border-box;
  height: 100%;
  padding-top: 9px;
  padding-bottom: 8px;
}

.e-big-board-table td.e-candidate-col [data-preservation-static-state] {
  display: block;
  box-sizing: border-box;
  min-height: 30px;
  padding: 10px;
  position: relative;
  white-space: nowrap;
}

.e-big-board-table td.e-big-board-caret [data-preservation-static-state] {
  padding-top: 10px;
}

.e-big-board-table td.e-big-board-reporting [data-preservation-static-state] {
  padding-top: 12px;
}

@media (min-width: 765px) {
  .e-big-board-table td.e-candidate-col [data-preservation-static-state] {
    padding-right: 22px;
  }

  .e-big-board-table td.e-big-board-reporting [data-preservation-static-state] {
    padding-top: 11px;
  }
}

@media (min-width: 975px) {
  .e-big-board-table td.e-candidate-col [data-preservation-static-state] {
    padding-bottom: 8px;
  }
}

/* Candidate totals alignment */
.e-bop .e-labels {
  box-sizing: border-box;
}

/* State-results dialog: fit viewport */
.e-nav-dropdown-wrap {
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Reduced-motion preferences ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
