/* MapFun — wow moments gallery + caption, rich info-card content, About panel, share, poster view.
   Uses the theme tokens from theme-*.css; every colour below works on both the observatory and the atlas theme. */

/* ---------- category colours (badges, filter dots) --------------------------------------------------------- */
:root {
  --cat-truesize: #ffb454; --cat-projection: #4fd8ff; --cat-globe: #8fb4ff; --cat-night: #c9a7ff;
  --cat-sealevel: #5fd0c0; --cat-iceage: #bfe6ff; --cat-geology: #f08a6a; --cat-history: #e0c48a;
}
:root[data-theme="atlas"] {
  --cat-truesize: #9b5a10; --cat-projection: #1f4e79; --cat-globe: #3b4f9e; --cat-night: #5a3e8f;
  --cat-sealevel: #146a63; --cat-iceage: #2f6f9f; --cat-geology: #a3372b; --cat-history: #6b4a12;
}
.cat-truesize { --cat: var(--cat-truesize); } .cat-projection { --cat: var(--cat-projection); } .cat-globe { --cat: var(--cat-globe); } .cat-night { --cat: var(--cat-night); }
.cat-sealevel { --cat: var(--cat-sealevel); } .cat-iceage { --cat: var(--cat-iceage); } .cat-geology { --cat: var(--cat-geology); } .cat-history { --cat: var(--cat-history); }

/* ---------- top-bar buttons ---------------------------------------------------------------------------------- */
#wow-btn { font-family: var(--font-display); font-weight: 600; gap: 6px; }
#wow-btn .sparkle, .wow-head .sparkle, #wow-caption .sparkle { color: var(--accent); }
#wow-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
#wow-btn.tip-below::after { left: 50%; }

/* ---------- gallery ------------------------------------------------------------------------------------------ */
#wow-scrim { z-index: 24; }
#wow-gallery {
  position: absolute; left: 12px; right: 12px; top: calc(var(--topbar-h) + 10px); margin: 0 auto; max-width: 1240px;
  max-height: calc(100vh - var(--topbar-h) - 24px); max-height: calc(100dvh - var(--topbar-h) - 24px);
  display: flex; flex-direction: column; z-index: 25; animation: pop-in var(--t-med); overflow: hidden;
}
/* the close button is pinned to the corner, so a wrapping row of filter chips can never push it onto its own line */
.wow-head { display: flex; align-items: center; gap: 12px; padding: 12px 52px 12px 16px; border-bottom: 1px solid var(--panel-border); flex-wrap: wrap; position: relative; }
.wow-head h2 { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.wow-head h2 svg { width: 18px; height: 18px; }
.wow-head .hint { color: var(--ink-muted); font-size: 12.5px; }
.wow-head .filters { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.wow-head .filters .chip .dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--cat); flex: none; }
.wow-head .filters .chip[aria-pressed="true"] { color: var(--cat); border-color: color-mix(in srgb, var(--cat) 45%, transparent); background: color-mix(in srgb, var(--cat) 14%, transparent); }
.wow-head .surprise { height: 30px; font-size: 13px; }
.wow-head .close { position: absolute; top: 10px; right: 10px; }

