/* Custom styles. Bootstrap 5.3.3 is loaded from the CDN in each page. */

:root {
  --sdg-blue: #0a5aa8;
  --sdg-yellow: #ffd83b;
  /* Height of the WordPress sticky header. Change this one value if the header changes. */
  --sdg-header-offset: 82px;
  --sdg-gap: 16px;
}

html {
  scroll-behavior: smooth;
  /* Anchor jumps stop below the sticky header */
  scroll-padding-top: calc(var(--sdg-header-offset) + var(--sdg-gap));
}

/* Logged-in WordPress users also see the admin bar (32px, 46px on small screens).
   html:has() lets the scroll offset on <html> see WordPress' body.admin-bar class. */
html:has(> body.admin-bar),
body.admin-bar {
  --sdg-header-offset: calc(82px + 32px);
}

@media (max-width: 782px) {
  html:has(> body.admin-bar),
  body.admin-bar {
    --sdg-header-offset: calc(82px + 46px);
  }
}

/* ---- Title banner (matches the WordPress page) ---- */
.title-banner {
  background: var(--sdg-blue);
  color: var(--sdg-yellow);
}

/* ---- Goal tiles / cards ---- */
.goal-tile {
  flex: none;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2.6rem;
  font-weight: 700;
  object-fit: cover;
}

.goal-tile-lg {
  width: 64px;
  height: 64px;
}

.goal-card {
  border-radius: 0;
  transition: box-shadow 0.15s;
}

a.goal-card:hover {
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.15);
}

.wheel {
  max-width: 380px;
}

/* ---- Goal page header ---- */
.goal-hero {
  color: #0f2d12;
}

/* ---- Right-side navigation ---- */
.side {
  position: sticky;
  top: calc(var(--sdg-header-offset) + var(--sdg-gap));
  max-height: calc(100vh - var(--sdg-header-offset) - 2 * var(--sdg-gap));
  overflow-y: auto;
}

.nav-sub {
  padding-left: 1.6rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

.list-group-item.active {
  background: var(--bs-success);
  border-color: var(--bs-success);
  color: #fff;
}

/* ---- Content ---- */
.sdg-group {
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
  border-left: 5px solid var(--bs-success);
}

.sdg-page main img {
  height: auto; /* width/height attributes reserve space before photos load */
}

.fig-img {
  max-height: 380px;
  object-fit: contain;
  background: var(--bs-tertiary-bg);
}

/* ---- Back-to-top button ---- */
#totop {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  z-index: 1030;
}

/* ---- Per-goal colour theme ----
   Each goal page sets --goal / --goal-dark on .sdg-page (SDG 15 green is the default). */
.sdg-page {
  --goal: #56C02B;
  --goal-dark: #3f9a1c;
}

.text-goal {
  color: color-mix(in srgb, var(--goal-dark) 75%, #000);
}

.sdg-page .sdg-group {
  background: color-mix(in srgb, var(--goal) 14%, #fff);
  color: color-mix(in srgb, var(--goal-dark) 70%, #000);
  border-left-color: var(--goal);
}

.sdg-page .list-group-item.active {
  background: var(--goal-dark);
  border-color: var(--goal-dark);
  color: #fff;
}

.btn-goal,
.btn-goal:hover,
.btn-goal:focus {
  background: var(--goal-dark);
  border-color: var(--goal-dark);
  color: #fff;
}

.btn-goal:hover {
  filter: brightness(0.92);
}

.table-goal th {
  background: color-mix(in srgb, var(--goal) 22%, #fff);
}

.alert-goal {
  background: color-mix(in srgb, var(--goal) 10%, #fff);
  border-color: color-mix(in srgb, var(--goal) 35%, #fff);
  color: #212529;
}

.link-goal {
  color: color-mix(in srgb, var(--goal-dark) 70%, #000);
}

.answer-badge {
  background: var(--goal-dark);
  color: #fff;
}

.callout {
  background: color-mix(in srgb, var(--goal) 8%, #fff);
  border: 1px solid color-mix(in srgb, var(--goal) 35%, #fff);
}

.callout > :last-child {
  margin-bottom: 0;
}

/* Long lists scroll inside their own box */
.table-scroll {
  max-height: 520px;
  overflow: auto;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Long questions in the side menu: up to three lines, full text on the page */
#sidenav .nav-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#sidenav .list-group-item.active .nav-text {
  -webkit-line-clamp: unset;
}

#sidenav .nav-group {
  background: var(--bs-tertiary-bg);
}

.sdg-page #sidenav .list-group-item.active {
  background: var(--goal-dark) !important;
  border-color: var(--goal-dark);
  color: #fff;
}

.sdg-page main img.img-fluid {
  max-height: 520px;
}
