/* ---------------------------------------------------------------
   Jonathan Cervas — site styles
   One stylesheet. CMU red accent (#C41230). No frameworks.
   --------------------------------------------------------------- */

:root {
  --red: #C41230;        /* Carnegie red */
  --red-dark: #9e0f27;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --line: #e4e4e4;
  --bg: #ffffff;
  --bg-alt: #f7f7f7;
  --wrap: 860px;
  --font: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark theme — applied when <html data-theme="dark"> (set from system default or the
   visitor's saved choice by the inline script in the layout). */
:root[data-theme="dark"] {
  --ink: #e7e8ea;
  --muted: #9aa0a6;
  --line: #33373b;
  --bg: #16181c;
  --bg-alt: #202429;
  --red: #ff5d6c;       /* lighter red for legibility on dark */
  --red-dark: #ff8894;
}
/* Keep white text readable where it sits on the (now brighter) red */
:root[data-theme="dark"] .mtable__chip.is-active,
:root[data-theme="dark"] .btn-cite:hover { color: #14161a; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); text-decoration: underline; }

/* Animated underline-swipe on content links (from the old site):
   underline grows from left to right on hover. */
main a, .site-footer a {
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 .0625em no-repeat;
  padding-bottom: .0625em;
  transition: background-size .4s ease, color .4s ease;
}
main a:hover, .site-footer a:hover {
  text-decoration: none;
  background-size: 100% .0625em;
}

h1, h2, h3 { line-height: 1.25; font-weight: 700; }
h2 { font-size: 1.6rem; margin: 2.5rem 0 1rem; }
h3 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
img { max-width: 100%; height: auto; }

/* ---------- Header / nav ---------- */
.site-header {
  border-bottom: 3px solid var(--red);
  background: var(--bg);
  position: sticky; top: 0; z-index: 50;
}
.site-header__inner {
  display: flex; align-items: center; gap: 1rem;
  min-height: 60px;
}
.site-brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); margin-right: auto; }
.site-brand:hover { color: var(--red); text-decoration: none; }
.site-nav { display: flex; gap: 1.5rem; }
.site-nav a {
  color: var(--ink); font-weight: 500; font-size: 1rem;
  padding: .25rem 0; border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--red); text-decoration: none; border-bottom-color: var(--red); }
.site-nav a.active { color: var(--red); border-bottom-color: var(--red); }

/* mobile menu toggle (hidden on desktop) */
.nav-toggle, .nav-toggle-label { display: none; }

/* theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--ink); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--red); border-color: var(--red); }
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ---------- Hero (home) ---------- */
.hero {
  position: relative;
  /* Opaque CMU-red base so the translucent overlay never blends with the page
     background — keeps the hero rich and the roads visible in light AND dark. */
  background-color: #a8112a;
  background-image:
    linear-gradient(135deg, rgba(196, 18, 48, .66) 0%, rgba(158, 15, 39, .80) 100%),
    url('/images/PAROADS.svg');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: #fff;
  border-bottom: 4px solid #7d0c1f;
}
.hero__inner {
  display: flex; align-items: center; gap: 2.5rem;
  padding: 3.25rem 1.25rem; max-width: var(--wrap); margin: 0 auto;
}
.hero__photo {
  flex: 0 0 200px; width: 200px; height: 200px;
  border-radius: 50%; object-fit: cover;
  border: 5px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.hero__text h1 { margin: 0 0 .35rem; font-size: 2.6rem; text-shadow: 0 1px 12px rgba(0,0,0,.25); }
.hero__text .tagline { margin: 0 0 .9rem; font-size: 1.15rem; opacity: .97; }
.hero__areas {
  margin: 0; font-size: .8rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; opacity: .92;
  padding-top: .9rem; border-top: 1px solid rgba(255,255,255,.3); display: inline-block;
}

/* ---------- Breadcrumbs ---------- */
/* Inline (not flex) so a long page title wraps as ordinary text instead of
   overflowing the line on a narrow screen. */
.breadcrumbs {
  max-width: var(--wrap); margin: 0 auto;
  padding: 1rem 1.25rem 0;
  font-size: .85rem;
}
/* Map pages run wider than the text column; keep the trail on their left edge. */
.breadcrumbs--wide { max-width: 1200px; }

.breadcrumbs__list { list-style: none; margin: 0; padding: 0; line-height: 1.6; }
.breadcrumbs__item { display: inline; color: var(--muted); }
.breadcrumbs__item + .breadcrumbs__item::before {
  content: "/"; margin: 0 .45rem; color: var(--muted); opacity: .5;
}
.breadcrumbs__item--current { color: var(--ink); font-weight: 500; }

/* Quieter than body links — the trail is orientation, not a call to action. */
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--red); }