.wow-strip-wrap { position: relative; min-height: 0; }
.wow-strip {
  display: flex; gap: 12px; padding: 16px 18px 18px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; scroll-padding: 18px; -webkit-overflow-scrolling: touch;
}
.wcard {
  flex: 0 0 240px; width: 240px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 12px; border-radius: 12px; text-align: left; color: var(--ink);
  background: color-mix(in srgb, var(--ink) 4%, transparent); border: 1px solid transparent;
  transition: background-color var(--t-fast), border-color var(--t-fast), transform var(--t-med), box-shadow var(--t-med);
}
.wcard:hover, .wcard:focus-visible { background: color-mix(in srgb, var(--ink) 9%, transparent); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0,0,0,.22); }
.wcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wcard[aria-selected="true"] { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft); }
.wcard .thumb { position: relative; border-radius: 8px; overflow: hidden; background: var(--ocean-deep); aspect-ratio: 16 / 10; }
.wcard .thumb canvas { width: 100%; height: 100%; }
.wcard .badge, #wow-caption .badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--cat); background: color-mix(in srgb, var(--cat) 16%, var(--panel-solid)); border: 1px solid color-mix(in srgb, var(--cat) 40%, transparent); white-space: nowrap;
}
.wcard .badge { position: absolute; top: 8px; left: 8px; }
.wcard .tag { position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 5px; font-family: var(--font-mono); font-size: 10px; color: #fff; background: rgba(0,0,0,.5); letter-spacing: .01em; }
.wcard .wtitle { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; line-height: 1.25; letter-spacing: -0.005em; }
.wcard .wtext { font-size: 12.5px; line-height: 1.45; color: var(--ink-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
:root[data-theme="atlas"] .wcard .wtext { font-size: 13.5px; }

.wow-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--ink);
  background: var(--panel-solid); border: 1px solid var(--panel-border); box-shadow: var(--shadow); transition: opacity var(--t-fast), transform var(--t-fast);
}
.wow-arrow svg { width: 18px; height: 18px; }
.wow-arrow.prev { left: 8px; } .wow-arrow.next { right: 8px; }
.wow-arrow:hover { transform: translateY(-50%) scale(1.06); }
@media (pointer: coarse) { .wow-arrow { display: none; } }

/* dim the floating chrome behind the gallery, as the picker does */
:root.wow-open #infocard, :root.wow-open #coords, :root.wow-open #attribution, :root.wow-open #skinbar, :root.wow-open #wow-caption { opacity: 0; pointer-events: none; transition: opacity var(--t-fast); }

@keyframes wow-cap-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- caption card ------------------------------------------------------------------------------------- */
#wow-caption {
  /* --wow-shift / --wow-shift-l (set by placeCaption) are the widths the open info card takes on the right and the
     bottom-left panels (empire blurb, sea-level pill, true-size card) take on the left: the caption centres in what
     is left of the map instead of on top of either of them */
  position: absolute; left: 50%; bottom: calc(16px + var(--safe-b) + var(--wow-lift, 0px));
  transform: translateX(calc(-50% + var(--wow-shift-l, 0px) / 2 - var(--wow-shift, 0px) / 2));
  width: min(520px, calc(100vw - 24px - var(--wow-shift, 0px) - var(--wow-shift-l, 0px))); z-index: 13; padding: 12px 16px 12px;
  /* fade in only — a keyframe that animates `transform` (toast-in) would fight the centring transform above */
  animation: wow-cap-in var(--t-med);
  transition: bottom var(--t-med), transform var(--t-med);
}
#wow-caption .cap-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
#wow-caption .cap-head .count { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
#wow-caption .cap-head .spacer { flex: 1; }
#wow-caption h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
#wow-caption p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.55; }
:root[data-theme="atlas"] #wow-caption p { font-size: 14.5px; }
#wow-caption .applied { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
#wow-caption .applied .chip.skipped { text-decoration: line-through; opacity: .6; }
#wow-caption .cap-foot { display: flex; align-items: center; gap: 4px; }
#wow-caption .cap-foot .btn.ghost { margin-left: auto; font-size: 12.5px; height: 30px; }
#wow-caption .cap-foot .btn.ghost svg { width: 14px; height: 14px; }

