/* ============================================================
   Chinampa Project — design system
   Palette derived from the existing identity + the Xochimilco
   landscape. Photography carries the color; the UI stays quiet.
   ============================================================ */

:root {
  /* Primary institutional */
  --blue:       #0B4F7C;
  --cream:      #F2E8D3;
  --green:      #607A3A;
  --yellow:     #F2C230;

  /* Secondary landscape palette */
  --canal:      #4E6F74;
  --soil:       #3B3027;
  --straw:      #B99A63;
  --leaf:       #73855D;
  --harvest:    #C96E32;   /* decorative accents only (fails AA as small text on cream) */
  --harvest-deep: #9A4E16; /* AA-compliant harvest for small text on light bg */
  --dusty-red:  #8A4F3D;
  --water-grey: #D8DFDC;
  --off-white:  #F8F6F0;

  --serif: "EB Garamond", Georgia, serif;
  --sans: "DM Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --max: 1160px;
  --measure: 68ch;
  --header-h: 72px;
  /* single vertical rhythm for all scenes */
  --scene-pad: clamp(72px, 10vh, 128px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--sans);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  line-height: 1.7;
  color: var(--soil);
  background: var(--off-white);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, blockquote { font-family: var(--serif); font-weight: 500; line-height: 1.15; color: var(--soil); }
h1 { font-size: clamp(2.2rem, 1.4rem + 4vw, 4.5rem); }
h2 { font-size: clamp(1.7rem, 1.2rem + 2.4vw, 3rem); }
h3 { font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.6rem); }

a { color: var(--blue); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.measure { max-width: var(--measure); }

/* ---------- header (sticky everywhere) ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--header-h);
  padding: 10px clamp(16px, 4vw, 40px);
  transition: background .35s ease, box-shadow .35s ease;
  /* scrim so white links stay readable over bright hero foliage */
  background: linear-gradient(180deg, rgba(11,49,76,.62), rgba(11,49,76,0));
}
.site-header.solid,
.site-header.scrolled {
  background: var(--blue);
  box-shadow: 0 2px 14px rgba(0,0,0,.22);
}
/* keep content below the fixed header on pages without a hero */
body.no-hero main { padding-top: var(--header-h); }

.site-header .stamp img { height: 44px; width: auto; }
.main-nav { display: flex; gap: 2px 4px; flex-wrap: wrap; align-items: center; }
.main-nav a {
  color: rgba(255,255,255,.92); text-decoration: none;
  font-size: .92rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 12px 12px; /* ≥44px touch target */
  border-radius: 4px;
}
.main-nav a:hover { background: rgba(255,255,255,.14); }
.main-nav a[aria-current="page"] { border-bottom: 2px solid var(--yellow); border-radius: 0; }
.lang-switch { margin-left: 16px; border-left: 1px solid rgba(255,255,255,.3); padding-left: 16px; }
.lang-switch a { font-size: .85rem; }

