/* coffeemap.css — /coffeemap.html, the interactive world coffee map.
   Layered ON TOP of css/landing.css: every value here is either one of that
   file's tokens or a coffeemap-local token declared in the :root block below.
   Governed by landing/DESIGN_SYSTEM.md — dark theme only, nothing raw outside
   :root (exceptions: @media bodies, structural px, SVG data-URI internals). */

:root {
  /* ---- layout ------------------------------------------------ */
  /* The instrument gets a wider container than the 1180 prose column — a world
     map wants width — and the prose below re-narrows itself to 1180. */
  --cm-shell: 1520px;
  --cm-prose-w: 1180px;
  --cm-map-h: clamp(380px, 56vh, 640px);
  --cm-rail-w: 352px;
  --cm-deck-h: 0px;                 /* > 0 only on mobile (fixed control deck) */
  --cm-spark-h: 40px;
  --cm-track-h: 6px;

  /* ---- canvas surfaces (read by JS through a colour probe) ---- */
  --cm-ocean-hi: #0c141e;           /* sphere fill, top */
  --cm-ocean-lo: #070c13;           /* sphere fill, bottom */
  --cm-sphere-edge: #2b3a4b;        /* projection outline */
  --cm-land: #101822;               /* non-producing land */
  --cm-land-grow: #1e2b3a;          /* producing countries, lifted a step */
  --cm-coast: #26333f;              /* coastline / border hairline */
  --cm-grat: rgba(147, 161, 175, 0.09);      /* graticule */
  --cm-grat-hi: rgba(147, 161, 175, 0.16);   /* equator */
  --cm-belt: rgba(53, 224, 200, 0.045);      /* the bean belt fill */
  --cm-belt-line: rgba(53, 224, 200, 0.22);  /* tropic lines */
  --cm-halo: #05080d;               /* dark ring punched under every mark */

  /* ---- crop-stage ramp: one cycle, violet → sky → peak turquoise → gray */
  --cm-flowering: var(--violet);
  --cm-cherry-development: var(--grad-mid);
  --cm-harvest: var(--accent-hi);
  --cm-drying-milling: var(--accent);
  --cm-export: var(--tab-idle);
  --cm-dormant: var(--text-dim);

  /* ---- green-freshness ramp: 5 sequential steps + 1 categorical ----
     `arriving` is the brightest step on the ramp because it is the best state
     a coffee can be in — this year's crop actively landing. */
  --cm-arriving: var(--accent-hi);
  --cm-new-crop: var(--accent);
  --cm-current: var(--grad-mid);
  --cm-fading: var(--tab-idle);
  --cm-past-crop: var(--text-dim);
  --cm-not-landed: var(--violet);

  /* ---- pipeline legs (the annual harvest → cup bar) -----------
     Ordered as the coffee moves: on the farm (bright), in transit (violet
     counterpoint), then the two stages that only happen after you buy it. */
  --cm-leg-harvest: var(--accent-hi);
  --cm-leg-mill: var(--accent);
  --cm-leg-toPort: var(--tab-idle);
  --cm-leg-transit: var(--violet);
  --cm-leg-landing: var(--grad-mid);
  --cm-leg-green: var(--accent-a55);
  --cm-leg-roast: var(--neg);
  --cm-leg-rest: var(--accent-bright);
  --cm-leg-available: var(--accent-a25);

  /* ---- fly crop -----------------------------------------------
     Hue is fully committed to stage/band, so the second crop is carried by
     PATTERN instead: a diagonal hatch on the map mark and on the annual bar.
     That keeps "which crop" and "which stage" independently readable. */
  --cm-fly-hatch: var(--bg-a65);
  --cm-fly-hatch-w: 3px;
}

/* ============================== page shell ============================== */

.cm-main {
  max-width: var(--cm-shell);
  padding-bottom: var(--space-46);
  overflow-x: clip; overflow-y: visible;
}
.cm-narrow { max-width: var(--cm-prose-w); margin-inline: auto; }

.cm-back {
  display: inline-flex; align-items: center; gap: var(--space-8);
  margin: var(--space-24) 0 var(--space-16);
  font-size: 14px; color: var(--text-sub);
  transition: color var(--dur) var(--ease-out);
}
.cm-back:hover { color: var(--accent); }

