/*
  style.css
  LocalGov Drupal Network

  Table of Contents
  -----------------
  1.  Fonts
  2.  Variables
  3.  Reset & Base
  4.  Typography
  5.  Utilities
  6.  Buttons
  7.  Header
  8.  Footer
  9.  Dialog menu
  10. Banner / Hero
  11. Sections
  12. Components
  13. Responsive
  14. Reduced motion
  15. Network overview (home)
*/

/* ============================================================
   1. Fonts
   ============================================================ */

/*
  Fonts load without a flash of fallback text:
  - the four faces used above the fold are preloaded in each page's <head>
  - font-display: optional never swaps fonts after first paint
  - if a font misses the first paint, a size-matched local fallback (Arial)
    is used instead, so the layout does not shift (CLS)
*/

@font-face {
  font-family: "Barlow";
  src: url("../fonts/Barlow/barlow-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Barlow";
  src: url("../fonts/Barlow/barlow-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Barlow";
  src: url("../fonts/Barlow/barlow-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Barlow";
  src: url("../fonts/Barlow/barlow-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/BarlowCondensed/barlow-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: optional;
}

@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/BarlowCondensed/barlow-condensed-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: optional;
}

/* Fallbacks sized to Barlow's metrics (measured against Arial) */
@font-face {
  font-family: "Barlow Fallback";
  src: local("Arial"), local("ArialMT"), local("Helvetica"), local("Liberation Sans");
  font-weight: 400 600;
  size-adjust: 93.9%;
  ascent-override: 106.5%;
  descent-override: 21.3%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Barlow Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Bold"), local("Liberation Sans Bold");
  font-weight: 700 800;
  size-adjust: 90.7%;
  ascent-override: 110.3%;
  descent-override: 22.1%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Barlow Condensed Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Bold"), local("Liberation Sans Bold");
  font-weight: 700 800;
  size-adjust: 68%; /* tuned for the uppercase headlines */
  ascent-override: 147.1%;
  descent-override: 29.4%;
  line-gap-override: 0%;
}

/* ============================================================
   2. Variables
   ============================================================ */

:root {
  /* Brand colours */
  --color-yellow:          #ffe146;
  --color-teal:            #004459;
  --color-teal-mid:        #005c75;
  --color-teal-dark:       #003244;
  --color-blue-grey:       #668a96; /* map borders: looks like 40% white on the hero, but opaque so overlaps don't add up */
  --color-white:           #ffffff;
  --color-black:           #0b0c0c;

  /* Grey scale */
  --color-grey-lightest:   #f4f5f5;
  --color-grey-lighter:    #eaeaea;
  --color-grey-light:      #cecfd0;
  --color-grey-dark:       #444c50; /* 7:1 or more on every light background (AAA) */

  /* Fonts */
  --font-body:    "Barlow", "Barlow Fallback", system-ui, sans-serif;
  --font-display: "Barlow Condensed", "Barlow Condensed Fallback", sans-serif;

  /* Spacing (4pt scale) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-12: 48px;
  --sp-24: 96px;

  /* Widths */
  --width-container:  73.75rem; /* 1180px */
  --width-medium:     48rem;

  /* Line heights */
  --line-height:       1.65;
  --line-height-dark:  1.75;
  --line-height-tight: 1.15;

  /* Font sizes */
  --font-size:         1.0625rem; /* 17px */
  --font-size-small:   0.875rem; /* 14px: the smallest text size used */
  --font-size-h1:      clamp(2.2rem, 6vw, 3.75rem);
  --font-size-h2:      clamp(1.6rem, 4vw, 2.4rem);
  --font-size-h3:      clamp(1.15rem, 2.5vw, 1.5rem);
  --font-size-h4:      1rem;

  /* Border */
  --border-radius:      4px;
  --border-radius-md:   8px;
  --border-radius-large: 24px;

  /* Fixed header */
  --header-height: 72px;

  /* Animation */
  --transition-time: 0.25s;

  /* Vertical rhythm */
  --vertical-rhythm-spacing: calc(var(--line-height) * 1rem);
}

/* ============================================================
   3. Reset & Base
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-padding-top: var(--header-height);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--color-black);
  background-color: var(--color-white);
  -webkit-font-smoothing: antialiased;
}

img,
video,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

figure {
  margin: 0 0 var(--sp-4) 0;
}

figcaption {
  font-size: var(--font-size-small);
  text-align: center;
  color: var(--color-grey-dark);
  margin-top: var(--sp-2);
}

:where(:not(dialog)) {
  margin-block-start: 0;
}

:where(input, textarea, select, button) {
  font-family: inherit;
  font-size: var(--font-size);
  line-height: inherit;
}

/* Focus visible: black on light backgrounds, yellow on dark ones (set --focus-color per area) */
:focus-visible {
  outline: 3px solid var(--focus-color, var(--color-black));
  outline-offset: 3px;
}

.network-hero,
.banner {
  --focus-color: var(--color-yellow);
}

/* Skip link target: <main tabindex="-1"> takes focus without a ring around the whole page */
main:focus {
  outline: 3px solid transparent;
}

/* Skip link: first focusable element, visible only on focus */
.skip-link {
  position: absolute;
  z-index: 100;
  top: var(--sp-2);
  left: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--border-radius);
  background-color: var(--color-black);
  color: var(--color-yellow);
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
  outline-color: var(--color-yellow);
}

a {
  color: var(--color-teal);
  transition: color var(--transition-time);
}

a:hover {
  color: var(--color-black);
}

/* ============================================================
   4. Typography
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--line-height-tight);
  letter-spacing: -0.01em;
  color: var(--color-black);
  margin-block-end: 0;
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); font-weight: 700; }
h4 { font-size: var(--font-size-h4); font-weight: 700; }

p {
  max-width: 65ch;
  margin-block-end: 0;
}

ul, ol {
  padding-inline-start: var(--sp-6);
}

li {
  margin-block-start: var(--sp-2);
}

small {
  font-size: var(--font-size-small);
}

/* ============================================================
   5. Utilities
   ============================================================ */

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

.lgd-container {
  max-width: var(--width-container);
  margin-inline: auto;
}

.padding-horizontal {
  padding-inline: clamp(var(--sp-4), 3vw, var(--sp-8));
}

.flow > * + * {
  margin-block-start: var(--vertical-rhythm-spacing);
}

/* ============================================================
   6. Buttons
   ============================================================ */

:where(button, [type="button"], [type="reset"], [type="submit"], .button) {
  display: inline-block;
  padding: var(--sp-3) var(--sp-6);
  cursor: pointer;
  transition: background-color var(--transition-time), color var(--transition-time), box-shadow var(--transition-time);
  text-decoration: none;
  color: var(--color-black);
  border: 2px solid transparent;
  border-radius: 1000px;
  background-color: var(--color-white);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9375rem;
  line-height: 1.4;
}

:where(button, [type="button"], [type="reset"], [type="submit"], .button):hover,
:where(button, [type="button"], [type="reset"], [type="submit"], .button):focus-visible {
  background-color: var(--color-black);
  color: var(--color-yellow);
  border-color: var(--color-black);
  box-shadow: none;
}

:where(button, [type="button"], [type="reset"], [type="submit"], .button):active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

.button--accent {
  background-color: var(--color-yellow);
  color: var(--color-black);
}

.button--accent:hover,
.button--accent:focus-visible {
  background-color: var(--color-black);
  border-color: var(--color-black);
  color: var(--color-yellow);
  box-shadow: none;
}

/* ============================================================
   7. Header
   ============================================================ */

.header {
  --header-fg: var(--color-white);
  --header-bg: rgba(0,50,68,.35);
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  color: var(--header-fg);
  transition: color var(--transition-time);
}

/* Tinted, blurred backdrop over the hero; the bottom fades out with an eased mask */
.header::before {
  --header-fade: linear-gradient(to bottom,
    #000 0%,
    #000 50%,
    rgba(0,0,0,.92) 56%,
    rgba(0,0,0,.8) 62%,
    rgba(0,0,0,.65) 69%,
    rgba(0,0,0,.49) 75%,
    rgba(0,0,0,.34) 81%,
    rgba(0,0,0,.2) 87%,
    rgba(0,0,0,.09) 94%,
    transparent 100%);
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: calc(100% + var(--sp-12));
  z-index: -1;
  background-color: var(--header-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-mask-image: var(--header-fade);
  mask-image: var(--header-fade);
  transition: background-color var(--transition-time);
  pointer-events: none;
}

/* Below the hero: plain yellow, black text, no blur or fade (class set in script.js) */
.header--solid {
  --header-fg: var(--color-black);
  --header-bg: var(--color-yellow);
}

.header--solid::before {
  height: 100%;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--header-height);
}

.header__branding {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: var(--sp-4);
  color: inherit;
  text-decoration: none;
}

.header__branding:hover {
  color: inherit;
}

.header__logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
  /* logo.svg is black; render it white over the hero */
  filter: brightness(0) invert(1);
  transition: filter var(--transition-time);
}

.header--solid .header__logo {
  filter: brightness(0);
}

.header__slogan {
  display: none;
  max-width: 17rem;
  padding-inline-start: var(--sp-4);
  border-inline-start: 1px solid currentColor;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
}

.header__menu-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--border-radius-md);
  background-color: transparent;
  color: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.header__menu-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
}