/* hamburger */
.nav-toggle {
  display: none;
  background: none; border: 1px solid rgba(255,255,255,.5); border-radius: 6px;
  width: 48px; height: 48px; cursor: pointer; color: #fff;
  align-items: center; justify-content: center;
}
.nav-toggle svg { width: 24px; height: 24px; }
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 860px) {
  .site-header { min-height: 64px; }
  .nav-toggle { display: flex; }
  .main-nav {
    position: fixed; top: 64px; left: 0; right: 0;
    background: var(--blue);
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px 0 16px;
    box-shadow: 0 12px 24px rgba(0,0,0,.3);
    display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 13px clamp(20px, 6vw, 40px); min-height: 48px; font-size: 1rem; border-radius: 0; }
  .main-nav a[aria-current="page"] { border-bottom: 0; border-left: 3px solid var(--yellow); background: rgba(255,255,255,.08); }
  .lang-switch { margin: 8px clamp(20px, 6vw, 40px) 0; border-left: 0; padding: 8px 0 0; border-top: 1px solid rgba(255,255,255,.25); }
  .site-header.menu-open { background: var(--blue); }
}

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: 92svh;
  display: flex; flex-direction: column; justify-content: flex-end;
  color: #fff; overflow: hidden;
}
.hero picture { position: absolute; inset: 0; z-index: 0; }
.hero .hero-img, .hero picture img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0;
  animation: hero-breathe 24s ease-in-out infinite alternate; transform-origin: 50% 80%;
}
@keyframes hero-breathe { from { transform: scale(1); } to { transform: scale(1.045); } }
@media (prefers-reduced-motion: reduce) { .hero .hero-img, .hero picture img { animation: none; } }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(11,31,44,.25) 0%, rgba(11,31,44,0) 35%, rgba(11,31,44,.55) 100%);
}
.hero-inner { position: relative; z-index: 2; padding: 0 clamp(16px, 4vw, 40px) clamp(48px, 8vh, 90px); max-width: var(--max); margin: 0 auto; width: 100%; }
.hero h1 { color: #fff; text-shadow: 0 2px 24px rgba(0,0,0,.35); max-width: 16ch; }
.hero .locus { font-family: var(--mono); font-size: .85rem; letter-spacing: .12em; color: var(--cream); margin-top: 14px; text-transform: uppercase; }
.hero-actions { margin-top: 28px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- buttons: exactly two levels ---------- */
.btn {
  display: inline-block; font-family: var(--sans); font-size: .95rem; letter-spacing: .05em;
  text-transform: uppercase; text-decoration: none; padding: 13px 26px; border-radius: 3px;
  border: 1px solid transparent; min-height: 44px;
}
/* primary: the one action we most want on that screen */
.btn-primary { background: var(--yellow); color: var(--soil); border-color: var(--yellow); }
.btn-primary:hover { background: #ffd24a; border-color: #ffd24a; }
/* secondary: everything else */
.btn-secondary { border-color: currentColor; color: var(--blue); background: transparent; }
.btn-secondary:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
/* secondary over photos / dark scenes */
.on-dark .btn-secondary, .hero .btn-secondary, .scene-blue .btn-secondary, .scene-soil .btn-secondary { color: #fff; border-color: rgba(255,255,255,.75); }
.on-dark .btn-secondary:hover, .hero .btn-secondary:hover, .scene-blue .btn-secondary:hover, .scene-soil .btn-secondary:hover { background: rgba(255,255,255,.16); border-color: #fff; color: #fff; }
/* legacy aliases (kept so nothing breaks if a page still uses them) */
.btn-ghost { border-color: rgba(255,255,255,.75); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.16); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #0a4066; }
.btn-outline { border-color: var(--blue); color: var(--blue); }
.btn-outline:hover { background: var(--blue); color: #fff; }

/* ---------- scenes / sections: single rhythm ---------- */
.scene { padding: var(--scene-pad) 0; }
.scene-cream { background: var(--cream); }
.scene-blue { background: var(--blue); color: var(--off-white); }
.scene-blue h2, .scene-blue h3 { color: var(--off-white); }
.scene-blue a { color: var(--cream); }
.scene-soil { background: var(--soil); color: var(--cream); }
.scene-soil h2, .scene-soil h3 { color: var(--cream); }
.scene-soil a { color: var(--straw); }

/* section eyebrows: green on light, yellow on dark — always AA */
.kicker {
  font-family: var(--mono); font-size: .8rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--green); margin-bottom: 18px;
}
.scene-blue .kicker, .scene-soil .kicker { color: var(--yellow); }

.lede { font-size: clamp(1.15rem, 1rem + 0.7vw, 1.45rem); line-height: 1.6; max-width: 56ch; }

/* stakes numbers */
.stakes { position: relative; color: #fff; padding: clamp(90px, 16vh, 170px) 0; overflow: hidden; }
.stakes .bg, .stakes picture img { position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%; }
.stakes picture { position: absolute; inset: 0; }
/* lateral scrim anchors the text block, like the hero gradient */
.stakes::after {
  content:""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(23,32,27,.82) 0%, rgba(23,32,27,.55) 45%, rgba(23,32,27,.18) 100%);
}
.stakes .wrap { position: relative; z-index: 2; }
.stakes .big {
  font-family: var(--serif); font-size: clamp(2.6rem, 2rem + 5vw, 6rem); line-height: 1.05; color: #fff;
  text-shadow: 0 2px 18px rgba(0,0,0,.45);
}
.stakes .big em { font-style: normal; color: var(--yellow); }
.stakes .foot { margin-top: 26px; max-width: 52ch; color: rgba(255,255,255,.92); }
.stakes cite { font-style: normal; font-family: var(--mono); font-size: .75rem; display: block; margin-top: 10px; color: rgba(255,255,255,.65); }

/* photo band */
.band { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.band figure { position: relative; overflow: hidden; }
.band img { width: 100%; height: 100%; min-height: 320px; object-fit: cover; }
.band figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px;
  font-family: var(--mono); font-size: .75rem; letter-spacing: .08em; color: var(--cream);
  background: linear-gradient(transparent, rgba(23,32,27,.75));
}
.full-bleed { width: 100%; }
.full-bleed img { width: 100%; max-height: 82vh; object-fit: cover; }

/* anatomy / loop diagrams */
.diagram { margin: 32px auto 0; max-width: 640px; }
.diagram svg text { font-family: var(--mono); }
.anatomy-step { display: grid; grid-template-columns: 56px 1fr; gap: 18px; align-items: baseline; padding: 18px 0; border-bottom: 1px solid rgba(59,48,39,.14); }
.scene-blue .anatomy-step { border-color: rgba(248,246,240,.18); }
.anatomy-step .n { font-family: var(--mono); color: var(--harvest); font-size: .85rem; }
.scene-blue .anatomy-step .n { color: var(--yellow); }
.anatomy-step h3 { margin-bottom: 4px; }
.anatomy-note { font-family: var(--mono); font-size: .8rem; color: var(--canal); margin-top: 22px; }
.scene-blue .anatomy-note { color: var(--water-grey); }

/* people */
.people-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 26px; margin-top: 40px; }
.person img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.person h3 { margin-top: 14px; }
.person .role { font-family: var(--mono); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--harvest-deep); margin-top: 2px; }
.person blockquote { font-size: 1.1rem; margin-top: 10px; color: var(--canal); }

/* ecosystem roles */
.roles { display: grid; gap: 0; margin-top: 34px; border-top: 1px solid rgba(248,246,240,.2); }
.role-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid rgba(248,246,240,.2); align-items: baseline; }
.role-row .verb { font-family: var(--mono); letter-spacing: .14em; font-size: .85rem; color: var(--yellow); text-transform: uppercase; }
.partner-logos { display: flex; gap: 34px; align-items: center; flex-wrap: wrap; margin-top: 40px; }
.partner-logos img { max-height: 64px; width: auto; background: #fff; padding: 8px 12px; border-radius: 4px; }

/* participation cards */
.routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; margin-top: 40px; }
.route { background: var(--off-white); border: 1px solid rgba(59,48,39,.12); padding: 30px 26px; display: flex; flex-direction: column; gap: 12px; }
.route .kicker { margin-bottom: 0; }
.route p { flex: 1; }

/* KPI tiers — in-palette, explicit states */
.kpi-tier { margin-top: 40px; }
.kpi-tier h3 { border-bottom: 2px solid var(--straw); padding-bottom: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 18px; }
.kpi { background: var(--cream); border: 1px solid rgba(11,79,124,.25); border-left: 4px solid var(--blue); padding: 20px; }
.kpi .v { font-family: var(--serif); font-size: 2rem; color: var(--blue); }
.kpi .l { font-size: .9rem; }
.kpi .status {
  display: inline-block; font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--soil); background: rgba(11,79,124,.1); padding: 3px 8px; border-radius: 3px; margin-top: 10px;
}
.kpi.pending { border-left-color: var(--yellow); }
.kpi.pending .status { background: var(--yellow); color: var(--soil); }

/* field notes */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; margin-top: 36px; }
.note-card img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.note-card .cat { font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--harvest-deep); margin-top: 12px; }
.note-card h3 { margin-top: 4px; }
.note-card time { font-size: .85rem; color: var(--canal); }

