/* ==========================================================================
   FLIP the Script — shared stylesheet
   Palette sampled directly from the FLIP logo (flip-logo.jpg):
     navy #033B5A · red #BE1E22 · green #0A8C58 · gold #DBB338
   Sector accents are darkened variants verified at >= 4.5:1 against white,
   so white text sits on them safely.
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */
:root {
  /* brand, straight from the logo */
  --brand-navy:  #033B5A;
  --brand-red:   #BE1E22;
  --brand-green: #0A8C58;
  --brand-gold:  #DBB338;

  /* sector accents — all >= 4.5:1 vs white */
  --sector-power:     #8A6A15;
  --sector-buildings: #033B5A;
  --sector-transport: #BE1E22;
  --sector-forests:   #077A4C;
  --sector-food:      #5F7A1E;
  --sector-industry:  #455A6B;

  /* surfaces + ink */
  --bg:          #FFFFFF;
  --bg-subtle:   #F4F6F8;
  --bg-sunken:   #ECEFF2;
  --surface:     #FFFFFF;
  --border:      #D8DEE4;
  --border-soft: #E7ECF0;

  --ink:         #14232E;
  --ink-muted:   #4A5C68;
  --ink-faint:   #6B7C88;
  --on-accent:   #FFFFFF;

  --accent:      var(--brand-navy);
  --accent-hover:#05507A;

  /* type */
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /* space + shape */
  --wrap: 1140px;
  --wrap-narrow: 760px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(3, 59, 90, .06), 0 8px 24px rgba(3, 59, 90, .07);
  --shadow-lift: 0 2px 4px rgba(3, 59, 90, .08), 0 16px 40px rgba(3, 59, 90, .13);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0E1620;
    --bg-subtle:   #14202C;
    --bg-sunken:   #101A24;
    --surface:     #16232F;
    --border:      #2A3B4A;
    --border-soft: #223140;

    --ink:         #E8EEF3;
    --ink-muted:   #A8BAC7;
    --ink-faint:   #8397A6;

    --accent:      #4FA3D1;
    --accent-hover:#7BC0E4;

    /* lightened so they stay legible as text/borders on a dark ground */
    --sector-power:     #D9AE3A;
    --sector-buildings: #5AA8D6;
    --sector-transport: #E8686B;
    --sector-forests:   #35B67C;
    --sector-food:      #9DBE4A;
    --sector-industry:  #8FA6B6;

    --on-accent:   #0E1620;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 16px 40px rgba(0, 0, 0, .45);
  }
}

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.18;
  letter-spacing: -.015em;
  margin: 0 0 .5em;
  font-weight: 700;
}