.header__menu-button:hover,
.header__menu-button:focus-visible {
  background-color: rgba(255,255,255,.15);
  color: inherit;
  box-shadow: none;
}

.header--solid .header__menu-button:hover,
.header--solid .header__menu-button:focus-visible {
  background-color: rgba(11,12,12,.08);
}

.header :focus-visible {
  outline-color: currentColor;
}

@media screen and (min-width: 48rem) {
  .header__logo {
    height: 48px;
  }

  .header__slogan {
    display: block;
  }
}

/* ============================================================
   8. Footer
   ============================================================ */

footer {
  background-color: var(--color-yellow);
  padding-block: var(--sp-6);
  margin-top: var(--sp-12);
}

/* No gap when the page ends with a tinted section (e.g. the FAQ) */
main:has(> .faq:last-child) + footer {
  margin-top: 0;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4) var(--sp-8);
}

.footer__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--color-black);
}

.footer__logo svg {
  width: auto;
  height: 40px;
  fill: currentColor;
}

.footer__logo:hover,
.footer__logo:focus-visible {
  color: var(--color-teal);
}

/* Verified digital public good badge (LocalGov Drupal in the DPG registry) */
.footer__dpg {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.footer__dpg img {
  width: auto;
  height: 42px;
}

/* Mobile: logo on top, then main links and imprint/privacy as two rows */
.footer__inner nav {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-6);
}

