/*
 * The Coffee Atlas: map and wizard side by side, sized together to one screen.
 * Panel colours are the original build's atlas tokens (--atlas-panel-*, set on
 * .coffee-atlas-main); zone fills are the ECA atlas palette.
 */

.buna-atlas {
	--zone-north: #1f1f1f;
	--zone-rift: #b88a4a;
	--zone-south-west: #7a1e22;
	--zone-south-east: #1e4d2b;
	--zone-harar: #556b2f;
	--pick: var(--brass, #c9a24a);
	--panel-head: var(--atlas-panel-head, #42665a);
	--panel-body: var(--atlas-panel-body, #345348);
	--panel-ink: var(--atlas-panel-ink, #f2eee4);
	--panel-muted: var(--atlas-panel-muted, #dfe6db);
	--panel-border: var(--atlas-panel-border, #f2eee426);

	display: grid;
	grid-template-columns: minmax(0, 1.2fr) minmax(360px, 1fr);
	gap: clamp(16px, 2vw, 28px);
	/* Everything fits one screen under the header and the page title. */
	height: clamp(560px, calc(100svh - 254px), 860px);
	margin-bottom: clamp(40px, 6vw, 80px);
	color: var(--panel-ink);
}

/* The page title tightens so the map and the wizard share the first screen. */
.coffee-atlas-page:has(.buna-atlas) { padding-top: clamp(16px, 2.5vh, 28px); }
.coffee-atlas-page:has(.buna-atlas) .coffee-atlas-heading { margin-bottom: clamp(12px, 2vh, 20px); }
.coffee-atlas-page:has(.buna-atlas) .coffee-atlas-heading h1 { margin: 0; }
.coffee-atlas-page:has(.buna-atlas) .coffee-atlas-heading p { margin: 4px auto 0; }

/* ---------------------------------------------------------------- map */

.buna-atlas-map {
	display: flex; flex-direction: column; min-height: 0; margin: 0;
	border: 1px solid var(--panel-border); border-radius: 22px; overflow: hidden;
	/* The same ground as the wizard beside it, so the two read as one surface. */
	background: linear-gradient(180deg, color-mix(in srgb, var(--panel-head) 88%, transparent) 0%, var(--panel-body) 100%);
	backdrop-filter: blur(8px); box-shadow: 0 24px 54px #0f251d3d;
}
.buna-atlas-map-label {
	display: flex; justify-content: space-between; gap: 16px; padding: 14px 20px;
	font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
}
.buna-atlas-map-label span:last-child { color: var(--panel-muted); text-transform: none; letter-spacing: .02em; }
.buna-atlas-map-canvas {
	flex: 1; min-height: 0; display: grid; place-items: center;
	padding: clamp(8px, 1.5vw, 20px);
}
.buna-atlas-map-canvas svg { display: block; width: 100%; height: 100%; max-height: 100%; }
.buna-atlas-map-canvas .atlas-outline { fill: #f2eee41a; stroke: #f2eee466; stroke-width: 1.2; }

.buna-atlas .atlas-area {
	stroke: #f2eee4b3; stroke-width: 1.2; cursor: pointer; outline: none;
	transition: opacity .16s ease, fill .16s ease, filter .16s ease;
}
.buna-atlas [data-zone="North"]      { --zone: var(--zone-north); }
.buna-atlas [data-zone="Rift"]       { --zone: var(--zone-rift); }
.buna-atlas [data-zone="South West"] { --zone: var(--zone-south-west); }
.buna-atlas [data-zone="South East"] { --zone: var(--zone-south-east); }
.buna-atlas [data-zone="Harar"]      { --zone: var(--zone-harar); }
.buna-atlas .atlas-area { fill: var(--zone); }
.buna-atlas .atlas-area.is-dimmed { opacity: .22; }
.buna-atlas .atlas-area.is-picked { fill: var(--pick); }
.buna-atlas .atlas-area:hover, .buna-atlas .atlas-area:focus-visible { filter: brightness(1.18) drop-shadow(0 0 3px #1f1f1f55); }

/* Names are light on every zone but Rift's gold; the halo is the ground under them. */
.buna-atlas .atlas-label {
	font: 700 10.5px/1 var(--sans, Manrope, sans-serif); pointer-events: none;
	fill: #faf7f2; stroke: var(--zone, #1f1f1f); stroke-width: 3px; paint-order: stroke;
	transition: opacity .16s ease;
}
.buna-atlas .atlas-label[data-kew^="B1"] { fill: #1f1f1f; stroke: var(--zone-rift); }
.buna-atlas .atlas-label.is-dimmed { opacity: .5; }
.buna-atlas .atlas-label.is-picked { fill: #1f1f1f; stroke: var(--pick); }
.buna-atlas .atlas-label[data-kew^="A1"] { --zone: var(--zone-north); }
.buna-atlas .atlas-label[data-kew^="A2"] { --zone: var(--zone-south-west); }
.buna-atlas .atlas-label[data-kew^="C1"] { --zone: var(--zone-south-east); }
.buna-atlas .atlas-label[data-kew^="C2"] { --zone: var(--zone-harar); }

.buna-atlas-map figcaption {
	display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 18px;
	padding: 12px 20px 14px; font-size: 11px; color: var(--panel-muted);
}
.buna-atlas-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; color: var(--panel-ink); }
.buna-atlas-legend li { display: inline-flex; align-items: center; gap: 6px; }
.buna-atlas-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--zone); flex: none; box-shadow: 0 0 0 1px #f2eee455; }

/* ---------------------------------------------------------------- wizard */

.buna-atlas-wizard {
	display: flex; flex-direction: column; min-height: 0;
	border: 1px solid var(--panel-border); border-radius: 22px; overflow: hidden;
	background: linear-gradient(180deg, color-mix(in srgb, var(--panel-head) 88%, transparent) 0%, var(--panel-body) 100%);
	backdrop-filter: blur(8px); box-shadow: 0 20px 40px #0f251d3d;
}
.buna-atlas-wizard-head {
	display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
	padding: 18px clamp(20px, 2.2vw, 28px); background: var(--panel-head);
}
.buna-atlas-wizard-head h2 { margin: 0; font: 500 clamp(24px, 2.4vw, 32px)/1.08 var(--serif, "Alegreya SC", serif); color: var(--panel-ink); }
.buna-atlas-wizard-head span { font-size: 10px; color: var(--panel-muted); white-space: nowrap; }

.buna-atlas-steps {
	display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 0;
	padding: 12px clamp(20px, 2.2vw, 28px) 0; list-style: none; counter-reset: step;
}
.buna-atlas-steps button {
	width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
	padding: 0 0 10px; border: 0; border-bottom: 2px solid #f2eee42e; background: none;
	color: var(--panel-muted); font: 700 10.5px/1.2 var(--sans, Manrope, sans-serif); letter-spacing: .04em; text-align: left; cursor: pointer;
}
.buna-atlas-steps button span {
	display: grid; place-items: center; width: 22px; height: 22px; border-radius: 999px;
	border: 1px solid #f2eee466; font-size: 11px;
}
.buna-atlas-steps button.is-done { color: var(--panel-ink); border-bottom-color: #c9a24a88; }
.buna-atlas-steps button.is-done span { background: #c9a24a33; border-color: var(--pick); }
.buna-atlas-steps button[aria-current="step"] { color: var(--panel-ink); border-bottom-color: var(--pick); }
.buna-atlas-steps button[aria-current="step"] span { background: var(--pick); border-color: var(--pick); color: #1f1f1f; }
.buna-atlas-steps button:disabled { cursor: default; opacity: .55; }

.buna-atlas-stage { flex: 1; min-height: 0; overflow-y: auto; padding: 18px clamp(20px, 2.2vw, 28px); scrollbar-gutter: stable; }
.buna-atlas-step h3 { margin: 4px 0 8px; font: 500 clamp(22px, 2vw, 28px)/1.1 var(--serif, "Alegreya SC", serif); color: var(--panel-ink); outline: none; }
.buna-atlas-kicker, .buna-atlas-label {
	margin: 0; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--readable-gold, #e5c77d);
}
.buna-atlas-label { margin-top: 14px; margin-bottom: 6px; }
.buna-atlas-lede { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: var(--panel-muted); }
.buna-atlas-sub { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--panel-muted); }

.buna-atlas-choices { display: grid; gap: 8px; }
/* Five regions sit two-up so the whole first step is in view. */
/* Fifteen origins sit three-up, so the whole first step is in view. */
[data-step-panel="1"] .buna-atlas-choices { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 6px; }
[data-step-panel="1"] .buna-atlas-choice { padding: 7px 24px 7px 10px; gap: 1px; }
[data-step-panel="1"] h3 { margin-bottom: 10px; }
[data-step-panel="1"] .buna-atlas-choice-title { font-size: 14px; }
[data-step-panel="1"] .buna-atlas-choice-meta, [data-step-panel="1"] .buna-atlas-choice-list { font-size: 10.5px; line-height: 1.35; }
[data-step-panel="1"] .buna-atlas-choice-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-step-panel="1"] .buna-atlas-choice-arrow { right: 10px; }
[data-step-panel="2"] .buna-atlas-choices { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.buna-atlas-choice {
	position: relative; display: grid; gap: 3px; width: 100%; padding: 12px 40px 12px 14px;
	border: 1px solid #f2eee433; border-radius: 12px; background: #f2eee40a; color: var(--panel-ink);
	text-align: left; cursor: pointer; font: inherit; transition: background .16s, border-color .16s;
}
.buna-atlas-choice:hover, .buna-atlas-choice:focus-visible { background: #f2eee41f; border-color: var(--pick); outline: none; }
.buna-atlas-choice-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.buna-atlas-choice-meta { font-size: 11.5px; color: var(--panel-muted); }
.buna-atlas-choice-list { font-size: 11.5px; color: #f2eee4b3; line-height: 1.45; }
.buna-atlas-choice-arrow { position: absolute; right: 14px; top: 50%; translate: 0 -50%; color: var(--pick); }

.buna-atlas-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 6px 0 0; }
.buna-atlas-facts div { border-top: 1px solid #f2eee426; padding-top: 7px; }
.buna-atlas-facts dt { font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--readable-gold, #e5c77d); }
.buna-atlas-facts dd { margin: 3px 0 0; font-size: 13px; text-transform: none; }
.buna-atlas-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.buna-atlas-tags li { padding: 4px 10px; border: 1px solid #f2eee44d; border-radius: 999px; font-size: 11.5px; text-transform: capitalize; }
.buna-atlas-forward { margin-left: 12px; min-height: 40px; padding: 10px 18px; font-size: 11px; }

.buna-atlas-lots { display: grid; gap: 10px; margin: 10px 0 16px; }
.buna-atlas-lot { padding: 14px 16px; border-radius: 14px; background: #f2eee4eb; color: var(--volcanic-stone, #333); }
.buna-atlas-lot .buna-atlas-label { margin: 0 0 4px; color: #8d6a1f; }
.buna-atlas-lot h4 { margin: 0 0 4px; font: 500 18px/1.15 var(--serif, "Alegreya SC", serif); }
.buna-atlas-lot p { margin: 0 0 4px; font-size: 12.5px; }
.buna-atlas-lot .buna-atlas-sub { color: #5b5b55; }
.buna-atlas-lot .text-link { color: var(--forest-green, #2f5d50); }
.buna-atlas-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; }
.buna-atlas-empty { margin: 10px 0 16px; padding: 14px 16px; border: 1px dashed #f2eee44d; border-radius: 14px; font-size: 13px; color: var(--panel-muted); }
.buna-atlas-paths { display: grid; gap: 8px; }
.buna-atlas-path {
	display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 14px;
	border: 1px solid #f2eee433; border-radius: 12px; color: var(--panel-ink); text-decoration: none;
}
.buna-atlas-path:hover { border-color: var(--pick); background: #f2eee414; }
.buna-atlas-path strong { font-size: 14px; }
.buna-atlas-path span:nth-of-type(1) { grid-column: 1; font-size: 11.5px; color: var(--panel-muted); }
.buna-atlas-path span[aria-hidden] { grid-column: 2; grid-row: 1 / span 2; color: var(--pick); }
.buna-atlas-again { margin-top: 14px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--readable-gold, #e5c77d); font: 700 12px var(--sans, Manrope, sans-serif); }

.buna-atlas-foot {
	display: flex; justify-content: space-between; align-items: center; gap: 12px;
	padding: 12px clamp(20px, 2.2vw, 28px); border-top: 1px solid #f2eee41f; font-size: 11px; color: var(--panel-muted);
}
.buna-atlas-foot .buna-atlas-progress { margin-left: auto; }
.buna-atlas-back {
	display: inline-flex; gap: 6px; padding: 8px 14px; border: 1px solid #f2eee44d; border-radius: 999px;
	background: none; color: var(--panel-ink); font: 700 11px var(--sans, Manrope, sans-serif); cursor: pointer;
}
.buna-atlas-back:hover { border-color: var(--pick); }

/* The coffee: sub-origin and the notes the buyer asks for. */
.buna-atlas-field { display: grid; gap: 6px; margin: 4px 0 6px; }
.buna-atlas select, .buna-atlas input:not([type="checkbox"]) {
	width: 100%; box-sizing: border-box; min-height: 40px; padding: 8px 10px;
	border: 1px solid #f2eee466; border-radius: 8px; background: #f2eee4f0; color: var(--volcanic-stone, #333);
	font: 13px var(--sans, Manrope, sans-serif);
}
.buna-atlas input:focus-visible, .buna-atlas select:focus-visible { outline: 2px solid var(--pick); outline-offset: 1px; }
.buna-atlas-tags.is-pickable li { padding: 0; border: 0; }
.buna-atlas-tags.is-pickable button {
	padding: 4px 10px; border: 1px solid #f2eee44d; border-radius: 999px; background: none; color: var(--panel-ink);
	font: 11.5px var(--sans, Manrope, sans-serif); cursor: pointer;
}
.buna-atlas-tags.is-pickable button[aria-pressed="true"] { background: var(--pick); border-color: var(--pick); color: #1f1f1f; font-weight: 700; }
.buna-atlas-exporters { margin-top: 14px; color: var(--readable-gold, #e5c77d); font-weight: 700; }

/* The enquiry. */
.buna-atlas-form { display: block; }
.buna-atlas-fixed { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 12px; font-size: 12px; color: var(--panel-muted); }
.buna-atlas-fixed b { color: var(--panel-ink); font-weight: 700; }
.buna-atlas-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin: 0 0 10px; }
.buna-atlas-grid label { display: grid; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--panel-muted); }
.buna-atlas-grid .is-wide { grid-column: 1 / -1; }
.buna-atlas-pair { display: flex; gap: 6px; } .buna-atlas-pair input { flex: 1; min-width: 0; } .buna-atlas-pair select { width: auto; }
.buna-atlas-certs { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 12px; padding: 0; border: 0; font-size: 12.5px; }
.buna-atlas-certs legend { width: 100%; margin-bottom: 6px; }
.buna-atlas-certs label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.buna-atlas-certs input { accent-color: var(--pick); width: 16px; height: 16px; }
.buna-atlas-trap { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.buna-atlas-error { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: #a63a2a; color: #faf7f2; font-size: 12.5px; }

/* The membership step that stands in for matching until payments are integrated. */
.buna-atlas-gate .buna-atlas-actions { margin-top: 6px; }
.buna-atlas-preview { background: none; border: 0; padding: 0; cursor: pointer; color: var(--readable-gold, #e5c77d); font: 700 12px var(--sans, Manrope, sans-serif); }
.buna-atlas-preview-note { margin: 0 0 12px; }
.buna-atlas-placeholder { margin: 22px 0 0; font-size: 12px; color: var(--panel-muted); }

/* The matched exporters. */
.buna-atlas-matches { display: grid; gap: 8px; margin: 10px 0 16px; padding: 0; list-style: none; }
.buna-atlas-match {
	display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; padding: 12px 14px;
	border: 1px solid #f2eee433; border-radius: 12px; background: #f2eee40a;
}
.buna-atlas-match strong { font-size: 14px; }
.buna-atlas-why { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 4px; padding: 0; list-style: none; font-size: 11.5px; }
.buna-atlas-why .is-ok { color: var(--panel-ink); } .buna-atlas-why .is-miss { color: #f2eee480; }
.buna-atlas-pct { display: grid; justify-items: end; line-height: 1.05; }
.buna-atlas-pct b { font-size: 20px; color: var(--readable-gold, #e5c77d); }
.buna-atlas-pct small { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--panel-muted); }
.buna-atlas-forward:disabled { opacity: .7; cursor: progress; }

/* ---------------------------------------------------------------- narrower screens */

@media (max-width: 980px) {
	.buna-atlas { grid-template-columns: minmax(0, 1fr); height: auto; }
	.buna-atlas-map-canvas { height: min(72vw, 460px); flex: none; }
	.buna-atlas-stage { overflow: visible; }
	.buna-atlas-wizard { scroll-margin-top: calc(var(--header, 90px) + 56px); }
}
@media (max-width: 520px) {
	.buna-atlas-grid { grid-template-columns: 1fr; }
	.buna-atlas-map-label span:last-child { display: none; }
	.buna-atlas-steps button { font-size: 0; gap: 0; }
	.buna-atlas-steps button span { font-size: 11px; }
	.buna-atlas-steps button[aria-current="step"] { font-size: 10px; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
	.buna-atlas * { transition: none !important; }
}

/* The Addis Cup lots under the Atlas: the heading's label sits on the page, not in a panel head,
   and the lot a link arrived for stands out. */
.coffee-atlas-auction-heading .coffee-atlas-origin-label { margin: 0 0 .5rem; padding: 0; background: none; color: var(--brass); }
.coffee-atlas-main .atlas-lot-card.is-highlighted { border-color: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 45%, transparent), 0 18px 36px #0f251d33; }