h1 { font-size: clamp(2rem, 1.35rem + 2.7vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2.125rem); }
h3 { font-size: 1.1875rem; }

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); }

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }
.wrap--narrow { max-width: var(--wrap-narrow); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: .75rem 1.25rem; border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

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

/* --------------------------------------------------------------- header -- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; min-height: 68px;
}

.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }
.brand__mark { width: 34px; height: 34px; flex: none; }
.brand__text { font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; }
.brand__text em { font-style: normal; color: var(--brand-red); }

.site-nav ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav a {
  display: block; padding: .5rem .8rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink-muted);
  font-size: .9375rem; font-weight: 500;
}
.site-nav a:hover { background: var(--bg-subtle); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 650; box-shadow: inset 0 -2px 0 var(--brand-red); }

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .8rem 1.5rem; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 1rem; font-weight: 600;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); color: var(--on-accent); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn--ghost:hover { background: var(--bg-subtle); color: var(--ink); border-color: var(--ink-faint); }
.btn__icon { width: 1em; height: 1em; flex: none; }

/* ----------------------------------------------------------------- hero -- */
.hero { padding: clamp(3rem, 6vw, 5.5rem) 0 clamp(2.5rem, 5vw, 4rem); }
.hero__grid {
  display: grid; grid-template-columns: 1fr; gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
@media (min-width: 900px) { .hero__grid { grid-template-columns: 1.25fr .75fr; } }

.hero__logo { width: clamp(88px, 11vw, 124px); margin-bottom: 1.75rem; }
.hero__title { margin-bottom: .35em; }
.hero__subtitle {
  font-family: var(--font-display); font-size: clamp(1.0625rem, .95rem + .5vw, 1.375rem);
  color: var(--ink-muted); font-style: italic; line-height: 1.4; margin-bottom: 1.5rem;
}
.hero__summary { font-size: 1.125rem; color: var(--ink-muted); max-width: 62ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .85rem; margin-top: 2rem; }

.hero__cover {
  border-radius: var(--radius); box-shadow: var(--shadow-lift);
  border: 1px solid var(--border-soft); overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
  display: block; width: 100%; max-width: 340px; margin-inline: auto;
}
/* fill the link box — the intrinsic 300px width otherwise leaves a white gap */
.hero__cover img { width: 100%; }
.hero__cover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

/* -------------------------------------------------------------- pillars -- */
.section { padding: clamp(3rem, 6vw, 5rem) 0; }
.section--tint { background: var(--bg-subtle); border-block: 1px solid var(--border-soft); }
.section__lead { color: var(--ink-muted); max-width: 68ch; font-size: 1.0625rem; }
.section__head { margin-bottom: 2.5rem; }

.pillars { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.pillar {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-top: 4px solid var(--pillar-color, var(--accent));
  border-radius: var(--radius); padding: 1.6rem 1.5rem;
  box-shadow: var(--shadow);
}
.pillar__letter {
  font-family: var(--font-display); font-size: 2.75rem; line-height: 1;
  color: var(--pillar-color, var(--accent)); font-weight: 700; display: block; margin-bottom: .3rem;
}
.pillar h3 { margin-bottom: .45em; font-size: 1.25rem; }
.pillar p { color: var(--ink-muted); font-size: .9688rem; margin: 0; }

.pillar--free      { --pillar-color: var(--brand-gold); }
.pillar--local     { --pillar-color: var(--brand-green); }
.pillar--immediate { --pillar-color: var(--brand-red); }
.pillar--persuasive{ --pillar-color: var(--accent); }

/* ------------------------------------------------------------ nav cards -- */
.cardlinks { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.cardlink {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.6rem 1.5rem;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.cardlink:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-lift);
  border-color: var(--accent); color: inherit;
}
.cardlink h3 { margin-bottom: .4em; }
.cardlink p { color: var(--ink-muted); font-size: .9375rem; margin: 0; }
.cardlink__arrow { color: var(--accent); font-weight: 700; margin-left: .3em; }

/* ----------------------------------------------------------- page intro -- */
.pagehead { padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(1.5rem, 3vw, 2.5rem); }
.pagehead__eyebrow {
  text-transform: uppercase; letter-spacing: .1em; font-size: .8125rem;
  font-weight: 700; color: var(--brand-red); margin-bottom: .75rem;
}
.pagehead p { color: var(--ink-muted); max-width: 70ch; font-size: 1.0625rem; }

/* --------------------------------------------------------------- filter -- */
.filterbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: 1.25rem 0 2rem; border-bottom: 1px solid var(--border-soft); margin-bottom: 2.5rem;
}
.filterbar__label {
  font-size: .8125rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-faint); margin-right: .35rem;
}
.chip {
  font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  padding: .45rem .95rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-muted);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { border-color: var(--chip-color, var(--accent)); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--chip-color, var(--accent));
  border-color: var(--chip-color, var(--accent));
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  .chip[aria-pressed="true"] { color: var(--bg); }
}

/* ---------------------------------------------------------- case studies -- */
.sector { margin-bottom: 3.25rem; scroll-margin-top: 90px; }
.sector[hidden] { display: none; }

.sector__head {
  display: flex; align-items: baseline; gap: .85rem;
  padding-bottom: .7rem; margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--sector-color, var(--accent));
}
.sector__head h2 { margin: 0; font-size: 1.5rem; color: var(--sector-color, var(--ink)); }
.sector__count { font-size: .875rem; color: var(--ink-faint); font-weight: 600; }

.cards { display: grid; gap: 1.15rem; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); }

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--sector-color, var(--accent));
  border-radius: var(--radius); padding: 1.4rem 1.4rem 1.25rem;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.card:focus-within { box-shadow: var(--shadow-lift); }