.footer__menu.footer__menu--legal {
  flex-basis: 100%;
}

/* Desktop: one row, imprint/privacy pushed to the far right */
@media screen and (min-width: 48rem) {
  .footer__inner nav {
    flex-basis: 0%;
  }

  .footer__menu.footer__menu--legal {
    flex-basis: auto;
    margin-inline-start: auto;
  }
}

.footer__menu {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer__menu li {
  margin: 0;
}

.footer__menu a {
  display: inline-block;
  padding-block: calc((44px - 1lh) / 2); /* 44px target height; inline (not flex) keeps the space before the ↗ */
  text-decoration: none;
  color: var(--color-black);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: color var(--transition-time);
}

.footer__menu a:hover,
.footer__menu a:focus-visible {
  color: var(--color-teal);
  text-decoration: underline;
}

footer :focus-visible {
  outline-color: var(--color-black);
}

/* ============================================================
   9. Dialog menu
   ============================================================ */

.dialog-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  max-width: 80%;
  height: 100vh;
  height: 100dvh;
  max-height: none; /* browsers cap modal dialogs at 100% - 2em - 6px by default */
  margin: 0;
  padding: 0;
  transition:
    transform var(--transition-time) ease,
    display var(--transition-time) allow-discrete,
    overlay var(--transition-time) allow-discrete;
  transform: translateX(-100%);
  border: 1px solid var(--color-grey-lighter);
  background-color: var(--color-white);
  box-shadow: 8px 0 32px rgba(0,0,0,.18);
}