/* ---------- rich info card ----------------------------------------------------------------------------------- */
#infocard .rich { display: contents; }
#infocard p.tagline { font-family: var(--font-display); font-size: 15.5px; font-weight: 500; line-height: 1.35; color: var(--ink); margin: 2px 0 10px; letter-spacing: -0.005em; }
:root[data-theme="atlas"] #infocard p.tagline { font-style: italic; font-weight: 500; font-size: 17px; }
#infocard p.lead { font-size: 13.5px; color: var(--ink); }
#infocard .proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
#infocard .proscons .k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; margin-bottom: 4px; }
#infocard .proscons ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#infocard .proscons li { display: flex; gap: 6px; align-items: baseline; font-size: 12.5px; line-height: 1.4; padding: 5px 8px; border-radius: 7px; background: color-mix(in srgb, var(--ink) 5%, transparent); }
#infocard .proscons .sign { font-family: var(--font-mono); font-weight: 700; flex: none; width: 10px; text-align: center; }
#infocard .proscons .pros .sign { color: var(--c-equal-area); }
#infocard .proscons .cons .sign { color: var(--c-conformal); }
#infocard .callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; margin: 4px 0 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
#infocard .callout .ico { width: 16px; height: 16px; flex: none; color: var(--accent); margin-top: 2px; }
#infocard .callout p { margin: 0; font-size: 13px; line-height: 1.5; }
#infocard p.quip { font-size: 12.5px; line-height: 1.5; color: var(--ink-muted); margin: 0 0 12px; }
#infocard .quip .quip-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; display: block; margin-bottom: 2px; }
#infocard .quip .quip-text { font-style: italic; color: var(--ink); }
#infocard .quip .quip-ref { font-size: 11.5px; color: var(--ink-muted); text-decoration: underline dotted; }
#infocard .quip .quip-ref:hover { color: var(--accent); }
#infocard section.wiki { display: flow-root; padding: 10px 12px; border-radius: 9px; margin: 2px 0 12px; background: color-mix(in srgb, var(--ink) 4%, transparent); border: 1px solid var(--panel-border); }
#infocard .wiki .wiki-thumb { float: right; width: 84px; height: 84px; object-fit: cover; border-radius: 6px; margin: 0 0 6px 12px; background: var(--ocean-deep); }
#infocard .wiki p.extract.clamped { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
#infocard .wiki .more { color: var(--accent); font-size: 11px; font-weight: 600; margin-left: 6px; }
#infocard .wiki .more:hover { text-decoration: underline; }
#infocard .wiki .k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#infocard .wiki p { margin: 0 0 6px; font-size: 12.5px; line-height: 1.5; }
:root[data-theme="atlas"] #infocard .wiki p { font-size: 13.5px; }
#infocard .wiki p.attribution { font-size: 11px; color: var(--ink-muted); margin: 0; }
#infocard .wiki p.attribution a { color: inherit; text-decoration: underline dotted; }
#infocard .wiki p.attribution a:hover { color: var(--accent); }
#infocard .wiki .wiki-loading { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 4px 0; }
#infocard .wiki .shimmer { display: block; height: 11px; border-radius: 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--ink) 7%, transparent), color-mix(in srgb, var(--ink) 14%, transparent), color-mix(in srgb, var(--ink) 7%, transparent)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
#infocard .wiki .shimmer.short { width: 60%; }
#infocard .wiki.wiki-failed { display: none; }
@keyframes shimmer { to { background-position: -200% 0; } }
#infocard h3.country-title { display: flex; align-items: center; gap: 10px; }
#infocard .flag { font-size: 24px; line-height: 1; flex: none; }
#infocard .flag.flag-text { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 3px 6px; border-radius: 5px; background: color-mix(in srgb, var(--ink) 9%, transparent); color: var(--ink-muted); }
#infocard .sizebox { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 10px 12px; border-radius: 9px; margin: 2px 0 12px; background: color-mix(in srgb, var(--ink) 5%, transparent); border: 1px solid var(--panel-border); }
#infocard .sizebox .ratio-num { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; color: var(--ink); min-width: 3.2ch; }
#infocard .sizebox.inflated .ratio-num { color: var(--c-conformal); }
#infocard .sizebox.shrunk .ratio-num { color: var(--c-equidistant); }
#infocard .sizebox .ratio-text { font-size: 12px; line-height: 1.45; color: var(--ink-muted); }
#infocard .sizebox .ratio-text::first-letter { text-transform: none; }

/* ---------- About panel -------------------------------------------------------------------------------------- */
#about {
  position: absolute; right: 12px; top: calc(var(--topbar-h) + 10px); width: 440px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--topbar-h) - 24px); max-height: calc(100dvh - var(--topbar-h) - 24px);
  display: flex; flex-direction: column; z-index: 26; animation: pop-in var(--t-med); overflow: hidden;
}
#about .about-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--panel-border); }
#about .about-mark { color: var(--accent); display: grid; place-items: center; }
#about .about-title { flex: 1; min-width: 0; }
#about h2 { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 600; line-height: 1.2; }
#about .about-sub { font-size: 12px; color: var(--ink-muted); }
#about .about-body { padding: 12px 16px 16px; overflow: auto; }
#about .about-lead { margin: 0 0 12px; font-size: 14px; line-height: 1.6; }
:root[data-theme="atlas"] #about .about-lead { font-size: 15.5px; }
#about .about-links { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
#about h3.about-h { margin: 14px 0 8px; font-family: var(--font-display); font-size: 13px; font-weight: 600; letter-spacing: .02em; padding-top: 12px; border-top: 1px solid var(--panel-border); }
#about .about-note { font-size: 12.5px; color: var(--ink-muted); margin: -2px 0 10px; }
#about .shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 13px; }
#about .shortcuts .keys { display: flex; gap: 3px; justify-content: flex-end; flex-wrap: wrap; }
#about .shortcuts .section { margin-top: 10px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; grid-column: 1 / -1; }
#about .shortcuts .section:first-child { margin-top: 0; }
#about .credit-group { margin-bottom: 12px; }
#about .credit-group .eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; margin: 0 0 6px; }
#about ul.credits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#about .credit { padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--ink) 4%, transparent); }
#about .credit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
#about .credit-name { font-weight: 600; font-size: 13px; color: var(--ink); }
#about .credit-name:hover { color: var(--accent); }
#about .credit-license { flex: none; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 7%, transparent); white-space: nowrap; }
#about .credit-license.req { color: var(--accent); background: var(--accent-soft); }
#about .credit-text { margin: 0; font-size: 12.5px; line-height: 1.5; }
#about .credit-note { margin: 4px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-muted); }
#about .about-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--panel-border); font-size: 12.5px; color: var(--ink-muted); }
#about .about-foot .dot { opacity: .5; }