.cm-intro { max-width: 62ch; margin-bottom: var(--space-24); }
.cm-intro h1 {
  font-size: var(--fs-display); font-weight: 750;
  margin: var(--space-12) 0 var(--space-14);
}
.cm-intro__lead {
  margin: 0; font-size: var(--fs-lead); color: var(--text-sub);
  line-height: 1.55; max-width: 56ch;
}

/* mono label voice, shared by every machine-label in the instrument */
.cm-lab {
  font: 600 10px/1 var(--mono); letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-dim);
  white-space: nowrap;
}
.cm-lab--accent { color: var(--accent); }

/* ============================== instrument ============================== */

.cm-instrument {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-14);
  display: flex; flex-direction: column; gap: var(--space-12);
}

/* ---- head row: identity chip + search + market ---- */
.cm-head {
  display: flex; align-items: center; gap: var(--space-12);
  flex-wrap: wrap;
}
.cm-head__chip {
  display: inline-flex; align-items: center; gap: var(--space-8);
  font: 600 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-a08);
  border: 1px solid var(--line-soft); border-radius: var(--r-8);
  padding: var(--space-8) var(--space-11);
  white-space: nowrap;
}
.cm-head__chip b { color: var(--accent-bright); font-weight: 600; }
.cm-head__spacer { flex: 1 1 var(--space-8); }

/* ---- search ---- */
.cm-search { position: relative; flex: 0 1 340px; min-width: 220px; }
.cm-search__icon {
  position: absolute; left: var(--space-11); top: 50%;
  transform: translateY(-50%); width: var(--icon-xs); height: var(--icon-xs);
  color: var(--text-dim); pointer-events: none;
}
.cm-search input {
  width: 100%; min-height: 40px;
  padding: var(--space-9) var(--space-12) var(--space-9) var(--space-34);
  background: var(--scrim-input); border: 1px solid var(--line);
  border-radius: var(--r-10); color: var(--text);
  font: 400 14.5px var(--font-sans);
  transition: border-color var(--dur) var(--ease-out);
}
.cm-search input::placeholder { color: var(--text-dim); }
.cm-search input:focus { outline: none; border-color: var(--accent); }
.cm-search input::-webkit-search-cancel-button { display: none; }

.cm-results {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + var(--space-6));
  margin: 0; padding: var(--space-4); list-style: none;
  background: var(--panel-solid); border: 1px solid var(--accent-a25);
  border-radius: var(--r-12); box-shadow: var(--shadow-dropdown);
  max-height: 320px; overflow-y: auto;
}
.cm-results[hidden] { display: none; }
.cm-results li {
  display: flex; align-items: baseline; gap: var(--space-8);
  padding: var(--space-8) var(--space-10); border-radius: var(--r-8);
  cursor: pointer; line-height: 1.35;
}
.cm-results li[aria-selected="true"] { background: var(--accent-a10); }
.cm-results__t { font-size: 14px; color: var(--text); }
.cm-results__s { font-size: 12px; color: var(--text-dim); margin-left: auto; text-align: right; }
.cm-results__k {
  font: 600 9px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--line-soft); border-radius: var(--r-4);
  padding: var(--space-3) var(--space-5);
}
.cm-results__empty { padding: var(--space-10); font-size: 13.5px; color: var(--text-dim); }

/* ---- market select ---- */
.cm-market { display: inline-flex; align-items: center; gap: var(--space-8); }
.cm-market select {
  min-height: 40px; padding: var(--space-8) var(--space-30) var(--space-8) var(--space-11);
  background: var(--scrim-input); border: 1px solid var(--line);
  border-radius: var(--r-10); color: var(--text);
  font: 600 13px var(--mono); letter-spacing: 0.02em;
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a1af' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-9) center;
  background-size: var(--icon-xs);
  transition: border-color var(--dur) var(--ease-out);
}
.cm-market select:focus { outline: none; border-color: var(--accent); }
.cm-market[hidden] { display: none; }

/* ============================== stage ============================== */

.cm-stage {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--cm-rail-w);
  gap: var(--space-12); align-items: stretch;
}
.cm-mapcol { display: flex; flex-direction: column; gap: var(--space-10); min-width: 0; }