.dialog-menu[open] {
  transform: translateX(0);
}

@starting-style {
  .dialog-menu[open] {
    transform: translateX(-100%);
  }
}

.dialog-menu__close {
  display: flex;
  justify-content: flex-end;
  padding: var(--sp-4);
  border-block-end: 1px solid var(--color-grey-lighter);
}

.dialog-menu__menu {
  padding: var(--sp-4);
}

.dialog-menu__menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.dialog-menu__menu li + li {
  margin-top: var(--sp-2);
}

.dialog-menu__menu a {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  text-decoration: none;
  color: var(--color-black);
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: var(--border-radius-md);
  transition: background-color var(--transition-time);
}

.dialog-menu__menu a:hover,
.dialog-menu__menu a:focus-visible {
  background-color: var(--color-grey-lightest);
  color: var(--color-teal);
}

.dialog-menu__menu a:focus-visible {
  outline-offset: -3px;
}

/* ============================================================
   10. Banner / Hero
   ============================================================ */

@keyframes banner-bg {
  from { background-position: 0 50%; }
  50%  { background-position: 100% 50%; }
  to   { background-position: 0 50%; }
}

@keyframes fade-slide-up {
  from { opacity: 0; transform: translateY(0.75rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.banner {
  color: var(--color-white);
  background: linear-gradient(135deg, var(--color-teal) 0%, var(--color-teal-mid) 50%, var(--color-teal-dark) 100%);
  background-size: 300% 300%;
  animation: banner-bg 12s ease infinite;
  padding-block: clamp(var(--sp-12), 8vw, var(--sp-24));
  padding-block-start: calc(var(--header-height) + clamp(var(--sp-12), 8vw, var(--sp-24)));
}

.banner__inner {
  display: grid;
  gap: var(--sp-12);
}

/* Hero heading uses display font */
.banner h1 {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--color-white);
  letter-spacing: -0.01em;
}

.banner h1 {
  font-size: var(--font-size-h1);
  line-height: 1.05;
  margin-block-end: var(--sp-6);
}

.banner p {
  color: rgba(255,255,255,.9);
  line-height: var(--line-height-dark);
  letter-spacing: 0.01em;
  max-width: 55ch;
}

.banner__first-content p {
  animation: fade-slide-up 0.7s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  .banner,
  .banner__first-content p {
    animation: none;
    opacity: 1;
  }
}

/* Pretitle: small all-caps label above a heading */
.pretitle {
  margin-block-end: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-yellow);
}

/* Typewriter ([data-typewriter], see script.js): untyped letters keep their space but are invisible */
.typewriter__rest {
  visibility: hidden;
}

/* Zero net width, so the caret never pushes the text */
.typewriter__caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-inline: 2px -4px;
  vertical-align: -0.12em;
  background-color: currentColor;
  animation: caret-blink 0.8s steps(1) infinite;
  transition: opacity 0.4s 1.5s;
}

