/* =============================================================================
   TRTV — styles.css  ·  Milestone 1 (the Seedbed)
   Palette + layout + D5 treatment. Mobile-first. Colors come from CONFIG but
   are mirrored here as CSS variables (set once from JS in map.js:applyPalette).
   ========================================================================== */

:root {
  --cream:      #F3EAD7;
  --green-text: #33422B;
  --sage:       #74864F;
  --violet:     #49475C;
  --navy:       #2B2739;
  --wheat:      #C89A3C;
  --field-green:#74864F;

  --cream-card: #F7F0E1;         /* slightly lighter card over the ground */
  --sage-soft:  rgba(116,134,79,.28);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans:  system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --maxw: 1040px;
  --focus: 3px solid var(--violet);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--cream);
  color: var(--green-text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Equal-weight bilingual: EN then ES. ES italic — NEVER a different color. */
.bi { display: block; }
.bi .lang { display: block; }
.bi.bi--inline { display: inline; }
.bi.bi--inline .lang { display: inline; }
.lang--es { font-style: italic; }
.bi--inline .lang--en::after { content: '  ·  '; font-style: normal; color: var(--sage); }

a { color: var(--green-text); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: var(--focus); outline-offset: 2px; border-radius: 3px;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Header --------------------------------------------------------------- */
.site-header { text-align: center; padding: 28px 18px 8px; }
/* Emblem sits on cream; its baked halo blends with the exactly-#F3EAD7 header. */
.emblem { width: 150px; max-width: 40vw; height: auto; margin: 0 auto 6px; display: block; }
.kicker {
  font-family: var(--serif);
  font-size: clamp(15px, 2.4vw, 19px);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--sage);
  margin: 0 0 2px;
}
.kicker .lang--es { text-transform: uppercase; }
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(30px, 6.6vw, 54px);
  line-height: 1.05;
  color: var(--green-text);
  margin: 0;
}
.wordmark .lang--es { font-weight: 500; font-size: .82em; color: var(--green-text); }

/* ---- Seedbed frame + ornamental border ----------------------------------- */
.seedbed { padding: 14px 0 26px; }
.seedbed-frame {
  position: relative;
  padding: 56px;                 /* room for the icon border strips */
  margin: 0 auto;
  max-width: var(--maxw);
}
/* the four decorative icon strips (built in map.js). aria-hidden. */
.border-strip {
  position: absolute;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  opacity: .95;
}
.border-strip img { height: 34px; width: auto; display: block; }
.border-top    { top: 6px;    left: 56px; right: 56px; height: 44px; flex-direction: row; }
.border-bottom { bottom: 6px; left: 56px; right: 56px; height: 44px; flex-direction: row; }
.border-left   { left: 6px;  top: 56px; bottom: 56px; width: 44px; flex-direction: column; }
.border-right  { right: 6px; top: 56px; bottom: 56px; width: 44px; flex-direction: column; }

/* ---- Map stage + overlay -------------------------------------------------- */
.map-stage {
  position: relative;
  border: 1.5px solid var(--sage);
  border-radius: 6px;
  overflow: hidden;
  background: var(--cream);
}
.map {
  width: 100%;
  height: clamp(440px, 68vh, 700px);
  background: var(--cream);
}
/* MapLibre chrome tinted to palette */
.maplibregl-ctrl-group { background: var(--cream-card); }
.maplibregl-ctrl-group button + button { border-top-color: var(--sage-soft); }

.overlay {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  background: rgba(247, 240, 225, .94);
  border: 1.5px solid var(--sage);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 6px 22px rgba(43, 39, 57, .16);
  text-align: center;
}
.overlay .seedbed-msg {
  font-family: var(--serif);
  font-size: clamp(17px, 2.6vw, 22px);
  line-height: 1.32;
}
.overlay .seedbed-msg .lang--en { margin-bottom: 6px; }
.overlay .disclaimer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--sage-soft);
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--green-text);
  opacity: .82;
}

/* ---- Graceful-degradation fallback --------------------------------------- */
.fallback {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  text-align: center;
  background: var(--cream);
  padding: 24px;
}
.fallback.is-visible { display: flex; }
.fallback .msg {
  font-family: var(--serif);
  font-size: clamp(19px, 3.2vw, 26px);
  line-height: 1.35;
  max-width: 460px;
}

/* ---- What's Growing Here + legend ---------------------------------------- */
.whats-growing { padding: 26px 0 10px; }
.section-heading {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(24px, 4.4vw, 34px);
  margin: 0 0 12px;
  text-align: center;
}
.section-heading .lang--es { font-weight: 500; font-size: .78em; }
.growing-body {
  max-width: 720px; margin: 0 auto 8px;
  font-size: clamp(15px, 2.2vw, 17px);
}
.growing-body .lang--en { margin-bottom: 10px; }

.legend {
  margin: 22px auto 0;
  max-width: 940px;
  border: 1.5px solid var(--sage);
  border-radius: 8px;
  background: var(--cream-card);
  padding: 18px 18px 22px;
  /* seed-packet-back feel: a faint dashed inner rule */
  box-shadow: inset 0 0 0 6px rgba(247,240,225,.6), inset 0 0 0 7px var(--sage-soft);
}
.legend-caption {
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(18px, 3vw, 22px);
  margin-bottom: 2px;
}
.legend-note { text-align: center; font-size: 12.5px; color: var(--sage); margin-bottom: 14px; }
.legend-grid {
  display: grid;
  /* FIXED-WIDTH icon slots so columns align at any breakpoint */
  grid-template-columns: repeat(auto-fit, 150px);
  justify-content: center;
  gap: 14px 10px;
}
.legend-item { text-align: center; }
.legend-slot {
  height: 78px;                 /* fixed slot: tall spike ≈ round daisy */
  display: flex; align-items: flex-end; justify-content: center;
  margin-bottom: 6px;
}
.legend-slot img { max-height: 72px; max-width: 72px; width: auto; height: auto; }
.legend-name { font-size: 14px; line-height: 1.25; }
.legend-name .lang--en { font-weight: 600; }
.legend-name .lang--es { font-size: .92em; }