/* The trail already supplies the top gap above the title. General sibling, not
   adjacent: the include emits its JSON-LD <script> between the two. */
.breadcrumbs ~ .page { padding-top: 1.25rem; }

/* ---------- Page content ---------- */
.page { padding: 2.5rem 1.25rem 1rem; }
.page-title { font-size: 2rem; margin: 0 0 1rem; }
.home-section { padding: 2.5rem 1.25rem; }
.home-section:nth-of-type(even) { background: var(--bg-alt); }
.home-section .inner { max-width: var(--wrap); margin: 0 auto; }
.section-lead { color: var(--muted); margin-top: -.25rem; }
.more-link { display: inline-block; margin-top: 1rem; font-weight: 600; }

/* Highlighted link to a featured page (e.g. interactive maps) */
.feature-banner {
  margin: 1.25rem 0 1.75rem; padding: .8rem 1rem;
  background: var(--bg-alt); border: 1px solid var(--line);
  border-left: 3px solid var(--red); border-radius: 6px;
}
.feature-banner a { text-decoration: none; color: var(--ink); }
.feature-banner a:hover strong { color: var(--red); }
.feature-banner strong { color: var(--red); }
/* A banner listing several maps needs its inline links to read as links, which
   the rule above deliberately suppresses for whole-line banner links. */
.feature-banner .banner-links { display: block; margin-top: .35rem; }
.feature-banner .banner-links a {
  color: var(--red); text-decoration: underline; text-underline-offset: 2px;
}
.feature-banner .banner-links a:hover { text-decoration-thickness: 2px; }
.feature-banner .banner-sep { color: var(--muted); margin: 0 .5rem; }