.is-typed .typewriter__caret {
  opacity: 0;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  /* Invisible until typing starts, so the text doesn't flash in full first.
     Transparent rather than hidden, so screen readers still find the heading. */
  .js [data-typewriter]:not(.is-typing) {
    color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typewriter__caret {
    animation: none;
  }
}

/* ============================================================
   11. Sections
   ============================================================ */

.section {
  padding-block: clamp(var(--sp-12), 6vw, var(--sp-24));
}

.section__header {
  max-width: var(--width-medium);
  margin-block-end: var(--sp-8);
  margin-inline: auto;
  text-align: center;
}

.section__text {
  max-width: 65ch;
}

/* ============================================================
   12. Components
   ============================================================ */

/* --- Prose containers (legal pages) --- */
.prose-content h2 + p {
  margin-block-start: var(--sp-3);
}

.prose-content * + h2 {
  margin-block-start: var(--sp-12);
}

.prose-content h3 {
  font-size: var(--font-size-h3);
  margin-block-start: var(--sp-8);
  margin-block-end: var(--sp-3);
}

.prose-content h4 {
  font-size: 1rem;
  margin-block-start: var(--sp-6);
  margin-block-end: var(--sp-2);
}

.prose-content p + p {
  margin-block-start: 2.5em; /* at least 1.5 × the line height (WCAG 1.4.8) */
}

.prose-content ul,
.prose-content ol {
  margin-block-start: var(--sp-3);
  margin-block-end: var(--sp-4);
}

.prose-content figure {
  margin-block: var(--sp-8);
}

.prose-content figure img {
  border-radius: var(--border-radius-md);
  width: 100%;
  max-width: 560px;
}

/* ============================================================
   13. Responsive
   ============================================================ */

@media screen and (min-width: 48rem) {
  .banner__inner {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}

/* ============================================================
   14. Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .header,
  .header::before,
  .header__logo {
    transition: none;
  }

  :root {
    --transition-time: 0.01s;
  }

  .dialog-menu {
    transition: none;
  }

  @starting-style {
    .dialog-menu[open] {
      transform: translateX(0);
    }
  }

  .footer__menu a {
    transition: none;
    transform: none !important;
  }

  :where(button, [type="button"], [type="reset"], [type="submit"], .button):active {
    transform: none;
  }
}

/* ============================================================
   15. Network overview (home)
   ============================================================ */

.network-hero {
  color: var(--color-white);
  background:
    radial-gradient(ellipse at 50% 70%, var(--color-teal-mid) 0%, transparent 70%),
    var(--color-teal-dark);
  padding-block-start: calc(var(--header-height) + clamp(var(--sp-4), 8vw - 40px, var(--sp-24) - 40px));
  overflow: hidden;
}

.network-hero__intro {
  position: relative;
  z-index: 1;
  max-width: 60rem;
}


.network-hero h1 {
  color: var(--color-white);
  font-size: clamp(2.75rem, 9vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  margin-block-end: var(--sp-6);
}

.network-hero__lead {
  color: rgba(255,255,255,.9);
  font-size: clamp(1.0625rem, 1.6vw, 1.3125rem);
  line-height: var(--line-height-dark);
  max-width: 52ch;
}

.network-hero h1,
.network-hero__lead {
  animation: fade-slide-up 0.7s ease both;
}

.network-hero__lead {
  animation-delay: 0.15s;
}

/* Map */

/* Pulled up under the intro: the top of the map is empty, faded sea */
.network-map {
  position: relative;
  /* Pulled up under the intro, minus 40px on desktop (scales down to 16px on phones) */
  margin-block-start: calc(-1 * clamp(var(--sp-4), 10vw, 10rem) + clamp(var(--sp-4), 3vw, 2.5rem));
}

.network-map__svg {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 80px);
  max-height: calc(100svh - 80px);
  margin-inline: auto;
  overflow: visible;
}

.network-map__base {
  fill: rgba(255,255,255,.05);
  stroke: var(--color-blue-grey);
  stroke-width: 0.8;
  stroke-linejoin: round;
}

.network-map__country path {
  stroke-width: 1.2;
  stroke-linejoin: round;
  transition: fill var(--transition-time), stroke var(--transition-time);
}

.network-map__country--live path {
  fill: var(--color-yellow);
  stroke: var(--color-blue-grey);
  stroke-width: 0.8;
}

.network-map__country--eval path {
  fill: url(#hatch-eval);
  stroke: var(--color-blue-grey);
  stroke-width: 0.8;
}

.network-map__label {
  font-family: var(--font-display);
  font-weight: 800;
  /* --map-label-min (set by script.js) keeps the rendered size at 14px or more when the map scales down.
     --map-label-fallback approximates it by breakpoint until the script runs, or if it never does. */
  --map-label-fallback-w: 14px; /* by width */
  --map-label-fallback-h: 14px; /* by height (the map is capped at viewport height) */
  font-size: max(14px, var(--map-label-min, max(var(--map-label-fallback-w), var(--map-label-fallback-h))));
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.network-map__country--live .network-map__label {
  fill: var(--color-teal-dark);
  /* Yellow halo keeps the text readable where it runs past the country's edge */
  stroke: var(--color-yellow);
  stroke-width: 0.3em;
  paint-order: stroke;
}

.network-map__country--eval .network-map__label {
  fill: var(--color-white);
  stroke: var(--color-teal-dark);
  stroke-width: 0.3em;
  paint-order: stroke;
}

@media screen and (max-height: 48.74rem) {
  .network-map__label {
    --map-label-fallback-h: 19px;
  }
}

@media screen and (max-height: 40.6rem) {
  .network-map__label {
    --map-label-fallback-h: 23px;
  }
}

@media screen and (max-width: 63.99rem) {
  .network-map__label {
    --map-label-fallback-w: 21px;
  }
}

@media screen and (max-width: 47.99rem) {
  .network-map__label {
    --map-label-fallback-w: 29px;
    font-size: max(15px, var(--map-label-min, max(var(--map-label-fallback-w), var(--map-label-fallback-h))));
  }
}

@media screen and (max-width: 29.99rem) {
  .network-map__label {
    --map-label-fallback-w: 38px;
  }
}

/* Phones: labels are large relative to the map, so Ireland's label moves west of the UK's */
@media screen and (max-width: 47.99rem) {
  .network-map__label[data-key="ie"] {
    text-anchor: end;
    transform: translate(10px, -16px);
  }
}

@media screen and (max-width: 22.49rem) {
  .network-map__label {
    --map-label-fallback-w: 44px;
  }
}

.network-map__country--live:hover path,
.network-map__country--live:focus-visible path {
  fill: var(--color-white);
  stroke: var(--color-white);
}

.network-map__country--live:hover .network-map__label,
.network-map__country--live:focus-visible .network-map__label {
  stroke: var(--color-white);
}

/* Transparent, not none: forced-colors mode (Windows high contrast) turns it into a visible ring */
.network-map__country--live:focus-visible {
  outline: 3px solid transparent;
}

/* Focus: white shape with a black 3px ring (fixed width, independent of the map's scale) */
.network-map__country--live:focus-visible path {
  stroke: var(--color-black);
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
}

/* Intro animation, runs once when the map scrolls into view (script.js adds .is-visible):
   outlines draw, then the live networks appear in founding order, then the evaluated ones.
   Only with JS (.js on <html>) and without reduced motion; otherwise the map is static. */
@keyframes map-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes map-fill {
  to { fill-opacity: 1; }
}

@keyframes map-pop {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: none; }
}

@keyframes map-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  /* All outlines draw first (the base map includes the evaluated countries) */
  .js .network-map__base path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    fill-opacity: 0;
  }

  .js .network-map__country--eval {
    opacity: 0;
  }

  .js .network-map__country--live {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
  }

  .js .network-map.is-visible .network-map__base path {
    animation:
      map-draw 1.2s ease-out forwards,
      map-fill .6s ease 1s forwards;
  }

  .js .network-map.is-visible .network-map__country--live {
    animation: map-pop .5s cubic-bezier(.2, .8, .3, 1.2) calc(1s + var(--step) * .45s) both;
  }

  .js .network-map.is-visible .network-map__country--eval {
    animation: map-fade .8s ease 2.6s both;
  }
}

/* Legend */

.network-map__legend-wrap {
  position: relative;
}

.network-map__legend {
  position: absolute;
  bottom: var(--sp-4);
  display: flex;
  gap: var(--sp-4);
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  list-style: none;
  border-radius: var(--border-radius-md);
  background-color: var(--color-teal-dark);
  font-size: var(--font-size-small);
  font-weight: 600;
}

.network-map__legend li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
}