.cm-mapwrap {
  position: relative; height: var(--cm-map-h);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--rig-bg); overflow: hidden;
  touch-action: none;
}
.cm-mapwrap canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.cm-mapwrap canvas.is-drag { cursor: grabbing; }
.cm-mapwrap canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* zoom cluster */
.cm-zoom {
  position: absolute; right: var(--space-10); top: var(--space-10);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.cm-zoom button {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--bg-a82); border: 1px solid var(--line);
  border-radius: var(--r-8); color: var(--text-sub); cursor: pointer;
  -webkit-backdrop-filter: blur(var(--blur-md)); backdrop-filter: blur(var(--blur-md));
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.cm-zoom button:hover { color: var(--accent); border-color: var(--accent-a35); }
.cm-zoom svg { width: var(--icon-xs); height: var(--icon-xs); }

/* hover tooltip */
.cm-tip {
  position: absolute; z-index: 20; pointer-events: none;
  padding: var(--space-7) var(--space-10);
  background: var(--bg-a96); border: 1px solid var(--accent-a25);
  border-radius: var(--r-8); box-shadow: var(--shadow-tip);
  -webkit-backdrop-filter: blur(var(--blur-md)); backdrop-filter: blur(var(--blur-md));
  transform: translate(-50%, -100%); white-space: nowrap;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
}
.cm-tip.is-on { opacity: 1; }
.cm-tip__n { font: 600 13px var(--font-sans); color: var(--text-bright); }
.cm-tip__m {
  display: block; margin-top: var(--space-3);
  font: 500 10.5px var(--mono); letter-spacing: 0.06em; color: var(--text-sub);
}
.cm-tip__dot {
  display: inline-block; width: 7px; height: 7px; border-radius: var(--r-round);
  margin-right: var(--space-6); vertical-align: middle;
}

/* scale bar / attribution strip inside the map frame */
.cm-mapnote {
  position: absolute; left: var(--space-11); bottom: var(--space-9);
  font: 500 9.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim); pointer-events: none;
}

/* ============================== legend ============================== */

.cm-legend {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-6) var(--space-16);
  padding: var(--space-10) var(--space-12);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.cm-legend__group { display: flex; align-items: center; gap: var(--space-10); flex-wrap: wrap; }
.cm-legend__group + .cm-legend__group {
  padding-left: var(--space-16); border-left: 1px solid var(--line);
}
.cm-key {
  display: inline-flex; align-items: center; gap: var(--space-6);
  font: 500 11.5px var(--font-sans); color: var(--text-sub);
  background: none; border: 0; padding: var(--space-2) 0; cursor: pointer;
  transition: color var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.cm-key:hover, .cm-key.is-on { color: var(--text-bright); }
.cm-legend.is-filtered .cm-key:not(.is-on) { opacity: 0.42; }
.cm-key__sw {
  width: 11px; height: 11px; border-radius: var(--r-round);
  box-shadow: var(--ring-inset-accent);
}
.cm-key__n {
  font: 500 10px var(--mono); letter-spacing: 0.06em; color: var(--text-dim);
}
.cm-key__hint { font: 500 11px var(--font-sans); color: var(--text-dim); }
.cm-key svg { width: var(--icon-xs); height: var(--icon-xs); color: var(--text-sub); }

/* ============================== control deck ============================== */

.cm-deck {
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-16); align-items: center;
  padding: var(--space-12) var(--space-14);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* mode toggle — a segmented control, deliberately large */
.cm-modes {
  display: inline-flex; gap: var(--space-4); padding: var(--space-4);
  background: var(--bg-a82); border: 1px solid var(--line);
  border-radius: var(--r-12);
}
.cm-mode {
  display: flex; align-items: center; gap: var(--space-9);
  padding: var(--space-8) var(--space-14);
  min-height: 44px; border: 0; border-radius: var(--r-10);
  background: transparent; color: var(--tab-idle); cursor: pointer; text-align: left;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.cm-mode:hover { background: var(--accent-a08); color: var(--text-bright); }
.cm-mode[aria-checked="true"] {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-tab-active);
}
.cm-mode svg { width: var(--icon-md); height: var(--icon-md); flex: none; }
.cm-mode__txt { display: flex; flex-direction: column; gap: var(--space-2); }
.cm-mode__t { font: 600 13.5px var(--font-sans); letter-spacing: -0.01em; }
.cm-mode__s { font: 500 10px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.72; }

/* ---- the date scrubber ---- */
.cm-scrub { min-width: 0; }
.cm-scrub__head {
  display: flex; align-items: baseline; gap: var(--space-10);
  margin-bottom: var(--space-6);
}
.cm-scrub__date {
  font: 700 17px var(--mono); font-variant-numeric: tabular-nums;
  color: var(--text-bright); letter-spacing: 0.02em;
}
.cm-scrub__sub {
  font: 500 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim);
}
.cm-today {
  margin-left: auto; min-height: 30px;
  padding: var(--space-5) var(--space-12);
  font: 600 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); background: transparent;
  border: 1px solid var(--accent-a35); border-radius: var(--r-pill);
  cursor: pointer; transition: background var(--dur) var(--ease-out);
}
.cm-today:hover { background: var(--accent-a12); }
.cm-today[disabled] { color: var(--text-dim); border-color: var(--line); cursor: default; }

