/* SDG Hub year: animated year text + year picker (see static/js/sdg_year.js) */

:root {
  --sdg-blue: #009dda;
  --sdg-navy: #062969;
  --sdg-ink: #1f2a44;
  --sdg-muted: #6b7a99;
  --sdg-line: #d9e1ee;
  --sdg-tint: #eef3fb;
}

/* ---------- Heading: logo + year at the same height ---------- */

.sdg-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.sdg-heading__row {
  /* Logo is 1024x187 and the year adds ~2.4 heights, so shrink on phones */
  --sdg-h: clamp(32px, calc((100vw - 3rem) / 8.2), 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  /* The logo PNG already has ~0.18 height of transparent padding on its right */
  gap: calc(var(--sdg-h) * 0.02);
  max-width: 100%;
}

.sdg-heading__row .sdg_title {
  height: var(--sdg-h);
  width: auto;
  max-width: none;
  flex: none;
}

/* ---------- Odometer year text ---------- */

.sdg-year {
  position: relative;
  display: inline-flex;
  flex: none;
  height: var(--sdg-h, 80px);
  /* Digit ink matches the logo lettering (rows 31-149 of 187) */
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: calc(var(--sdg-h, 80px) * 0.9);
  line-height: var(--sdg-h, 80px);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.sdg-year__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sdg-year__digits {
  position: relative;
  top: calc(var(--sdg-h, 80px) * -0.02);
  display: inline-flex;
  /* Fade digits in/out as they roll through the window */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 84%, transparent 100%);
  filter: drop-shadow(0 calc(var(--sdg-h, 80px) * 0.05) calc(var(--sdg-h, 80px) * 0.08) rgba(0, 157, 218, 0.28));
}

.sdg-year__digit {
  display: inline-block;
  height: var(--sdg-h, 80px);
  overflow: hidden;
}

.sdg-year__strip {
  display: flex;
  flex-direction: column;
  transform: translate3d(0, calc(var(--d, 0) * -1 * var(--sdg-h, 80px)), 0);
  transition: transform 1.15s cubic-bezier(0.2, 1.28, 0.38, 1) calc(var(--i, 0) * 110ms);
  /* Brand blue with a band of goal colours sweeping digit to digit */
  background: linear-gradient(100deg,
      var(--sdg-blue) 0 36%,
      #e5243b 39%, #dda63a 41.5%, #4c9f38 44%, #26bde2 46.5%, #fcc30b 49%,
      #fd6925 51.5%, #dd1367 54%, #56c02b 56.5%, #19486a 59%,
      var(--sdg-blue) 63% 100%) 100% 0 / 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sdg-year-shimmer 6.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  animation-delay: calc(1.4s + var(--i, 0) * 0.62s);
  will-change: transform;
}

.sdg-year__strip > span {
  display: block;
  height: var(--sdg-h, 80px);
  text-align: center;
}

.sdg-year__digit.is-instant .sdg-year__strip {
  transition: none;
}

/* Motion blur while a digit rolls */
.sdg-year__digit.is-rolling {
  animation: sdg-year-blur 1.15s ease-out calc(var(--i, 0) * 110ms) both;
}

@keyframes sdg-year-shimmer {
  0% { background-position: 100% 0; }
  32%, 100% { background-position: 0 0; }
}

@keyframes sdg-year-blur {
  0% { filter: blur(0); }
  18% { filter: blur(calc(var(--sdg-h, 80px) * 0.035)); }
  55%, 100% { filter: blur(0); }
}

/* ---------- Year picker: themed dropdown with a year timeline ----------
 * sdg_year.js builds the trigger + menu from the native <select>, which stays
 * in the DOM as the source of truth (and as the no-JS fallback). */

.sdg-year-picker {
  position: relative;
  z-index: 40;
  display: inline-block;
  font-family: 'Poppins', sans-serif;
}

/* No-JS fallback: plain select in the site style */
.sdg-year-picker select {
  min-height: 46px;
  padding: 0.4rem 2.2rem 0.4rem 0.9rem;
  border: 1.5px solid var(--sdg-line);
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23062969' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.85rem center / 0.7rem;
  appearance: none;
  -webkit-appearance: none;
  color: var(--sdg-navy);
  font: 700 0.95rem 'Poppins', sans-serif;
  cursor: pointer;
}

.sdg-year-picker.is-enhanced select {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.sdg-year-picker__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 46px;
  padding: 0.3rem 0.95rem 0.3rem 0.35rem;
  border: 1.5px solid var(--sdg-line);
  border-radius: 8px;
  background: #fff;
  color: var(--sdg-navy);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(6, 41, 105, 0.06), 0 4px 12px rgba(6, 41, 105, 0.07);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.sdg-year-picker__trigger:hover,
.sdg-year-picker.is-open .sdg-year-picker__trigger {
  border-color: var(--sdg-navy);
  box-shadow: 0 6px 18px rgba(6, 41, 105, 0.16);
}

.sdg-year-picker__trigger:hover {
  transform: translateY(-1px);
}

.sdg-year-picker__trigger:focus-visible {
  outline: 3px solid rgba(6, 41, 105, 0.25);
  outline-offset: 2px;
}

.sdg-year-picker__trigger:disabled {
  cursor: progress;
  transform: none;
}

.sdg-year-picker__icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 6px;
  background: var(--sdg-navy);
  color: #fff;
  font-size: 0.95rem;
}

.sdg-year-picker__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.sdg-year-picker__caption {
  color: var(--sdg-muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sdg-year-picker__value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sdg-year-picker__chevron {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  transition: transform 0.25s ease;
}

.sdg-year-picker.is-open .sdg-year-picker__chevron {
  transform: rotate(180deg);
}

.sdg-year-picker.is-loading .sdg-year-picker__chevron {
  animation: sdg-picker-spin 0.8s linear infinite;
}

/* Menu */

.sdg-year-picker__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  min-width: max(100%, 210px);
  padding: 0.5rem;
  border: 1px solid var(--sdg-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(6, 41, 105, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -6px) scale(0.98);
  transform-origin: top center;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.sdg-year-picker.is-open .sdg-year-picker__menu {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.sdg-year-picker__menu-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  padding: 0.3rem 0.6rem 0.55rem;
  border-bottom: 1px solid var(--sdg-line);
  color: var(--sdg-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sdg-year-picker__list {
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  outline: none;
}

.sdg-year-picker__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  color: var(--sdg-ink);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Timeline rail through the dots */
.sdg-year-picker__option::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(0.7rem + 5px);
  width: 2px;
  background: var(--sdg-line);
}

.sdg-year-picker__option:first-child::before { top: 50%; }
.sdg-year-picker__option:last-child::before { bottom: 50%; }
.sdg-year-picker__option:only-child::before { display: none; }

.sdg-year-picker__dot {
  position: relative;
  width: 12px;
  height: 12px;
  flex: none;
  border: 2px solid #9fb0cc;
  border-radius: 50%;
  background: #fff;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.sdg-year-picker__tag {
  margin-left: auto;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 157, 218, 0.12);
  color: #00689d;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sdg-year-picker__check {
  width: 1em;
  margin-left: auto;
  font-size: 0.8rem;
  visibility: hidden;
}

.sdg-year-picker__tag + .sdg-year-picker__check {
  margin-left: 0;
}

.sdg-year-picker__option.is-active {
  background: var(--sdg-tint);
}

.sdg-year-picker__option.is-active .sdg-year-picker__dot {
  border-color: var(--sdg-navy);
}

.sdg-year-picker__option[aria-selected='true'] {
  background: var(--sdg-navy);
  color: #fff;
}

.sdg-year-picker__option[aria-selected='true']::before {
  background: rgba(255, 255, 255, 0.3);
}

.sdg-year-picker__option[aria-selected='true'] .sdg-year-picker__dot {
  border-color: #fff;
  background: var(--sdg-blue);
  box-shadow: 0 0 0 3px rgba(0, 157, 218, 0.35);
}

.sdg-year-picker__option[aria-selected='true'] .sdg-year-picker__tag {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sdg-year-picker__option[aria-selected='true'] .sdg-year-picker__check {
  visibility: visible;
}

@keyframes sdg-picker-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sdg-year__strip,
  .sdg-year__digit.is-rolling,
  .sdg-year-picker__trigger,
  .sdg-year-picker__chevron,
  .sdg-year-picker__menu,
  .sdg-year-picker__option {
    animation: none;
    transition: none;
  }
}