.network-map__swatch {
  display: inline-block;
  width: 1.5rem;
  height: 1rem;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255,255,255,.5);
}

.network-map__swatch--live {
  background-color: var(--color-yellow);
}

.network-map__swatch--eval {
  border: 0;
  background: repeating-linear-gradient(45deg, var(--color-yellow) 0 3.5px, transparent 3.5px 7px);
}

@media screen and (max-width: 47.99rem) {
  /* Below the map on small screens, so it never covers a country label */
  .network-map__legend {
    position: static;
    width: fit-content;
  }

  .network-map__swatch {
    width: 1.125rem;
    height: 0.75rem;
  }
}

@media screen and (min-width: 48rem) {
  .network-map__legend {
    bottom: var(--sp-8);
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-6);
    font-size: 0.9375rem;
  }
}

/* Country cards */

.cards__header {
  margin-block-end: var(--sp-8);
}

.cards__header p {
  margin-block-start: var(--sp-3);
  color: var(--color-grey-dark);
}

.cards {
  display: grid;
  gap: var(--sp-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin: 0;
  padding: var(--sp-8) var(--sp-6);
  border: 1px solid var(--color-black);
  border-radius: var(--border-radius-large);
  background-color: var(--color-white);
  transition: box-shadow var(--transition-time), border-color var(--transition-time);
}

.card:hover,
.card:target {
  border-color: var(--color-teal);
  box-shadow: 0 2px 12px rgba(0,68,89,0.10);
}

.card__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.card__step {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--color-teal);
}