/* ---- Footer --------------------------------------------------------------- */
.site-footer {
  margin-top: 30px;
  border-top: 1.5px solid var(--sage);
  background: var(--cream);
  padding: 22px 18px 34px;
  text-align: center;
  font-size: 13px;
}
.footer-attr { font-family: var(--serif); font-size: clamp(15px, 2.4vw, 18px); margin-bottom: 10px; }
.footer-disclaimer { font-size: 11.5px; opacity: .82; max-width: 620px; margin: 0 auto 14px; line-height: 1.35; }
.footer-links {
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; align-items: center;
  margin-top: 8px;
}
.footer-links button, .footer-links a {
  background: none; border: none; cursor: pointer;
  font: inherit; color: var(--green-text);
  text-decoration: underline; text-underline-offset: 2px;
  min-height: 44px; padding: 0 4px;
  display: inline-flex; align-items: center;
}
.footer-links .sep { color: var(--sage); text-decoration: none; }

/* ---- Modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: none;
  background: rgba(43, 39, 57, .5);
  align-items: center; justify-content: center;
  padding: 18px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--cream-card);
  border: 1.5px solid var(--sage);
  border-radius: 10px;
  max-width: 620px; width: 100%;
  max-height: 84vh; overflow: auto;
  padding: 22px 24px 26px;
  box-shadow: 0 18px 50px rgba(43,39,57,.4);
}
.modal h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 4px; font-size: 26px; }
.modal .modal-close {
  float: right; background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--green-text);
  min-width: 44px; min-height: 44px;
}
.credits-intro { font-size: 13px; color: var(--sage); margin: 2px 0 4px; line-height: 1.4; }
.credits-intro .lang--es { font-style: italic; }
.credits-list a { color: var(--green-text); }
.credits-list { list-style: none; padding: 0; margin: 14px 0 0; font-size: 13px; }
.credits-list li { padding: 8px 0; border-bottom: 1px solid var(--sage-soft); line-height: 1.4; }
.credits-list .credit-flower { font-weight: 600; }
.credits-pending { color: var(--sage); font-style: italic; }

/* ---- Dev-preview toggle + popup (only present with ?preview=populated) ---- */
.preview-toggle {
  position: absolute; left: 14px; bottom: 14px; z-index: 5;
  display: flex; gap: 0; border: 1.5px solid var(--sage); border-radius: 20px; overflow: hidden;
  background: var(--cream-card);
}
.preview-toggle button {
  border: none; background: none; cursor: pointer; font: inherit;
  padding: 8px 14px; min-height: 40px; color: var(--green-text);
}
.preview-toggle button[aria-pressed="true"] { background: var(--sage); color: var(--cream); }
.preview-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  background: var(--wheat); color: var(--navy);
  font-size: 12px; text-align: center; padding: 4px 8px; letter-spacing: .04em;
}
/* custom HTML markers — hover scales from the marker's OWN base (the hover fix) */
.bloom-marker {
  border: none; background: none; padding: 0; cursor: pointer;
  display: block; line-height: 0;
  transform-origin: bottom center;          /* NOT the map/canvas origin */
  transition: transform .12s ease-out;
}
.bloom-marker img { height: 40px; width: auto; display: block;
  filter: drop-shadow(0 2px 2px rgba(43,39,57,.28)); }
.bloom-marker:hover, .bloom-marker:focus-visible { transform: scale(1.18); }
.cluster-marker {
  position: relative; border: none; background: none; cursor: pointer;
  padding: 0; line-height: 0; transform-origin: bottom center;
}
.cluster-marker img { height: 46px; width: auto; }
.cluster-marker img:nth-child(2) { position: absolute; left: 12px; bottom: 0; height: 40px; opacity: .9; }
.cluster-count {
  position: absolute; right: -6px; top: -6px;
  background: var(--sage); color: var(--cream);
  font: 600 11px/1 var(--sans); padding: 3px 5px; border-radius: 10px;
  min-width: 16px; text-align: center;
}

.storycard { font-family: var(--sans); max-width: 260px; }
.storycard .words { font-family: var(--serif); font-size: 16px; line-height: 1.35; margin: 0 0 8px; }
.storycard .who { font-size: 12.5px; color: var(--sage); margin: 0 0 8px; }
.storycard .bouquet { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 6px; }
.storycard .bouquet img { height: 30px; width: auto; }
.storycard .area-note { font-size: 11px; color: var(--sage); margin: 6px 0 0; }
.storycard .video { margin-top: 8px; }
.storycard .video iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 4px; }
.maplibregl-popup-content { background: var(--cream-card); border: 1px solid var(--sage); border-radius: 8px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--cream-card); }

/* ---- Motion / responsive -------------------------------------------------- */
@media (max-width: 560px) {
  .seedbed-frame { padding: 40px; }
  .border-top, .border-bottom { left: 40px; right: 40px; }
  .border-left, .border-right { top: 40px; bottom: 40px; }
  .border-strip img { height: 24px; }
  .legend-grid { grid-template-columns: repeat(auto-fit, 128px); }
  .emblem { width: 118px; }
  /* keep the overlay compact so the whole state still fits below it */
  .overlay { top: 12px; padding: 12px 14px; }
  .overlay .seedbed-msg { font-size: clamp(15px, 4vw, 18px); line-height: 1.28; }
  .overlay .disclaimer { margin-top: 8px; padding-top: 8px; font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
