/* ==========================================================================
   Jim Rickards' Weekly Midterm Countdown: shared styles
   Used by index.html and every article. Article navigation styles are at the bottom.
   ========================================================================== */

:root {
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-muted: #5a616b;
  --line: #d5d8dc;
}

body {
  margin: 0;
  background-color: #f4f4f4;
  color: #111;
  font-family: var(--font-sans);
}

/* background photo: wide screens only. phones never see it, so they never download it.
   a fixed pseudo-element keeps it still while scrolling without the repaint cost of background-attachment: fixed */
@media (min-width: 1001px) {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url(https://d2z65klgtz99km.cloudfront.net/SMSINS/midterm-countdown/midterm-countdown-capital-bg.webp);
    background-size: contain;
    background-repeat: repeat;
  }
}

/* the hidden attribute must always hide, even when another rule (like an ad's own display setting) says otherwise */
[hidden] {
  display: none !important;
}

a:focus-visible {
  outline: 3px solid #1a5fd0;
  outline-offset: 3px;
}

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

/* ---------- page card ---------- */
.page {
  max-width: 1000px;
  margin: 0 auto;
  background-color: #fff;
}

@media (min-width: 769px) {
  .page {
    margin: 1.5rem auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
  }
}

/* ---------- masthead (single image: swaps between a phone and a wide version) ---------- */
.masthead-link {
  display: block;
}

.masthead {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- content area ---------- */
.wrapper {
  padding: 1rem;
}

@media (min-width: 769px) {
  .wrapper {
    padding: 1.5rem 2rem;
  }
}

.wrapper p {
  font-size: 1rem;
  line-height: 1.55;
}

/* ---------- article ---------- */
.back-to-articles-container {
  border-bottom: 1px solid var(--line);
}

.back-to-articles {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: #4a515a;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  transition:
    color 0.2s ease,
    gap 0.2s ease;
}

.back-to-articles span {
  font-size: 1rem;
  line-height: 1;
}

.back-to-articles:hover,
.back-to-articles:focus-visible {
  color: #111;
  gap: 12px;
}

.wrapper > .post-date {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.wrapper .post-title {
  margin-top: 0.25rem;
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-align: left;
  text-wrap: balance;
}

/* subheads inside an article (direct children only, so the index's article titles are not affected) */
.wrapper > h2,
.wrapper > h3 {
  margin-top: 1.5rem;
  font-size: clamp(22px, 5.5vw, 28px);
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  text-wrap: balance;
}

/* ---------- index: article list ---------- */
.post-preview {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.post-preview:first-child {
  padding-top: 0.5rem;
}

.post-preview:last-child {
  border-bottom: 0;
}

.post-preview a {
  color: inherit;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-preview .post-date {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.latest-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #c00;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post-preview h2 {
  margin-top: 0.25rem;
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-align: left;
  text-wrap: balance;
}

.post-preview h2 a {
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-preview h2 a:hover {
  color: #555;
}

.wrapper .post-preview p {
  color: #4d535b;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 0.5rem;
  color: #111;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
  transition: gap 0.2s ease;
}

.read-more:hover,
.read-more:focus-visible {
  gap: 12px;
}

/* ---------- article navigation (Newer / Older) ---------- */
.article-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.article-nav[hidden],
.article-nav-link[hidden] {
  display: none;
}

.article-nav-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  padding: 12px 0;
  color: #111;
  text-decoration: none;
}

.article-nav-link.older {
  margin-left: auto;
  justify-content: flex-end;
  text-align: right;
}

.nav-arrow {
  flex-shrink: 0;
  font-size: 1.2rem;
  line-height: 1.4;
  transition: transform 0.2s ease;
}

.article-nav-link small {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.article-nav-link strong {
  display: block;
  max-width: 300px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.article-nav-link:hover .nav-arrow {
  transform: translateX(-4px);
}

.article-nav-link.older:hover .nav-arrow {
  transform: translateX(4px);
}

@media (max-width: 600px) {
  .article-nav {
    flex-direction: column;
    gap: 5px;
  }

  .article-nav-link,
  .article-nav-link.older {
    margin-left: 0;
    justify-content: flex-start;
    text-align: left;
  }

  .article-nav-link.older .nav-arrow {
    order: 2;
  }
}

/* ---------- election countdown (every page, below the masthead) ---------- */
.countdown {
  padding: 1.1rem 1rem 1.25rem;
  background: #eef2fa;
  border-top: 1px solid #d3dbec;
  border-bottom: 4px solid #9e0829;
  color: #00215f;
  text-align: center;
}

.countdown-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9e0829;
}

.countdown-label::before,
.countdown-label::after {
  content: "";
  width: 2.5rem;
  height: 2px;
  background: #9e0829;
}

/* the numbers stay invisible (but keep their space, so nothing jumps) until countdown.js has filled them in */
.countdown-units {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  max-width: 640px;
  margin: 0.75rem auto 0;
  visibility: hidden;
}

.countdown.is-ready .countdown-units {
  visibility: visible;
}

.countdown-units[hidden],
.countdown-date[hidden] {
  display: none;
}

.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 0.25rem 0.65rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #00265f 0%, #001a47 100%);
  box-shadow: 0 4px 10px rgba(0, 33, 95, 0.28);
  color: #fff;
}

.countdown-value {
  font-size: clamp(36px, 10.5vw, 68px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.countdown-unit-label {
  margin-top: 0.4rem;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d3dcf0;
}

.countdown-date {
  margin-top: 0.9rem;
  font-size: 15px;
  font-weight: 600;
  color: #00215f;
}

@media (max-width: 479px) {
  .countdown-label::before,
  .countdown-label::after {
    display: none;
  }

  .countdown-units {
    gap: 0.35rem;
  }
}

/* narrow phones: tighten the labels so "Minutes" and "Seconds" don't touch */
@media (max-width: 400px) {
  .countdown-unit-label {
    font-size: 12px;
    letter-spacing: 0.06em;
  }
}

@media (max-width: 359px) {
  .countdown {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .countdown-unit {
    padding-left: 2px;
    padding-right: 2px;
  }

  .countdown-unit-label {
    font-size: 11px;
    letter-spacing: 0.04em;
  }
}