.card__badge {
  display: inline-block;
  padding: var(--sp-1) var(--sp-3);
  border-radius: 1000px;
  background-color: var(--color-yellow);
  font-size: var(--font-size-small);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card__badge--eval {
  background-color: var(--color-white);
  border: 1px solid var(--color-grey-light);
}

.card__badge--neutral {
  background-color: var(--color-teal);
  color: var(--color-white);
}

.card__title {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 800;
}

.card p {
  color: var(--color-grey-dark);
}

.card__main {
  align-self: flex-start;
  margin-block-start: auto;
}

.card__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
  padding: var(--sp-4) 0 0;
  border-block-start: 1px solid var(--color-grey-light);
  list-style: none;
}

.card__links li {
  margin: 0;
}

.card__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.9375rem;
}

.card--resources .card__links {
  margin-block-start: auto;
}

/* Same diagonal stripes as "in evaluation" on the map, in soft grey */
.card--eval,
.card--eval:hover {
  border-color: transparent;
  background: repeating-linear-gradient(45deg, var(--color-grey-lighter) 0 10px, var(--color-white) 10px 20px);
}

/* Cards fade and rise slightly as they scroll into view (script.js adds .is-visible
   and a small --delay so cards revealed together appear one after another) */
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .js .card {
    opacity: 0;
  }

  .js .card.is-visible {
    animation: card-in .6s cubic-bezier(.2, .7, .3, 1) var(--delay, 0s) both;
  }
}

@media screen and (min-width: 48rem) {
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (min-width: 68rem) {
  .cards {
    grid-template-columns: repeat(6, 1fr);
  }

  .card {
    grid-column: span 2;
  }

  .card--eval,
  .card--resources {
    grid-column: span 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .network-hero h1,
  .network-hero__lead {
    animation: none;
  }

  .card,
  .network-map__country path {
    transition: none;
  }
}

/* FAQ (content and FAQPage JSON-LD come from tools/map/site.mjs) */

.faq {
  background-color: var(--color-grey-lightest);
}

.faq__list {
  display: grid;
  gap: var(--sp-8) var(--sp-12);
}

.faq__item {
  padding-block-start: var(--sp-4);
  border-block-start: 1px solid var(--color-grey-light);
}

.faq__question {
  margin-block-end: var(--sp-2);
}

.faq__item p {
  color: var(--color-grey-dark);
}

.page-dates {
  max-width: none;
  margin-block-start: var(--sp-12);
  font-size: var(--font-size-small);
  color: var(--color-grey-dark);
  text-align: center;
}

@media screen and (min-width: 48rem) {
  .faq__list {
    grid-template-columns: repeat(2, 1fr);
  }
}
