/* FTW-2e viewer. Palette: FTW brand (Cyprus base, Yellow Green accent, Burning Orange for boundaries). */
:root {
  --cyprus: #004747;
  --cyprus-ink: #012626;
  --surface-2: rgba(0, 49, 47, 0.85);
  --meadow: #22a070;
  --yellow-green: #c0d85b;
  --orange: #ff7f41;
  --powder: #b5e1e6;
  --porcelain: #e7eaf2;
  --text: var(--porcelain);
  --muted: rgba(181, 225, 230, 0.7);
  --line: rgba(192, 216, 91, 0.22);
  --font-heading: 'Sora', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  --panel-w: 340px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 500 13px/1.45 var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 72% 42%, rgba(18, 74, 84, 0.45), transparent 65%),
    radial-gradient(900px 600px at 10% 110%, rgba(34, 160, 112, 0.12), transparent 60%),
    #02080b;
  overflow: hidden;
}

#stars { position: absolute; inset: 0; width: 100%; height: 100%; }
#map { position: absolute; inset: 0; }
/* atmosphere: a ring of soft blue light just outside the globe's limb (sized and placed by globe.js) */
#halo {
  position: absolute; left: 0; top: 0; pointer-events: none; border-radius: 50%; will-change: transform, opacity;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 78%, rgba(104, 178, 255, 0.5) 80.4%, rgba(70, 140, 235, 0.24) 84%, rgba(50, 110, 210, 0.1) 91%, rgba(30, 80, 180, 0) 100%);
}
#map canvas { image-rendering: auto; }

/* ---- side panel ---- */
#panel {
  position: absolute;
  top: 16px; left: 16px; bottom: 16px;
  width: var(--panel-w);
  padding: 20px 18px 14px;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(0, 89, 90, 0.78), rgba(0, 49, 47, 0.9)),
    url('assets/pattern-tile.svg') center / 260px repeat;
  background-blend-mode: normal, soft-light;
  backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: 0 20px 60px rgba(0, 20, 20, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(192, 216, 91, 0.35) transparent;
}
#panel::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(180deg, var(--yellow-green), var(--meadow) 60%, var(--cyprus));
  border-radius: 14px 0 0 14px;
}

/* staggered reveal once the app is ready */
.reveal { opacity: 0; transform: translateY(10px); }
#panel.ready .reveal { animation: rise 520ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
#panel.ready .reveal:nth-child(1) { animation-delay: 40ms; }
#panel.ready .reveal:nth-child(2) { animation-delay: 110ms; }
#panel.ready .reveal:nth-child(3) { animation-delay: 180ms; }
#panel.ready .reveal:nth-child(4) { animation-delay: 250ms; }
@keyframes rise { to { opacity: 1; transform: none; } }

header .logo { width: 140px; display: block; margin-bottom: 10px; }
.eyebrow {
  margin: 0 0 2px;
  font: 600 11px/1 var(--font-heading);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--yellow-green);
}
h1 { margin: 0 0 6px; font: 600 20px/1.15 var(--font-heading); color: #fff; letter-spacing: -0.01em; }
h2 { margin: 0 0 8px; font: 600 12px/1 var(--font-heading); letter-spacing: 0.1em; text-transform: uppercase; color: var(--yellow-green); }
.lede { margin: 0; color: var(--muted); font-size: 12.5px; }

section, footer { margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); }

/* segmented buttons */
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  flex: 1 0 auto; min-width: 44px;
  padding: 6px 8px;
  font: 600 12px/1 var(--font-heading);
  color: var(--powder);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(181, 225, 230, 0.16);
  border-radius: 7px;
  cursor: pointer;
  transition: background 120ms, color 120ms, transform 120ms;
}
.seg button:hover { background: rgba(34, 160, 112, 0.35); }
.seg button.on { background: var(--yellow-green); color: var(--cyprus-ink); border-color: var(--yellow-green); transform: translateY(-1px); }
.seg.small { margin-top: 6px; }
.seg.small button { padding: 5px 6px; font-size: 11px; }

