/* MapFun — compare experiences: the Wall (src/ui/wall.js) and the A/B Split (src/ui/split.js).
   Both live in full-stage sections (#wall, #split) that cover the map while their mode is active. */

/* ---------- Shared shell ------------------------------------------------- */
.compare {
  position: absolute; left: 0; right: 0; top: var(--topbar-h); bottom: 0; z-index: 10;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg); color: var(--ink);
  transition: background-color var(--t-theme), color var(--t-theme);
}
/* the Explore stage and its floating chrome step aside while a compare mode is on (the scene keeps its size) */
:root.mode-wall #stage, :root.mode-split #stage { visibility: hidden; }
:root.mode-wall #skinbar, :root.mode-wall #infocard, :root.mode-wall #coords, :root.mode-wall #attribution, :root.mode-wall #timeline,
:root.mode-split #skinbar, :root.mode-split #infocard, :root.mode-split #coords, :root.mode-split #timeline { display: none !important; }
/* the extras chrome belongs to Explore: it would float over the tiles / the panes */
:root.mode-wall #toolbox, :root.mode-wall #truesize, :root.mode-wall #terminator-clock, :root.mode-wall #areatint-legend, :root.mode-wall #sealevel-slot, :root.mode-wall #wow-caption,
:root.mode-split #toolbox, :root.mode-split #truesize, :root.mode-split #terminator-clock, :root.mode-split #areatint-legend, :root.mode-split #sealevel-slot { display: none !important; }
:root.mode-split #attribution { z-index: 13; }

.compare-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px 8px; flex-wrap: wrap; }
.compare-head .titles { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex-wrap: wrap; }
.compare-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.005em; }
.compare-head .hint { margin: 0; color: var(--ink-muted); font-size: 13px; }
.compare-head .filters { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.compare-head .toggle-all { font-variant-numeric: tabular-nums; }
.compare-head .quiz-btn svg { width: 16px; height: 16px; }
.compare .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.compare .dot.equal-area { color: var(--c-equal-area); } .compare .dot.conformal { color: var(--c-conformal); } .compare .dot.compromise { color: var(--c-compromise); }
.compare .dot.equidistant { color: var(--c-equidistant); } .compare .dot.gnomonic, .compare .dot.perspective { color: var(--c-gnomonic); }
.compare .chip .dot { width: 6px; height: 6px; margin-right: 6px; }
.compare .chip[aria-pressed="true"] .dot { color: var(--accent); }

/* ---------- The Wall ------------------------------------------------------ */
.wall-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 14px;
  grid-auto-rows: max-content; padding: 8px 22px 28px; overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; align-content: start;
  scroll-padding: 12px;
}
.wall-grid.empty { display: block; }
.wall-grid .empty { color: var(--ink-muted); padding: 24px 0; text-align: center; }
.wtile {
  position: relative; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden;
  background: color-mix(in srgb, var(--ink) 4%, transparent); border: 1px solid color-mix(in srgb, var(--ink) 6%, transparent);
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-fast), background-color var(--t-fast);
  will-change: transform;
}
.wtile:hover, .wtile:focus-within { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0,0,0,.28); background: color-mix(in srgb, var(--ink) 7%, transparent); border-color: color-mix(in srgb, var(--ink) 12%, transparent); z-index: 2; }
:root[data-theme="atlas"] .wtile:hover, :root[data-theme="atlas"] .wtile:focus-within { box-shadow: 0 14px 30px rgba(60,40,10,.18); }
.wtile.current { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wtile.current .wcap .name { color: var(--accent); }
.wtile .wmap { position: relative; aspect-ratio: 16 / 10; background: var(--bg-elev); cursor: grab; touch-action: pan-y; }
.wall-grid.dragging, .wall-grid.dragging .wmap { cursor: grabbing; }
.wtile canvas { width: 100%; height: 100%; display: block; }
.wtile .rank { position: absolute; top: 8px; left: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--ink); background: color-mix(in srgb, var(--bg) 60%, transparent); padding: 1px 5px; border-radius: 4px; opacity: 0; transition: opacity var(--t-fast); pointer-events: none; }
.wtile:hover .rank { opacity: .9; }
.wtile .wcap {
  display: flex; align-items: baseline; gap: 8px; padding: 9px 12px 10px; text-align: left; color: var(--ink); width: 100%;
  font-weight: 600; font-size: 13.5px; line-height: 1.25; border-radius: 0;
}
.wtile .wcap .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wtile .wcap .year { flex: none; font-weight: 400; color: var(--ink-muted); font-size: 11px; font-family: var(--font-mono); }
.wtile .wcap:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.wtile .wcap:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.wtile .winfo {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 14px 12px 42px; /* anchored to the tile bottom; the text sits above the caption row */
  color: var(--ink); font-size: 12px; line-height: 1.4;
  background: linear-gradient(to top, var(--panel-solid) 60%, color-mix(in srgb, var(--panel-solid) 85%, transparent) 88%, transparent);
  opacity: 0; transform: translateY(10px); transition: opacity var(--t-med), transform var(--t-med); pointer-events: none;
}
.wtile .winfo .chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.wtile .winfo p { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wtile:hover .winfo, .wtile:focus-within .winfo { opacity: 1; transform: none; transition-delay: 120ms; }
.wall-grid.dragging .winfo { opacity: 0 !important; }
@media (pointer: coarse) { .wtile .winfo { display: none; } }

/* ---------- Quiz ------------------------------------------------------------ */
.quiz { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 8px 22px 28px; max-width: 820px; width: 100%; margin: 0 auto; }
.quiz-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quiz-head h3 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.quiz-status { display: flex; gap: 6px; margin-left: auto; font-variant-numeric: tabular-nums; }
.quiz-status .chip.score { color: var(--accent); background: var(--accent-soft); }
.quiz-stage { border-radius: 14px; overflow: hidden; background: var(--bg-elev); border: 1px solid var(--panel-border); box-shadow: var(--shadow); }
.quiz-canvas { width: 100%; aspect-ratio: 16 / 10; display: block; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; border-radius: 10px; text-align: left; color: var(--ink);
  font-weight: 600; font-size: 14px; background: color-mix(in srgb, var(--ink) 6%, transparent); border: 1px solid transparent;
  transition: background-color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.qa:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 11%, transparent); transform: translateY(-1px); }