.cm-scrub__body { position: relative; padding-bottom: var(--space-14); touch-action: none; }
.cm-scrub__spark { display: block; width: 100%; height: var(--cm-spark-h); }
.cm-scrub__track {
  position: relative; height: var(--cm-track-h); border-radius: var(--r-pill);
  background: var(--track); cursor: pointer;
}
.cm-scrub__track:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.cm-scrub__fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  border-radius: var(--r-pill); background: var(--accent-a35);
}
.cm-scrub__play {
  position: absolute; left: 0; top: 0; width: 2px;
  height: calc(var(--cm-spark-h) + var(--cm-track-h));
  background: var(--accent); border-radius: var(--r-pill);
  box-shadow: var(--shadow-tick-a); pointer-events: none;
  will-change: transform;
}
.cm-scrub__play::after {
  content: ""; position: absolute; left: 50%; bottom: calc(var(--cm-track-h) / 2 - 7px);
  width: 14px; height: 14px; margin-left: -7px;
  border-radius: var(--r-round); background: var(--accent);
  box-shadow: var(--shadow-thumb-a), 0 0 0 2px var(--thumb-ring-a);
}
.cm-scrub__ticks {
  position: relative; height: var(--space-12); margin-top: var(--space-8);
}
.cm-scrub__tick {
  position: absolute; top: 0; transform: translateX(-50%);
  font: 500 9.5px var(--mono); letter-spacing: 0.08em;
  color: var(--text-dim); pointer-events: none;
}
.cm-scrub__tick.is-q { color: var(--text-sub); }

/* ============================== detail rail ============================== */

.cm-rail {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.cm-rail__scroll {
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-14); display: flex; flex-direction: column; gap: var(--space-14);
}
.cm-rail__close { display: none; }

/* --- empty state / "right now" list --- */
.cm-now__h {
  display: flex; align-items: baseline; gap: var(--space-8);
  margin-bottom: var(--space-10);
}
.cm-now__h h2 { font-size: 15px; font-weight: 600; color: var(--text-bright); }
.cm-now__list { list-style: none; margin: 0; padding: 0; }
.cm-now__list li { border-top: 1px solid var(--line-a70); }
.cm-now__list li:first-child { border-top: 0; }
.cm-now__row {
  display: flex; align-items: center; gap: var(--space-9); width: 100%;
  padding: var(--space-9) var(--space-4); min-height: 44px;
  background: none; border: 0; cursor: pointer; text-align: left;
  border-radius: var(--r-6);
  transition: background var(--dur) var(--ease-out);
}
.cm-now__row:hover { background: var(--accent-a08); }
.cm-now__dot { width: 9px; height: 9px; border-radius: var(--r-round); flex: none; }
.cm-now__n { font-size: 13.5px; color: var(--text); min-width: 0; }
.cm-now__n small { display: block; font-size: 11.5px; color: var(--text-dim); }
.cm-now__v {
  margin-left: auto; font: 600 12px var(--mono); font-variant-numeric: tabular-nums;
  color: var(--accent-bright); white-space: nowrap;
}
.cm-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin: 0; }

/* --- selected region --- */
.cm-det__top { display: flex; align-items: flex-start; gap: var(--space-10); }
.cm-det__name { min-width: 0; }
.cm-det__name h2 {
  font-size: 20px; font-weight: 700; color: var(--text-bright);
  letter-spacing: -0.015em; line-height: 1.15;
}
.cm-det__sub {
  display: block; margin-top: var(--space-4);
  font: 500 11px var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-sub);
}
.cm-det__x {
  margin-left: auto; flex: none; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: var(--r-round);
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim); cursor: pointer;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.cm-det__x:hover { color: var(--text); border-color: var(--line-2); }
.cm-det__x svg { width: var(--icon-xs); height: var(--icon-xs); }