/* ---------- Publication detail: cite actions ---------- */
.pub-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
  margin: 1rem 0 1.5rem;
}
.cite-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.btn-cite {
  font: inherit; font-size: .85rem; cursor: pointer;
  padding: .3rem .75rem; border: 1px solid var(--red); border-radius: 999px;
  background: var(--bg); color: var(--red); transition: background .15s, color .15s;
}
.btn-cite:hover { background: var(--red); color: #fff; }
.cite-status { font-size: .82rem; color: var(--muted); }

/* ---------- Teaching ---------- */
.course-list { display: grid; gap: 1.25rem; }
.course {
  border: 1px solid var(--line); border-left: 3px solid var(--red);
  border-radius: 8px; padding: 1rem 1.2rem;
}
.course__title { margin: 0 0 .5rem; font-size: 1.15rem; }
.course__tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.course__num {
  font-weight: 700; color: var(--red); font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.course__tag {
  font-size: .78rem; color: var(--muted); background: var(--bg-alt);
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .55rem;
}
.course__tag--gened { color: var(--ink); }
.course__terms { margin: 0; font-size: .92rem; color: var(--muted); }
.course__summary { margin: .6rem 0 .8rem; font-size: .95rem; }
.course-detail__tags { margin: -.25rem 0 .6rem; }
.course-body { margin-top: 1.25rem; }
.course-body h2 { font-size: 1.3rem; margin: 1.75rem 0 .5rem; }

/* ---------- Publication detail page ---------- */
.pub-detail__title { font-size: 1.8rem; margin: 0 0 .75rem; line-height: 1.25; }
.pub-detail__cite { color: var(--muted); margin: 0 0 1rem; font-size: 1.02rem; }
.pub-detail__summary { margin-top: 1.5rem; }
.pub-detail__summary h2 { font-size: 1.1rem; margin: 0 0 .5rem; }

/* ---------- Publications ---------- */
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub-list li { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.pub-list li:last-child { border-bottom: none; }
.pub-title { font-weight: 600; }
.pub-meta { color: var(--muted); font-size: .95rem; }
.pub-year { color: var(--red); font-weight: 700; }

/* ---------- Redistricting cases ---------- */
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.case {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--bg); display: flex; flex-direction: column;
}
.case img { width: 100%; height: 160px; object-fit: cover; background: var(--bg-alt); }
.case__body { padding: 1rem 1.1rem 1.25rem; }
.case__body h3 { margin: 0 0 .1rem; }
.case__sub { color: var(--red); font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.case__body p { font-size: .95rem; margin: 0; }

/* ---------- Case detail page ---------- */
.case-detail__sub {
  color: var(--red); font-weight: 600; margin: -.5rem 0 1rem; font-size: 1.05rem;
}
.case-detail__img {
  width: 100%; max-height: 340px; object-fit: contain;
  background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem; margin-bottom: 1.5rem;
}
.resource-list { list-style: none; margin: 0; padding: 0; }
.resource-list > li {
  padding: .6rem 0; border-bottom: 1px solid var(--line); font-size: .97rem;
}
.resource-list > li:last-child { border-bottom: none; }
.resource-label { font-weight: 600; display: block; }
.resource-list .sep { color: var(--muted); }
.case-highlights { padding-left: 1.1rem; }
.case-highlights li { margin-bottom: .3rem; }
.case__img-link { display: block; background: none; padding: 0; }

/* Maps index: same card as a case, but usually with no thumbnail above the
   title, so the heading needs the breathing room .case__sub would otherwise
   have given. A card that does carry one keeps the case spacing. */
.map-card:not(.has-thumb) .case__body h3 { margin-bottom: .45rem; }

/* Map thumbnails are drawings, not photographs: show the whole thing rather
   than cropping to fill, and let the card's own surface be the letterbox so
   the gutter follows the theme. */
.map-card.has-thumb img { object-fit: contain; padding: .35rem; }

/* Only some map cards have a thumbnail, so top-align them: a stretched
   text-only card next to a taller one is just a block of empty space. */
.case-grid--maps { align-items: start; }

/* ---------- Media ---------- */
.media-inquiries {
  border: 1px solid var(--line); border-radius: 8px;
  padding: .75rem 1rem; margin-bottom: 1.5rem; background: var(--bg-alt);
}
.media-inquiries summary { cursor: pointer; }
.media-inquiries address { font-style: normal; margin-top: .6rem; color: var(--muted); }

.media-featured { display: grid; gap: 1.25rem; margin-bottom: 1rem; }
.media-feature { border-left: 3px solid var(--red); padding: .25rem 0 .25rem 1.1rem; }
.media-feature--has-img { display: flex; gap: 1.25rem; align-items: stretch; }
.media-feature__figure {
  position: relative; flex: 0 0 200px; margin: 0;
  overflow: hidden; border-radius: 8px; background: var(--bg-alt);
  align-self: stretch; min-height: 130px;
}
.media-feature__img {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: center;
}
.media-feature__credit {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
  font-size: .68rem; color: #fff; line-height: 1.25; padding: .5rem .5rem .35rem;
  background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0));
}
.media-feature__body { flex: 1 1 auto; min-width: 0; }
.media-feature h3 { margin: 0 0 .1rem; font-size: 1.15rem; }
.media-outlet { color: var(--red); font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.media-feature p { margin: 0 0 .5rem; font-size: .97rem; }

@media (max-width: 620px) {
  .media-feature--has-img { flex-direction: column; align-items: stretch; }
  .media-feature__figure { flex-basis: auto; align-self: auto; height: 200px; min-height: 0; }
}

.collection-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem; margin: .5rem 0 1rem;
}
.collection {
  border: 1px solid var(--line); border-left: 3px solid var(--red);
  border-radius: 8px; padding: 1rem 1.2rem;
}
.collection h3 { margin: 0 0 .35rem; font-size: 1.1rem; }
.collection p { margin: 0 0 .6rem; font-size: .95rem; color: var(--muted); }
.media-more { margin-top: 1rem; font-weight: 600; }

/* ---------- Resources page ---------- */
.resource-section { margin: 2rem 0; }
.resource-section > h2 { margin-bottom: .25rem; }
.resource-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.resource {
  border-top: 1px solid var(--line); padding: .85rem 0;
}
.resource:last-child { border-bottom: 1px solid var(--line); }
.resource__title { font-weight: 600; }
.resource__ext { font-size: .8em; color: var(--muted); margin-left: .15rem; }
/* "Draft" pill for work-in-progress pages: Resources links, map cards, map pages. */
.draft-tag {
  display: inline-block; vertical-align: .1em; margin-left: .4rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--red); border: 1px solid var(--red); border-radius: 999px; padding: 0 .5rem;
}
.resource__note {
  display: block; color: var(--muted); font-size: .95rem; margin-top: .2rem;
}