.card__tag {
  align-self: flex-start; font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--sector-color, var(--accent));
  margin-bottom: .7rem;
}
.card__title { font-size: 1.125rem; margin-bottom: .35em; }
.card__title a { color: inherit; text-decoration: none; }
/* stretched hit area — whole card is clickable, link keeps the semantics */
.card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card__title a:hover { color: var(--sector-color, var(--accent)); }

.card__project { color: var(--ink); font-weight: 600; font-size: .9375rem; margin-bottom: .3rem; }
.card__location {
  display: flex; align-items: center; gap: .4rem;
  color: var(--ink-muted); font-size: .875rem; margin-bottom: 1rem;
}
.card__location svg { width: .95em; height: .95em; flex: none; opacity: .7; }

.card__cta {
  margin-top: auto; display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8125rem; font-weight: 650; color: var(--ink-faint);
}
.card:hover .card__cta { color: var(--sector-color, var(--accent)); }
.card__cta svg { width: .9em; height: .9em; }

.noresults { padding: 2.5rem 0; color: var(--ink-muted); font-size: 1.0625rem; }
.noresults[hidden] { display: none; }

/* ------------------------------------------------------------------ map -- */
.mapframe {
  width: 100%; height: min(72vh, 640px); min-height: 380px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-sunken); box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.leaflet-popup-content-wrapper { border-radius: var(--radius-sm); box-shadow: var(--shadow-lift); }
.leaflet-popup-content { font-family: var(--font-body); color: var(--ink); margin: .9rem 1.1rem; min-width: 190px; }
.mappopup__tag {
  display: block; font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: .35rem;
}
.leaflet-popup-content h3 { font-size: 1.0625rem; margin-bottom: .3em; }
.mappopup__project { font-weight: 600; font-size: .9375rem; margin-bottom: .15rem; }
.mappopup__location { color: var(--ink-muted); font-size: .8438rem; margin-bottom: .6rem; }
.leaflet-popup-content a { font-size: .875rem; font-weight: 650; text-decoration: none; }

/* ----------------------------------------------------------- pdf viewer -- */
.docview { padding-bottom: clamp(3rem, 6vw, 5rem); }

.docview__actions {
  display: flex; flex-wrap: wrap; gap: .85rem; align-items: center;
  margin-bottom: 1.5rem;
}

.docframe {
  width: 100%; height: min(78vh, 900px); min-height: 480px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-sunken); box-shadow: var(--shadow); display: block;
}

/* Inline PDF viewers are unreliable on small screens — offer the link instead. */
.docframe--mobilehide { display: none; }
@media (min-width: 768px) { .docframe--mobilehide { display: block; } }

.docfallback {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 2rem 1.5rem; text-align: center; background: var(--bg-subtle);
}
.docfallback p { color: var(--ink-muted); margin-bottom: 1.25rem; }
@media (min-width: 768px) { .docfallback { display: none; } }

.notecard {
  border-left: 4px solid var(--brand-gold);
  background: var(--bg-subtle); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.15rem 1.4rem; margin-bottom: 2rem;
}
.notecard p { color: var(--ink-muted); font-size: .9375rem; margin: 0; }

/* --------------------------------------------------------------- footer -- */
.site-footer {
  background: var(--bg-subtle); border-top: 1px solid var(--border-soft);
  padding: 3rem 0 2.5rem; margin-top: auto;
}
.site-footer__grid {
  display: grid; gap: 2rem; grid-template-columns: 1fr;
  padding-bottom: 2rem; border-bottom: 1px solid var(--border);
}
@media (min-width: 720px) { .site-footer__grid { grid-template-columns: 1.5fr 1fr; } }

.site-footer h2 { font-size: 1.125rem; margin-bottom: .5em; }
.site-footer p, .site-footer address {
  color: var(--ink-muted); font-size: .9375rem; font-style: normal; margin: 0 0 .5rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: .4rem; }
.site-footer a { font-size: .9375rem; }

.site-footer__base {
  padding-top: 1.5rem; color: var(--ink-faint); font-size: .8438rem;
  display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; justify-content: space-between;
}

/* print: drop chrome, keep content */
@media print {
  .site-header, .filterbar, .site-footer, .skip-link { display: none; }
  .card, .pillar { break-inside: avoid; box-shadow: none; }
  body { font-size: 11pt; }
}