.cm-status {
  display: flex; align-items: center; gap: var(--space-10);
  padding: var(--space-10) var(--space-12);
  border: 1px solid var(--line); border-radius: var(--r-12);
  background: var(--panel);
}
.cm-status__dot {
  width: 12px; height: 12px; border-radius: var(--r-round); flex: none;
}
.cm-status__t { font-size: 14px; color: var(--text-bright); font-weight: 600; }
.cm-status__s { display: block; font: 500 11px var(--mono); letter-spacing: 0.06em; color: var(--text-sub); margin-top: var(--space-3); }
.cm-status__v {
  margin-left: auto; text-align: right;
  font: 700 18px var(--mono); font-variant-numeric: tabular-nums; color: var(--text-bright);
}
.cm-status__v small {
  display: block; white-space: nowrap;
  font: 500 9.5px var(--mono); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim);
}

/* metric grid */
.cm-facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8) var(--space-12); }
.cm-fact { min-width: 0; }
.cm-fact__v {
  font: 600 14px var(--mono); font-variant-numeric: tabular-nums;
  color: var(--text); display: block; margin-top: var(--space-3);
  overflow-wrap: anywhere;
}
.cm-fact--wide { grid-column: 1 / -1; }

/* altitude bar */
.cm-alt { position: relative; height: 6px; border-radius: var(--r-pill); background: var(--track); margin-top: var(--space-6); }
.cm-alt__band { position: absolute; top: 0; bottom: 0; border-radius: var(--r-pill); background: var(--accent-a55); }
.cm-alt__scale { display: flex; justify-content: space-between; margin-top: var(--space-4); font: 500 9.5px var(--mono); color: var(--text-dim); }

/* tag rows */
.cm-tags { display: flex; flex-wrap: wrap; gap: var(--space-5); margin-top: var(--space-6); }
.cm-tag {
  font: 500 11.5px var(--font-sans); color: var(--text-sub);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-6); padding: var(--space-3) var(--space-8);
}
.cm-tag--accent { color: var(--accent-bright); border-color: var(--line-soft); background: var(--accent-a08); }
.cm-tag--violet { color: var(--violet); border-color: var(--violet-a30); background: var(--violet-soft); }

/* year strip */
/* Freshness ribbons — one per crop, sharing the annual bar's label gutter so
   the two stacks line up column for column. */
.cm-year { position: relative; }
.cm-year canvas { display: block; width: 100%; height: 26px; border-radius: var(--r-6); cursor: pointer; }
/* the fly crop's ribbon carries the same hatch as its mark and its bar row */
.cm-year.is-fly::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: var(--r-6);
  background-image: repeating-linear-gradient(45deg,
    transparent 0 var(--cm-fly-hatch-w),
    var(--cm-fly-hatch) var(--cm-fly-hatch-w) calc(var(--cm-fly-hatch-w) * 2));
  opacity: 0.5;
}

/* pipeline timeline (cup mode) */
/* ---- the annual harvest → cup bar ----------------------------------
   One row per crop on a shared Jan–Dec axis, so the phases line up with the
   freshness ribbon, the month ticks and the date scrubber. */
.cm-pipe { display: flex; flex-direction: column; gap: var(--space-6); }

/* ---- per-crop section -------------------------------------------------
   Main and fly are separate coffees, so each gets its own block. Everything
   inside runs the full panel width on one shared month axis. */