.qa:disabled { cursor: default; opacity: .7; }
.qa.right { background: color-mix(in srgb, #5ce0a6 22%, transparent); border-color: #5ce0a6; opacity: 1; }
.qa.wrong { background: color-mix(in srgb, var(--danger) 20%, transparent); border-color: var(--danger); opacity: 1; }
.quiz-feedback { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-muted); min-height: 2.9em; }
.quiz-feedback.ok { color: var(--ink); } .quiz-feedback.nope { color: var(--ink); }
.quiz-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- The Split ------------------------------------------------------- */
.split { --split: 0.5; }
.split-panes { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.split-panes.dragging { cursor: grabbing; }
.split .pane { position: absolute; overflow: hidden; background: var(--bg); }
.split .pane canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
/* side by side — each pane fitted to its own box */
.split[data-axis="x"][data-layout="side"] .pane.left { top: 0; bottom: 0; left: 0; width: calc(var(--split) * 100%); }
.split[data-axis="x"][data-layout="side"] .pane.right { top: 0; bottom: 0; right: 0; width: calc((1 - var(--split)) * 100%); }
.split[data-axis="y"][data-layout="side"] .pane.left { left: 0; right: 0; top: 0; height: calc(var(--split) * 100%); }
.split[data-axis="y"][data-layout="side"] .pane.right { left: 0; right: 0; bottom: 0; height: calc((1 - var(--split)) * 100%); }
/* wipe — both full frame, the right one behind a curtain */
.split[data-layout="wipe"] .pane { inset: 0; }
.split[data-axis="x"][data-layout="wipe"] .pane.right { clip-path: inset(0 0 0 calc(var(--split) * 100%)); }
.split[data-axis="y"][data-layout="wipe"] .pane.right { clip-path: inset(calc(var(--split) * 100%) 0 0 0); }
/* atlas paper grain over the panes, like #stage */
:root[data-theme="atlas"] .split-panes::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3; background-image: var(--paper-texture); opacity: .55; mix-blend-mode: multiply; }

/* divider */
.split .divider { position: absolute; z-index: 6; outline: none; }
.split[data-axis="x"] .divider { top: 0; bottom: 0; left: calc(var(--split) * 100%); width: 0; }
.split[data-axis="y"] .divider { left: 0; right: 0; top: calc(var(--split) * 100%); height: 0; }
.split .divider::before { content: ""; position: absolute; background: color-mix(in srgb, var(--accent) 55%, transparent); transition: background-color var(--t-fast), box-shadow var(--t-fast); }
.split[data-axis="x"] .divider::before { top: 0; bottom: 0; left: -1px; width: 2px; }
.split[data-axis="y"] .divider::before { left: 0; right: 0; top: -1px; height: 2px; }
.split .divider:hover::before, .split .divider.active::before, .split .divider:focus-visible::before { background: var(--accent); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); }
.split .divider .hit { position: absolute; }
.split[data-axis="x"] .divider .hit { top: 0; bottom: 0; left: -9px; width: 18px; cursor: col-resize; }
.split[data-axis="y"] .divider .hit { left: 0; right: 0; top: -9px; height: 18px; cursor: row-resize; }
.split .divider .grip {
  position: absolute; display: flex; align-items: center; justify-content: center; gap: 3px;
  background: var(--panel-solid); border: 1px solid var(--panel-border); box-shadow: var(--shadow); border-radius: 999px;
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.split[data-axis="x"] .divider .grip { top: 50%; left: 0; width: 26px; height: 58px; transform: translate(-50%, -50%); flex-direction: column; cursor: col-resize; }
.split[data-axis="y"] .divider .grip { left: 50%; top: 0; width: 58px; height: 26px; transform: translate(-50%, -50%); flex-direction: row; cursor: row-resize; }
.split .divider .grip i { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--ink-muted); }
.split .divider:hover .grip, .split .divider.active .grip { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.split .divider:focus-visible .grip { outline: 2px solid var(--accent); outline-offset: 2px; }
.split .divider .swap { position: absolute; background: var(--panel-solid); border: 1px solid var(--panel-border); box-shadow: var(--shadow); border-radius: 999px; color: var(--ink); width: 36px; height: 36px; }
.split[data-axis="x"] .divider .swap { top: calc(50% + 44px); left: 0; transform: translateX(-50%); }
.split[data-axis="y"] .divider .swap { left: calc(50% + 46px); top: 0; transform: translateY(-50%); }
.split .divider .swap:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.split .divider .swap.spin svg { animation: swap-spin 420ms cubic-bezier(.2,.7,.2,1); }
@keyframes swap-spin { from { transform: rotate(0); } to { transform: rotate(180deg); } }

/* pane labels: a compact select + the property chip */
.pane-label { position: absolute; top: 12px; z-index: 5; display: flex; align-items: center; gap: 8px; max-width: calc(50% - 40px); }
.pane-label.left { left: 12px; }
.pane-label.right { right: 12px; flex-direction: row-reverse; }
.split[data-axis="y"] .pane-label { max-width: calc(100% - 24px); }
.split[data-axis="y"] .pane-label.right { top: calc(var(--split) * 100% + 12px); right: auto; left: 12px; flex-direction: row; }
.pane-label .field { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.pane-select {
  appearance: none; -webkit-appearance: none; height: 34px; padding: 0 32px 0 12px; min-width: 0; max-width: 100%;
  border-radius: var(--radius-sm); border: 1px solid var(--panel-border); background: var(--panel); color: var(--ink);
  backdrop-filter: blur(12px) saturate(1.2); -webkit-backdrop-filter: blur(12px) saturate(1.2); box-shadow: var(--shadow);
  font-family: var(--font-display); font-weight: 600; font-size: 14px; cursor: pointer; text-overflow: ellipsis;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.pane-select:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.pane-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pane-select option, .pane-select optgroup { color: var(--ink); background: var(--panel-solid); font-family: var(--font-ui); font-weight: 500; }
.pane-label .chev { position: absolute; right: 10px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); pointer-events: none; opacity: .6; }
.pane-label .chip.prop { background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-color: var(--panel-border); }

/* toolbar */
.split-toolbar {
  position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 10px; padding: 5px 8px 5px 5px; border-radius: 999px; white-space: nowrap;
}
.split-toolbar .seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.split-toolbar .seg-btn { height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--ink-muted); transition: background-color var(--t-fast), color var(--t-fast); }
.split-toolbar .seg-btn[aria-pressed="true"] { background: var(--panel-solid); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.split-toolbar .zoom { font-family: var(--font-mono); font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 5ch; text-align: center; }
.split-toolbar .btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.split-toolbar .hint { font-size: 12px; color: var(--ink-muted); padding-right: 6px; }

/* ---------- Responsive ---------------------------------------------------- */
@media (max-width: 1180px) { .wall-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .compare-head { padding: 10px 12px 6px; gap: 8px; }
  .compare-head h2 { font-size: 17px; }
  .compare-head .hint { display: none; }
  .compare-head .filters { margin-left: 0; flex: 1 1 100%; order: 5; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; }
  .compare-head .filters::-webkit-scrollbar { display: none; }
  .compare-head .quiz-btn { padding: 0 10px; }
  .wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 6px 10px 20px; }
  .wtile .wcap { padding: 7px 9px 8px; font-size: 12.5px; gap: 6px; }
  .wtile .wcap .year { display: none; }
  .quiz { padding: 6px 12px 20px; gap: 10px; }
  .quiz-choices { grid-template-columns: 1fr; }
  .qa { min-height: 44px; }
  .split-toolbar .hint { display: none; }
  .split-toolbar { bottom: calc(10px + var(--safe-b)); gap: 6px; }
  .pane-select { max-width: 60vw; }
}
@media (prefers-reduced-motion: reduce) { .wtile, .wtile .winfo { transition: none; } }