/* rows */
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row.toggle { cursor: pointer; font-weight: 600; color: #fff; }
.row.toggle input { accent-color: var(--yellow-green); margin: 0; }
.hidden { display: none !important; }

.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: 0 0 12px; }
.sw-mosaic { background: linear-gradient(135deg, #7a6a4a, #3d5c39); }
.sw-field { background: linear-gradient(90deg, var(--cyprus), var(--meadow), var(--yellow-green)); }
.sw-boundary { background: var(--orange); }
.sw-outlines { border: 2px solid var(--orange); background: rgba(255, 127, 65, 0.15); }
.sw-pmtiles { background: linear-gradient(90deg, #ffffd9, #41b6c4, #081d58); }
.sw-lulc { background: linear-gradient(90deg, #1a5bab, #358221, #ffdb5c, #c6ad8d); }
.sw-alpha { border: 2px solid var(--powder-blue, #b5e1e6); background: rgba(181, 225, 230, 0.15); }

.legend { margin-top: 10px; }
.pm-legend { display: flex; margin-top: 6px; }
.pm-legend:empty { display: none; }
.pm-stop { flex: 1; padding: 8px 0 0; border-top: 8px solid var(--c); font-size: 10px; color: var(--muted); text-align: left; }
.ramp { height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgba(0, 71, 71, 0.55), var(--meadow), var(--yellow-green)); }
.ramp-labels { display: flex; justify-content: space-between; margin-top: 3px; font-size: 10.5px; color: var(--muted); }

/* change examples */
#changes summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; border-radius: 6px; }
#changes summary::-webkit-details-marker { display: none; }
#changes summary::after { content: '+'; font: 600 16px/1 var(--font-heading); color: var(--yellow-green); }
#changes[open] summary::after { content: '−'; }
#changes summary:focus-visible, .chg:focus-visible, #compare button:focus-visible { outline: 2px solid var(--yellow-green); outline-offset: 2px; }
#changes h2 { margin: 0; }
#change-list { max-height: 300px; overflow-y: auto; margin-top: 8px; scrollbar-width: thin; scrollbar-color: rgba(192, 216, 91, 0.35) transparent; }
#change-list h3 { margin: 8px 0 4px; font: 600 10.5px/1 var(--font-heading); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.chg {
  display: grid; grid-template-columns: 1fr auto; column-gap: 8px; width: 100%;
  margin: 0 0 4px; padding: 7px 9px; text-align: left;
  font: inherit; color: var(--text);
  background: rgba(0, 0, 0, 0.18); border: 1px solid rgba(181, 225, 230, 0.16); border-radius: 7px;
  cursor: pointer; transition: background 120ms, border-color 120ms;
}
.chg:hover { background: rgba(34, 160, 112, 0.35); }
.chg[aria-pressed='true'] { border-color: var(--yellow-green); background: rgba(192, 216, 91, 0.16); }
.chg-place { font-weight: 600; color: #fff; }
.chg-country { margin-left: 6px; font: 500 10px/1 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chg-ha { font: 600 11px/1.45 var(--font-heading); font-variant-numeric: tabular-nums; }
.chg-ha.gain { color: var(--yellow-green); }
.chg-ha.loss { color: var(--orange); }
.chg-story { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }

/* before / after pill over the map, shown while an example is selected */
#compare {
  position: absolute; left: calc(50% + (var(--panel-w) + 32px) / 2); bottom: 52px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  padding: 6px 8px 6px 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font: 600 12px/1.2 var(--font-heading);
}
#compare-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
#compare .seg.small { margin: 0; flex-wrap: nowrap; }
#compare-close { padding: 4px 8px; font: 600 16px/1 var(--font-heading); color: var(--powder); background: none; border: 0; cursor: pointer; }

/* status */
.status .row { justify-content: space-between; color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.status b { font: 600 12px/1 var(--font-heading); color: #fff; font-variant-numeric: tabular-nums; }
#st-inflight.busy { color: var(--orange); }
#st-inflight.busy::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 5px; border-radius: 50%; background: var(--orange); animation: pulse 900ms ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.2; } }
.fine { margin: 10px 0 0; font-size: 10.5px; color: var(--muted); }
.fine:empty { display: none; }
.fine a { color: var(--powder); text-decoration: none; border-bottom: 1px solid rgba(181, 225, 230, 0.3); }

/* click popup on hexagons and fields */
.ftw-popup .maplibregl-popup-content { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); backdrop-filter: blur(8px); color: var(--text); font: 500 12px/1.45 var(--font-body); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.ftw-popup .maplibregl-popup-content b { font: 600 13px/1.3 var(--font-heading); color: #fff; }
.ftw-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface-2); }
.ftw-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface-2); }
.ftw-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface-2); }
.ftw-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface-2); }

/* landing hint under the globe, gone with the first touch */
#globe-hint {
  position: absolute; left: calc(50% + (var(--panel-w) + 32px) / 2); bottom: 56px; transform: translateX(-50%);
  margin: 0; font: 600 11px/1 var(--font-heading); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); text-shadow: 0 1px 6px rgba(0, 10, 12, 0.9); pointer-events: none;
  animation: hint-in 900ms 1400ms both;
}
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (max-width: 720px) { #globe-hint { display: none; } }

/* hint */
#hint {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  font: 600 12px/1 var(--font-heading); letter-spacing: 0.04em;
  color: var(--cyprus-ink); background: var(--yellow-green);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* MapLibre chrome */
.maplibregl-ctrl-group { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; box-shadow: none; backdrop-filter: blur(8px); }
.maplibregl-ctrl-group:not(:empty) { box-shadow: none; }
.maplibregl-ctrl-group button { width: 32px; height: 32px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line); }
.maplibregl-ctrl-group button:hover, .maplibregl-ctrl-group button:focus-visible { background-color: rgba(34, 160, 112, 0.55); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) sepia(1) saturate(2.4) hue-rotate(35deg) brightness(1.05); }
.maplibregl-ctrl-top-right { top: 14px; right: 14px; }
.maplibregl-ctrl-top-right .maplibregl-ctrl { margin: 0 0 8px; }
.ctrl-globe::before {
  content: ''; display: block; width: 18px; height: 18px; margin: auto;
  background: var(--yellow-green);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3Cpath d='M3 12h18M5 7.5h14M5 16.5h14'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3Cpath d='M3 12h18M5 7.5h14M5 16.5h14'/%3E%3C/svg%3E") center / contain no-repeat;
}
.maplibregl-ctrl-attrib { background: transparent !important; font-size: 10px; }
.maplibregl-ctrl-attrib-inner, .maplibregl-ctrl-attrib a { color: var(--muted); text-shadow: 0 1px 2px rgba(0, 20, 20, 0.8); }
.maplibregl-ctrl-attrib.maplibregl-compact { background: var(--surface-2) !important; border: 1px solid var(--line); border-radius: 12px; }
.maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-ctrl-bottom-right { right: 8px; bottom: 4px; }
.maplibregl-ctrl-scale { background: rgba(0, 49, 47, 0.75); border-color: var(--yellow-green); color: var(--porcelain); font: 600 10px/1.6 var(--font-heading); border-radius: 0 0 4px 4px; }

@media (max-width: 720px) {
  :root { --panel-w: auto; }
  #panel { top: auto; left: 8px; right: 8px; bottom: 8px; max-height: 52vh; padding: 14px 14px 10px; }
  header .logo { width: 120px; }
  .lede { display: none; }
  .maplibregl-ctrl-top-right { top: 10px; right: 10px; }
  /* the panel covers the bottom of the map on phones: scale and attribution go to the top-left */
  .maplibregl-ctrl-bottom-right { top: 8px; left: 8px; right: auto; bottom: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-scale { order: 2; }
  #change-list { max-height: 28vh; }
  #compare { left: 8px; right: auto; top: 10px; bottom: auto; transform: none; max-width: calc(100% - 64px); }
}