/* forms */
.form { display: grid; gap: 16px; max-width: 640px; margin-top: 26px; }
.form label { display: grid; gap: 6px; font-size: .92rem; font-weight: 500; }
.form input, .form select, .form textarea {
  font: inherit; padding: 12px; border: 1px solid rgba(59,48,39,.3); border-radius: 3px; background: #fff; color: var(--soil);
}
.form textarea { min-height: 120px; }
.form button { cursor: pointer; }
.form-alt { font-size: .85rem; color: var(--canal); }

/* footer */
.site-footer { background: var(--soil); color: var(--cream); padding: 60px 0 40px; }
.site-footer a { color: var(--straw); }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 30px; }
.site-footer .stamp img { height: 52px; }
.site-footer .fine { margin-top: 40px; font-size: .8rem; color: rgba(242,232,211,.6); }
.site-footer .prefs-link { background: none; border: none; color: var(--straw); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

/* back to top */
.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 45;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--blue); color: #fff; border: 1px solid rgba(255,255,255,.35);
  font-size: 1.2rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease;
}
.to-top.show { opacity: .92; pointer-events: auto; transform: none; }
.to-top:hover { opacity: 1; }

/* ---------- reveal on scroll: content visible by default; animate only with JS ---------- */
html.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
html.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1; transform: none; transition: none; }
}

/* loop svg draw-on-scroll (visible without JS) */
html.js .loop-path { stroke-dasharray: 1400; stroke-dashoffset: 1400; transition: stroke-dashoffset 2s ease; }
html.js .in .loop-path { stroke-dashoffset: 0; }
@media (prefers-reduced-motion: reduce) { html.js .loop-path { stroke-dashoffset: 0 !important; transition: none; } }

/* cookie banner */
.consent {
  position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 60;
  background: var(--soil); color: var(--cream); padding: 18px 20px; border-radius: 6px;
  display: none; gap: 14px; align-items: center; flex-wrap: wrap; max-width: 720px; margin: 0 auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.consent.show { display: flex; }
.consent p { flex: 1 1 320px; font-size: .88rem; }
.consent button { font: inherit; font-size: .85rem; padding: 10px 18px; border-radius: 3px; border: 1px solid var(--straw); background: transparent; color: var(--cream); cursor: pointer; }
.consent button.accept { background: var(--yellow); border-color: var(--yellow); color: var(--soil); }

/* utilities */
.mt-1 { margin-top: 16px; } .mt-2 { margin-top: 28px; } .mt-3 { margin-top: 44px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--yellow); color: var(--soil); padding: 10px 16px; z-index: 100; }
.skip-link:focus { left: 12px; }

@media (max-width: 720px) {
  .hero { min-height: 78svh; }
  .role-row { grid-template-columns: 1fr; gap: 4px; }
}