.cm-cropsec {
  display: flex; flex-direction: column; gap: var(--space-6);
  padding: var(--space-11) 0 var(--space-8);
  border-top: 1px solid var(--line);
}
.cm-cropsec__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-8); }
.cm-cropsec__name {
  font: 600 11px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text);
}
.cm-cropsec__meta {
  font: 500 10px var(--mono); letter-spacing: 0.04em; color: var(--text-sub);
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* the fly crop's whole section is marked, not just its bars */
.cm-cropsec.is-fly .cm-cropsec__name { color: var(--text-sub); }
.cm-cropsec .cm-lab { margin-top: var(--space-3); }

.cm-pipe__track {
  position: relative; height: 22px; width: 100%;
  border-radius: var(--r-6); overflow: hidden; background: var(--track);
}
/* Picking is the base band; the post-harvest chain is inset above it. They
   overlap on purpose — milling starts at the peak of the pick, while the tail
   is still coming in — so they are drawn on separate bands rather than end to
   end, which would have implied the farm goes quiet the day milling begins. */
.cm-pipe__seg { position: absolute; top: 0; bottom: 0; min-width: 1px; }
.cm-pipe__seg--pick { top: 0; bottom: 0; opacity: 0.45; border-radius: var(--r-2); }
.cm-pipe__seg--chain { top: 5px; bottom: 0; }
/* Green store is WAITING, not moving. Drawn as a thin rail rather than a full
   leg so it cannot be mistaken for the picking band it sits near in colour. */
.cm-pipe__seg--wait {
  top: auto; bottom: 0; height: 5px; border-radius: var(--r-pill); opacity: 0.85;
}
/* Fly crop: pattern, not another hue — hue is fully committed to stage. */
.cm-pipe__track.is-fly .cm-pipe__seg {
  background-image: repeating-linear-gradient(45deg,
    transparent 0 var(--cm-fly-hatch-w),
    var(--cm-fly-hatch) var(--cm-fly-hatch-w) calc(var(--cm-fly-hatch-w) * 2));
}
.cm-pipe__zone { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; }
.cm-pipe__zoneband {
  position: absolute; top: 0; bottom: 0; min-width: 2px;
  background: var(--cm-arriving); opacity: 0.75; border-radius: var(--r-pill);
}
.cm-pipe__cupmark {
  position: absolute; top: 0; bottom: 7px; min-width: 3px;
  background: var(--cm-leg-rest); opacity: 0.9;
  border-left: 2px solid var(--cm-leg-roast); pointer-events: none; z-index: 1;
}
/* dynamic legs (green store, roast, rest) live in their own layer so they can
   be rebuilt every scrub tick without touching the static chain */
.cm-pipe__dyn { position: absolute; inset: 0; pointer-events: none; }
.cm-pipe__dyn .cm-pipe__seg { pointer-events: auto; }

/* Month letters sit at their TRUE day-of-year position, not on a repeat(12,1fr)
   grid: an even twelfth is 30.42 days, so an evenly-divided axis drifts up to
   two days against bars that are placed by real date. On a chart whose whole
   claim is "when", that drift is the one error a reader can actually measure. */
.cm-pipe__months {
  position: relative; height: var(--space-11); margin-top: var(--space-3);
  font: 500 9px var(--mono); color: var(--text-dim); letter-spacing: 0.06em;
}
.cm-pipe__mo { position: absolute; top: 0; transform: translateX(-50%); }
.cm-pipe__months--full { margin-left: 0; }
.cm-pipe__mo { text-align: left; }
.cm-pipe__cup { margin: var(--space-2) 0 0; font: 500 10.5px var(--mono); color: var(--text-sub); letter-spacing: 0.01em; }
.cm-pipe__now {
  position: absolute; top: -3px; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--text-bright); box-shadow: 0 0 0 1px var(--bg), 0 0 10px var(--bg);
  border-radius: var(--r-pill); pointer-events: none; z-index: 3;
}
/* one TODAY flag for the stack, not one per crop row */
.cm-cropsec:first-of-type .cm-pipe__now::after {
  content: "TODAY"; position: absolute; left: 0; bottom: calc(100% + 1px);
  transform: translateX(-50%);
  font: 600 8.5px var(--mono); letter-spacing: 0.14em; color: var(--text-bright);
}
@media (max-width: 560px) {


}
.cm-pipe__legend { display: flex; flex-wrap: wrap; gap: var(--space-5) var(--space-11); margin-top: var(--space-2); }
.cm-pipe__k { display: inline-flex; align-items: center; gap: var(--space-5); font: 500 10px var(--mono); letter-spacing: 0.04em; color: var(--text-sub); }
.cm-pipe__k i { width: 8px; height: 8px; border-radius: var(--r-2); display: block; }

/* estimated-value tag — quiet, but a careful reader sees it */
.cm-est {
  display: inline-block; margin-left: var(--space-5); vertical-align: 1px;
  font: 600 8.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--line-2);
  border-radius: var(--r-4); padding: 0 var(--space-3); cursor: help;
}
.cm-cite__est { margin: var(--space-8) 0 0; font-size: 11.5px; line-height: 1.45; color: var(--text-dim); }
.cm-pipe__route { margin: 0; font: 500 10.5px var(--mono); color: var(--text-dim); letter-spacing: 0.02em; }