.media-year {
  font-size: 1.05rem; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: .3rem; margin: 1.75rem 0 .75rem;
}
.media-list { list-style: none; margin: 0; padding: 0; }
.media-list > li { padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .97rem; }
.media-list > li:last-child { border-bottom: none; }
.media-date { color: var(--ink); font-weight: 600; white-space: nowrap; }
.media-src { font-style: italic; color: var(--muted); }
.media-quotes { margin: .5rem 0 .25rem; padding-left: 1.1rem; border-left: 2px solid var(--line); }
.media-quotes li { color: var(--muted); font-size: .92rem; margin-bottom: .35rem; list-style: none; }

/* ---------- Sortable media table ---------- */
.mtable__controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  margin: 1rem 0 1.25rem;
}
.mtable__search {
  flex: 1 1 220px; min-width: 180px;
  padding: .5rem .75rem; font: inherit; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.mtable__search:focus { outline: 2px solid var(--red); border-color: var(--red); }
.mtable__facets { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.mtable__facet { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.mtable__facet-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.mtable__chip {
  font: inherit; font-size: .85rem; cursor: pointer;
  padding: .25rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink); transition: background .15s, color .15s, border-color .15s;
}
.mtable__chip:hover { border-color: var(--red); color: var(--red); }
.mtable__chip.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.mtable__select {
  font: inherit; font-size: .9rem; padding: .35rem .5rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); max-width: 260px;
}
.mtable__count { font-size: .85rem; color: var(--muted); margin-left: auto; white-space: nowrap; }

.mtable__scroll { overflow-x: auto; }
.mtable__table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.mtable__table th, .mtable__table td {
  text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top;
}
.mtable__table thead th {
  border-bottom: 2px solid var(--line); font-size: .82rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); white-space: nowrap; background: var(--bg);
}
.mtable__table th.is-sortable { cursor: pointer; user-select: none; }
.mtable__table th.is-sortable:hover { color: var(--red); }
.mtable__arrow { display: inline-block; width: 1em; text-align: center; opacity: .5; }
.mtable__table th.is-asc .mtable__arrow::after { content: "\2191"; }   /* ↑ */
.mtable__table th.is-desc .mtable__arrow::after { content: "\2193"; }  /* ↓ */
.mt-author { color: var(--muted); font-size: .9em; }
.mt-quotes { margin: .4rem 0 .1rem; }
.mt-quotes blockquote {
  margin: .3rem 0; padding-left: .8rem; border-left: 2px solid var(--line);
  color: var(--muted); font-size: .9em;
}
.mt-date { white-space: nowrap; color: var(--muted); }
.mt-author-col { color: var(--muted); font-size: .92em; }
.mt-outlet { white-space: nowrap; color: var(--muted); }
.mtable__table tbody tr:hover { background: var(--bg-alt); }

@media (max-width: 600px) {
  .mt-outlet { white-space: normal; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 3rem;
  padding: 1.5rem 0; color: var(--muted); font-size: .9rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .hero__inner { flex-direction: column; text-align: center; padding: 2.25rem 1.25rem; }
  .hero__links { justify-content: center; }
  .hero__text h1 { font-size: 2rem; }

  .nav-toggle-label {
    display: block; cursor: pointer; padding: .5rem;
  }
  .nav-toggle-label span,
  .nav-toggle-label span::before,
  .nav-toggle-label span::after {
    display: block; width: 24px; height: 2px; background: var(--ink);
    position: relative; transition: .2s;
  }
  .nav-toggle-label span::before, .nav-toggle-label span::after { content: ""; position: absolute; }
  .nav-toggle-label span::before { top: -7px; }
  .nav-toggle-label span::after { top: 7px; }

  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--bg);
    border-bottom: 3px solid var(--red); padding: .5rem 1.25rem 1rem;
  }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .site-nav a { padding: .6rem 0; border-bottom: 1px solid var(--line); }
}
