/* ── Fonts ────────────────────────────────────────────────
   Inter: body, UI, labels, sidebar, legend, accordions,
          tabs, dropdowns
   Raleway Bold: page titles and section headings only    */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;600;800&family=Raleway:wght@400;700;800&display=swap');


/* ── Brand colors ─────────────────────────────────────────
   Fallbacks matching _brand.yml. At runtime, app.js
   overwrites these from the palette in measure_meta.json,
   so these only matter if the JSON fails to load.        */
:root {
  font-size: 1.2rem;
  --brand-primary: #3E1D15;
  --brand-secondary: #F49630;
  --brand-tertiary: #F2E4DC;
  --brand-white: #ffffff;
  --brand-tan-bg: #f6f4f1;
  --brand-abortion: #576033;
  --brand-contraception: #4180B0;
  --brand-maternity: #9B1B4B;
  --brand-art: #663366;
  --brand-missing: #7d7470;
}

/* Hero text colors — fallbacks match _brand.yml */
.color-abortion {
  color: var(--brand-abortion, #576033);
}

.color-contraception {
  color: var(--brand-contraception, #4180B0);
}

.color-maternity {
  color: var(--brand-maternity, #9B1B4B);
}

.color-art {
  color: var(--brand-art, #663366);
}


/* ── Base ──────────────────────────────────────────────── */
body {
  padding-top: 4.5rem;
  background: var(--brand-white);
  color: var(--brand-primary);
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

strong {
  font-weight: 600;
}

.page {
  flex: 1;
  margin: 2em 0;
}

a {
  color: var(--brand-primary);
  font-weight: 600;
  text-decoration: underline;
}

a:hover {
  color: var(--brand-primary);
  opacity: 0.7;
}


/* ── Navbar ────────────────────────────────────────────── */
.navbar {
  background: var(--brand-tertiary);
}

.navbar-logo {
  height: 4rem;
  width: auto;
}

.navbar-brand {
  font-family: 'Raleway', sans-serif;
  font-weight: 800;
  font-size: 1.5em;
}

.navbar-toggler {
  border-color: var(--brand-primary);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%233E1D15' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-toggler:focus {
  box-shadow: none;
}

.navbar-nav .nav-link {
  color: var(--brand-primary);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-decoration: none;
}

.navbar-nav .nav-link.active {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.navbar-collapse.show {
  background: var(--brand-tertiary);
  padding: 0.5em 1em 1em;
}


/* ── Hero ──────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 3em 1em 0;
}

.hero-inner {
  max-width: 1000px;
  margin: 0 auto 3em;
  line-height: 1.8;
}

.hero h1 {
  font-family: 'Raleway', sans-serif;
  font-size: 2em;
  font-weight: 800;
}

/* ── Map section ───────────────────────────────────────── */
.map-section {
  max-width: 1600px;
  width: 90%;
  margin: 0 auto 2em;
  margin-bottom: 5em;
}


/* ── Tabs ──────────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-tabs .nav-item {
  width: 50%;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
}

.nav-tabs .nav-link {
  width: 100%;
  height: 100%;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-decoration: none;
  color: var(--brand-primary);
  background: var(--brand-white);
  border: none;
  border-radius: 0.375rem 0.375rem 0 0;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 2px;
  clip-path: inset(-2px -2px 0px -2px);
}

.nav-tabs .nav-link:hover {
  border-bottom: none;
}

.nav-tabs .nav-link.active {
  background: var(--brand-tertiary);
  color: var(--brand-primary);
  border-bottom: none;
}

/* Enclosing border: wraps tab-content (map + accordion) */
.tab-content {
  border: none;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 2px;
  clip-path: inset(0px -2px -2px -2px);
}

.tab-sub {
  display: block;
  font-size: 0.85em;
}


/* ── Sidebar + Map grid ────────────────────────────────── */
.map-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
}

.sidebar {
  padding: 1em;
  background: white;
  grid-column: 1;
  grid-row: 1 / span 5;
  min-height: fit-content;
}

.map-title,
.map-container {
  grid-column: 2;
}

.map-container {
  /* Matches the lon/lat aspect ratio of BOUNDS in app.js (47:30),
     so the container's height tracks its rendered width instead of
     being a fixed pixel value unrelated to what the map actually
     shows. Update this if BOUNDS changes. */
  width: 100%;
  aspect-ratio: 47 / 30;
}

.click-prompt {
  width: 100%;
  text-align: center;
  font-size: 13px;
  opacity: 0.5;
  white-space: nowrap;
}

.map-state {
  grid-column: 2;
  font-family: 'Raleway', sans-serif;
  font-weight: 400;
  font-size: 2em;
  color: var(--brand-primary);
  text-align: center;
  padding: 1em 0 0 0;
  line-height: 1.1;
}

.map-title {
  font-family: 'Raleway', sans-serif;
  font-weight: 400;
  font-size: 2em;
  color: var(--brand-primary);
  text-align: center;
  padding: 0;
  line-height: 1.1;
}

.map-caption {
  grid-column: 2;
  font-family: 'Raleway', sans-serif;
  font-weight: 400;
  font-size: 0.85em;
  text-align: center;
  color: var(--brand-primary);
  margin-bottom: 2em;
}

/* Legend — sits above the map on all viewports */
.legend-desktop {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  background: white;
}


/* ── Dropdowns ─────────────────────────────────────────── */
.form-select {
  background-color: var(--brand-white);
  border: none;
  color: var(--brand-primary);
  font-family: 'Inter', sans-serif;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 2px;
}

.form-select:hover,
.form-select:focus {
  background-color: var(--brand-tertiary);
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 2px;
}

.form-select option:checked {
  background-color: var(--brand-tertiary);
}


/* ── Accordion ─────────────────────────────────────────── */
.accordion {
  margin-bottom: 0;
}

.accordion-item {
  border: none;
  border-radius: 0 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.accordion-item:last-child {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.accordion-body {
  text-align: left;
  background-color: white;
  font-family: 'Inter', sans-serif;
}

.accordion-button {
  font-family: 'Inter', sans-serif;
  background-color: var(--brand-tertiary) !important;
  color: var(--brand-primary) !important;
}

.accordion-header {
  background-color: var(--brand-tertiary) !important;
}

/* Chevron fill is hardcoded as %233E1D15 (= #3E1D15, brand primary).
   If primary changes, update the fill value in the SVG data URI. */
.accordion-button::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%233E1D15'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e") !important;
}


/* ── Value box ─────────────────────────────────────────── */
.value-box {
  background: var(--brand-tertiary);
  border-radius: 0.375rem;
  padding: 0.75em 1em;
}



.vb-chart-title {
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-bottom: 4px;
  text-align: center;
}

.vb-chart {
  position: relative;
  margin-top: 0.75em;
  margin-bottom: 1em;
}

.vb-chart-canvas-wrap {
  position: relative;
  height: 200px;
}


/* ── Flip card stat display ────────────────────────────── */
.fc-stat {
  flex-shrink: 0;
  margin-bottom: 0.25em;
}

.fc-stat-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.fc-stat-pct {
  font-family: 'Inter', sans-serif;
  font-size: 1.1em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.fc-stat-ratio {
  font-size: 0.75em;
  font-weight: 400;
  opacity: 0.5;
  text-align: right;
}

.fc-stat-label {
  font-size: 0.75em;
  font-weight: 400;
  opacity: 0.5;
}


/* ── Download button (styled to match dropdowns) ──────── */
.download-map {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--brand-white);
  border: none;
  color: var(--brand-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875em;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 2px;
}

.download-map:hover,
.download-map:focus {
  background-color: var(--brand-tertiary);
  color: var(--brand-primary);
  box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 2px;
}


/* ── Sidebar detail sections ───────────────────────────── */
.sidebar-detail {
  font-size: 0.85em;
  line-height: 1.6;
}

.sidebar-details-section {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar-details-summary {
  font-weight: 600;
  font-size: 0.9em;
  padding: 0.5em 0;
  cursor: pointer;
  list-style: none;
}

.sidebar-details-summary::-webkit-details-marker {
  display: none;
}

.sidebar-details-summary::before {
  content: "\25B6";
  display: inline-block;
  font-size: 0.65em;
  margin-right: 0.5em;
  transition: transform 0.2s;
}

details[open]>.sidebar-details-summary::before {
  transform: rotate(90deg);
}

.sidebar-details-body {
  padding: 0 0 0.75em;
  font-size: 0.8em;
  font-weight: 200;
  overflow-y: auto;
}

.sidebar-details-body a {
  font-weight: 400;
}

.sidebar-details-body table {
  width: 100%;
  border-collapse: collapse;
}

.sidebar-details-body td {
  padding: 0.3em 0;
  vertical-align: top;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-details-body tr:last-child td {
  border-bottom: none;
}

.sidebar-details-body td:first-child {
  font-weight: 400;
  white-space: nowrap;
  padding-right: 0.5em;
}

.sidebar-details-body.acc-source {
  max-height: none;
}


/* ── Flip cards ────────────────────────────────────────── */
.flip-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
}

.flip-card {
  min-height: 200px;
}

.flip-card-inner {
  width: 100%;
}

.flip-card-front,
.flip-card-back {
  background: var(--brand-white);
  padding: 1em 1.25em 0.75em;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Flipping is disabled for now; the back face (takeaways) is kept
   in the DOM for a possible future redesign but stays hidden. */
.flip-card-back {
  display: none;
}

.flip-card-header {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-bottom: 0.6em;
  flex-shrink: 0;
}

.flip-card-brief {
  flex: 1;
  font-size: 0.9em;
  line-height: 1.6;
  overflow: hidden;
}

.flip-card-scroll {
  flex: 1;
  font-size: 0.85em;
  line-height: 1.6;
  overflow-y: auto;
  margin-bottom: 0.5em;
}

.flip-card-hint {
  font-size: 0.75em;
  opacity: 0.5;
  text-align: right;
  flex-shrink: 0;
  padding-top: 0.25em;
}

/* Stack cards on mobile */
@media (max-width: 1024px) {
  .flip-cards {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .fc-stat-ratio {
    display: none;
  }
}


/* ── About page ────────────────────────────────────────── */
.about-section {
  max-width: 1000px;
  margin: 2em auto;
  margin-bottom: 5em;
  padding: 0 1em;
}

.section-heading {
  font-family: 'Raleway', sans-serif;
  text-align: center;
  font-size: 2em;
  font-weight: 800;
  margin-top: 2em;
  margin-bottom: 1em;
  color: var(--brand-primary);
}

.about-body {
  margin-top: 1em;
}

.contact-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 600px;
}

.contact-form-scaler {
  width: 125%;
  height: 1000px;
  transform: scale(0.6);
  transform-origin: top center;
  overflow: hidden;
}

.partners-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.partners-row {
  display: flex;
  gap: 50px;
  justify-content: center;
  align-items: center;
}


/* ── Footer ────────────────────────────────────────────── */
.rhd-footer {
  display: inline-flex;
  gap: 20pt;
  width: 100%;
  font-size: smaller;
  padding: 1em;
  color: var(--brand-white);
  background: var(--brand-tertiary);
  align-items: end;
  justify-content: center;
  max-height: 3em;
}

.rhd-footer a {
  color: var(--brand-primary);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 19px;
  text-decoration: none;
}

.rhd-footer a:hover {
  color: var(--brand-primary);
  opacity: 0.7;
}


/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 1023px) {
  body {
    padding-top: 3rem;
  }

  .navbar-logo {
    height: 3.5rem;
  }

  .map-section {
    width: 100%;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-column: 1;
    grid-row: auto;
    box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 0px 0px;
  }

  .map-state,
  .map-title,
  .map-caption,
  .map-container,
  .legend-desktop {
    grid-column: 1;
  }


  .partners-row {
    flex-direction: column;
    align-items: center;
    gap: 1.5em;
  }

  .partners-row img {
    max-width: 80%;
    width: 100% !important;
    height: auto !important;
  }

}

@media (max-width: 600px) {
  .contact-wrap {
    height: auto;
  }

  .contact-form-scaler {
    width: 100%;
    height: 1200px;
    transform: none;
  }
}