/* the honest note */
.cm-note {
  margin: 0; padding: var(--space-9) var(--space-12);
  border-left: 2px solid var(--accent-a45); border-radius: 0 var(--r-6) var(--r-6) 0;
  background: var(--accent-a06);
  font-size: 13.5px; line-height: 1.5; color: var(--text-sub);
}

/* section head inside the rail */
.cm-sec { display: flex; flex-direction: column; gap: var(--space-4); }
.cm-sec + .cm-sec { padding-top: var(--space-12); border-top: 1px solid var(--line-a70); }

/* citations */
.cm-cite { border-top: 1px solid var(--line-a70); padding-top: var(--space-10); }
.cm-cite > summary {
  list-style: none; cursor: pointer;
  font: 600 10px var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim); display: flex; align-items: center; gap: var(--space-8);
  min-height: 24px;
}
.cm-cite > summary::-webkit-details-marker { display: none; }
.cm-cite > summary::after { content: "+"; margin-left: auto; color: var(--accent); font-size: 13px; }
.cm-cite[open] > summary::after { content: "–"; }
.cm-cite > summary:hover { color: var(--text-sub); }
.cm-cite ol { list-style: none; margin: var(--space-8) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-8); }
.cm-cite li { font-size: 12px; line-height: 1.45; color: var(--text-dim); }
.cm-cite b { display: block; font-weight: 600; color: var(--text-sub); font-size: 12.5px; }
.cm-cite a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cm-cite__kind {
  font: 600 8.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--line-soft); border-radius: var(--r-4);
  padding: var(--space-1) var(--space-4); margin-left: var(--space-6);
}

/* ============================== prose below ============================== */

.cm-prose { margin-top: var(--space-42); display: grid; gap: var(--space-24); }
.cm-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-24); }
.cm-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--space-20) var(--space-22);
}
.cm-card h3 { font-size: 15.5px; font-weight: 600; color: var(--text-bright); margin-bottom: var(--space-8); }
.cm-card p { margin: 0 0 var(--space-10); font-size: 14px; line-height: 1.6; color: var(--text-sub); }
.cm-card p:last-child { margin-bottom: 0; }
.cm-prose h2 { font-size: var(--fs-h2); margin-bottom: var(--space-10); }
.cm-prose > section > p { font-size: 15px; line-height: 1.6; color: var(--text-sub); max-width: 68ch; margin: 0 0 var(--space-12); }

/* origins index */
/* multi-column, not grid: 46 origins with wildly different region counts leave
   huge holes in a row-aligned grid */
.cm-index__grid { columns: 210px; column-gap: var(--space-24); }
.cm-index__o {
  break-inside: avoid; display: inline-block; width: 100%;
  margin-bottom: var(--space-18);
}
.cm-index__o h3 {
  font: 600 12px var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: var(--space-6);
  padding-bottom: var(--space-5); border-bottom: 1px solid var(--line);
}
.cm-index__o ul { list-style: none; margin: 0; padding: 0; }
.cm-index__o li { margin: 0; }
.cm-index__o a {
  display: block; padding: var(--space-3) 0; font-size: 13.5px; color: var(--text-sub);
  transition: color var(--dur) var(--ease-out);
}
.cm-index__o a:hover { color: var(--accent); }
.cm-index__o em {
  font-style: normal; font: 500 10.5px var(--mono); color: var(--text-dim);
  margin-left: var(--space-6);
}

/* source register */
.cm-srcs { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-10); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cm-srcs li { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.cm-srcs b { display: block; color: var(--text-sub); font-weight: 600; font-size: 13.5px; }
.cm-srcs a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* CTA */
.cm-cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-16);
  margin-top: var(--space-34); padding: var(--space-26) var(--pad-section);
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.cm-cta__copy { flex: 1 1 320px; min-width: 0; }
.cm-cta h2 { font-size: var(--fs-h2-beta); margin-bottom: var(--space-8); }
.cm-cta p { margin: 0; font-size: 14.5px; color: var(--text-sub); max-width: 52ch; line-height: 1.55; }
.cm-cta__note { font: 500 12.5px var(--mono); color: var(--text-dim); }