/* ---------- poster view (H) ---------------------------------------------------------------------------------- */
:root.chrome-hidden #topbar, :root.chrome-hidden #skinbar, :root.chrome-hidden #infocard, :root.chrome-hidden #coords, :root.chrome-hidden #attribution,
:root.chrome-hidden #timeline, :root.chrome-hidden #wow-caption, :root.chrome-hidden #help, :root.chrome-hidden #about, :root.chrome-hidden #picker,
:root.chrome-hidden #wow-gallery, :root.chrome-hidden .scrim,
/* the left-edge instruments: the tool box (extras rail + navigation cluster), plus the chips and the cards they open */
:root.chrome-hidden #toolbox, :root.chrome-hidden #nav-rail, :root.chrome-hidden #extras-rail, :root.chrome-hidden #truesize,
:root.chrome-hidden #sealevel-slot, :root.chrome-hidden #areatint-legend, :root.chrome-hidden #terminator-clock,
/* the Indigenous-lands card and provenance sheet float over the stage like the empire blurb does */
:root.chrome-hidden .nl-card, :root.chrome-hidden .nl-prov { display: none !important; }

/* ---------- responsive --------------------------------------------------------------------------------------- */
@media (max-width: 960px) {
  #wow-btn .label { display: none; }
  #wow-btn { width: 34px; padding: 0; justify-content: center; }
}
@media (max-width: 720px) {
  /* Phone top bar, two rows. index.html budgets row 1 for wordmark + projection + theme + help (~330 px of 375);
     Wow and About join it as 34 px icons and the projection button gives up ~6vw to pay for them. Row 2 stays
     the mode tabs + the search box. Share is dropped — it lives in the About panel and on the wow caption. */
  #topbar:has(#wow-btn) #projection-btn { max-width: 28vw; }
  #wow-btn { order: 0; width: 34px; padding: 0; justify-content: center; }
  #wow-btn .label { display: none; }
  #share-btn { display: none; }
  #topbar:has(#wow-btn) .search { flex: 1 1 0; min-width: 110px; }
  #topbar:has(#wow-btn) .search .kbd { display: none; } /* no physical key to hint at, and it is what overflowed */
  #wow-gallery { left: 6px; right: 6px; }
  .wow-head { padding: 10px 12px; gap: 8px; }
  .wow-head .hint { display: none; }
  .wow-head .filters { flex-wrap: nowrap; overflow-x: auto; margin-left: 0; flex: 1 1 100%; order: 5; padding-bottom: 2px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .wow-head .filters::-webkit-scrollbar { display: none; }
  .wow-head .filters .chip { height: 32px; padding: 0 12px; font-size: 12.5px; }
  .wow-head .surprise { margin-left: auto; }
  .wow-strip { padding: 12px 12px 14px; gap: 10px; scroll-snap-type: x mandatory; }
  .wcard { flex-basis: 78vw; width: 78vw; max-width: 300px; }
  .wcard .wtext { -webkit-line-clamp: 2; }
  #wow-caption { width: calc(100vw - 16px); padding: 10px 12px 10px; }
  #wow-caption h3 { font-size: 16px; }
  #wow-caption p { font-size: 13px; }
  #about { left: 8px; right: 8px; width: auto; }
  #infocard .proscons { grid-template-columns: 1fr; }
}