/* ============================== responsive ============================== */

@media (max-width: 1180px) {
  .cm-stage { grid-template-columns: minmax(0, 1fr) 320px; }
  :root { --cm-rail-w: 320px; }
}

@media (max-width: 1080px) {
  .cm-stage { grid-template-columns: minmax(0, 1fr); }
  .cm-rail { max-height: 420px; }
  .cm-cols { grid-template-columns: 1fr; }
  .cm-deck { grid-template-columns: minmax(0, 1fr); gap: var(--space-12); }
  .cm-modes { width: 100%; }
  .cm-mode { flex: 1 1 0; justify-content: center; }
}

@media (max-width: 760px) {
  :root {
    --cm-map-h: clamp(215px, 30vh, 290px);
    --cm-deck-h: 126px;
  }
  /* the map is the hero on a phone: it comes first, search sits under it */
  .cm-stage { order: 1; }
  .cm-head { order: 2; }
  .cm-main { padding-bottom: calc(var(--cm-deck-h) + var(--space-34)); }
  .cm-instrument { padding: var(--space-10); border-radius: var(--radius); }
  /* buy back vertical space so the instrument reaches the first screen */
  .cm-back { margin: var(--space-14) 0 var(--space-12); }
  .cm-intro { margin-bottom: var(--space-16); }
  .cm-intro h1 { margin: var(--space-8) 0 var(--space-10); }
  .cm-intro__lead { font-size: 15.5px; }
  .cm-head { gap: var(--space-8); }
  .cm-head__chip { display: none; }        /* the deck's mode toggle says this */
  .cm-search { order: 3; flex: 1 1 100%; }
  .cm-market { order: 2; margin-left: auto; }
  .cm-head__spacer { display: none; }
  .cm-market select { font-size: 12px; }
  .cm-legend { gap: var(--space-6) var(--space-12); padding: var(--space-9) var(--space-10); }
  .cm-legend__group + .cm-legend__group { padding-left: 0; border-left: 0; }

  /* the control deck becomes a fixed, thumb-reachable bar */
  .cm-deck {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0;
    background: var(--bg-a96);
    -webkit-backdrop-filter: blur(var(--blur-xl)); backdrop-filter: blur(var(--blur-xl));
    padding: var(--space-8) var(--space-12) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    gap: var(--space-8);
  }
  .cm-mode { min-height: 44px; padding: var(--space-6) var(--space-10); }
  .cm-mode__s { display: none; }
  .cm-scrub { --cm-spark-h: 26px; --cm-track-h: 8px; }
  .cm-scrub__body { padding-bottom: var(--space-12); }
  .cm-scrub__date { font-size: 15px; }

  /* closed, the rail is just a panel under the map (the "right now" list);
     selecting a region raises it as a bottom sheet above the control deck */
  .cm-rail { max-height: 340px; }
  .cm-rail.is-open {
    position: fixed; left: 0; right: 0; bottom: var(--cm-deck-h); z-index: 65;
    max-height: 60vh; border-radius: var(--r-18) var(--r-18) 0 0;
    border-bottom: 0; background: var(--panel-solid);
    box-shadow: var(--shadow-modal);
    animation: cm-sheet-in var(--dur-slow) var(--ease-out);
  }
  .cm-rail.is-open::before {
    content: ""; position: absolute; left: 50%; top: var(--space-6);
    width: 36px; height: 4px; margin-left: -18px;
    border-radius: var(--r-pill); background: var(--line-2);
  }
  .cm-rail.is-open .cm-rail__scroll { padding: var(--space-18) var(--space-14) var(--space-20); }
  .cm-search input { min-height: 44px; }
  .cm-key { min-height: 30px; }
  @keyframes cm-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  .cm-facts { grid-template-columns: 1fr 1fr; }
  .cm-cta { padding: var(--space-20) var(--space-18); }
  .cm-index__grid { columns: 150px; column-gap: var(--space-16); }
  .cm-index__o a { padding: var(--space-8) 0; }      /* comfier tap targets */
  .cm-back { padding: var(--space-6) 0; }
}

@media (min-width: 1081px) {
  .cm-rail { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cm-rail, .cm-tip, .cm-mode, .cm-key, .cm-now__row { transition: none; }
  .cm-rail.is-open { animation: none; }
}
