/* ═══════════════════════════════════════════════════════════
   MommyBaby — region picker (index.html)
   The app's entry page: choose an oblast, then the map opens
   filtered to it. Same clay-and-paper palette as the map.

   Two shapes, one page:
   · phone   — a single scrolling column, hero over cards
   · desktop — an editorial split, hero left / cards right,
               sized so the whole page lands inside one screen
   ═══════════════════════════════════════════════════════════ */

:root {
  /* One measure for the bar, the hero and the footer, so their edges line up.
     The desktop split widens it; everything follows from this one value. */
  --shell: 900px;
}

html { min-height: 100%; }

body {
  min-height: 100dvh;
  /* Belt and braces against a horizontal scrollbar from the hero wash. */
  overflow-x: hidden;
}

/* Both backdrops are fixed and inert: they must not add page height, and
   they must sit under the content rather than over it. */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

/* paper grain — same treatment as the map's sidebar */
body::before {
  inset: 0;
  opacity: .5;
  background-image: var(--grain);
}

/* warm wash behind the hero, so the page is not a flat cream field */
body::after {
  inset: 0 0 auto;
  height: min(560px, 70dvh);
  background: radial-gradient(120% 85% at 50% -15%,
              rgba(228,103,75,.14), rgba(228,103,75,0) 68%);
}

.pick {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Inline padding only. The shorthand would zero out the vertical padding that
   .pick__main sets on the same element — which is exactly how the phone
   layout lost its breathing room at the top and bottom of the page. */
/* Aligned to the site header rather than to --shell: the page content and
   the bar above it have to share one edge, and two numbers kept in step by
   hand drift the moment either is touched. --wrap and --gut are the header's
   own tokens, so this tracks it by construction. */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding-inline: var(--gut);
}

/* ── top bar ────────────────────────────────────────────── */

.pick__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(251,247,242,.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* The brand block is shared with the map, where it is the sidebar header;
   here it is a centred page bar. */
.pick__bar .brand {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 13px 24px;
  border-bottom: 0;
}

/* ── hero ───────────────────────────────────────────────── */

.pick__main {
  flex: 1;
  padding-top: clamp(38px, 8vw, 60px);
  padding-bottom: clamp(46px, 9vw, 56px);
}

.pick__eyebrow {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--clay);
}

.pick__title {
  margin: 10px 0 0;
  font-family: "Unbounded", "Onest", sans-serif;
  font-weight: 700;
  font-size: clamp(27px, 5.6vw, 40px);
  line-height: 1.14;
  letter-spacing: -.035em;
}

.pick__lead {
  margin: 11px 0 0;
  max-width: 44ch;
  font-size: clamp(14.5px, 1.5vw, 16px);
  line-height: 1.55;
  color: var(--muted);
}

/* ── hero actions: "all points" + the running total ─────── */

.pick__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: clamp(18px, 3vw, 24px) 0 0;
}

.btn-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px 9px 12px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: color .18s, border-color .18s, box-shadow .18s,
              transform .18s var(--ease);
}
.btn-all svg { width: 16px; height: 16px; flex: none; color: var(--clay); }

.btn-all:hover {
  color: var(--clay-dark);
  border-color: var(--clay);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-all:active { transform: translateY(0) scale(.985); }
.btn-all:focus-visible { outline: 2px solid var(--clay); outline-offset: 3px; }

/* Total point count, filled in once branches.json lands. */
.pick__stat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 13px 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--moss);
  background: var(--moss-tint);
  border-radius: 999px;
}
.pick__stat svg { width: 14px; height: 14px; flex: none; }

/* ── region cards ───────────────────────────────────────── */

.regions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px;
  margin: clamp(26px, 4.5vw, 38px) 0 0;
  padding: 0;
  list-style: none;
}

/* Two columns only once each one is wide enough for the longest name and its
   town list. Below that a single wide column beats two truncated ones. */
@media (min-width: 760px) {
  .regions { grid-template-columns: 1fr 1fr; gap: 13px; }

  /* Seven cards over two columns leaves one orphan. Let it run the full
     width rather than hang in a half-empty row — these are wide horizontal
     rows, so a full-width one reads as part of the same rhythm. */
  .regions > li:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

.region {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 15px;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s, transform .18s var(--ease);
  animation: rise .45s var(--ease) both;
}

/* Each card carries a breath of its own colour, strongest behind the badge
   and gone by the middle — enough for seven cards to feel individual without
   turning the grid into a paint chart. */
.region::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 190% at 0% 50%,
              rgba(var(--tone-rgb), .10), rgba(var(--tone-rgb), 0) 60%);
  opacity: .8;
  transition: opacity .25s var(--ease);
}

/* A tone-coloured edge that grows in on hover: the card's one moving part. */
.region::after {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tone);
  opacity: 0;
  transform: scaleY(.35);
  transition: opacity .22s var(--ease), transform .28s var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}

.region:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.region:hover::before { opacity: 1; }
.region:hover::after  { opacity: .9; transform: scaleY(1); }
.region:active { transform: translateY(0) scale(.995); }

.region:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
}

/* Per-region accent. Warm enough to sit beside the clay without fighting it.
   --tone-rgb feeds the wash and the hairline rings, which need alpha. */
.region[data-tone="clay"]   { --tone: #C4502F; --tone-tint: #FDEEE9; --tone-rgb: 196,80,47; }
.region[data-tone="moss"]   { --tone: #2F5D50; --tone-tint: #E4EEE9; --tone-rgb: 47,93,80; }
.region[data-tone="amber"]  { --tone: #9C6A1B; --tone-tint: #FAF0DA; --tone-rgb: 156,106,27; }
.region[data-tone="indigo"] { --tone: #3C5A8A; --tone-tint: #E9EEF8; --tone-rgb: 60,90,138; }
.region[data-tone="rust"]   { --tone: #9E4E28; --tone-tint: #F8EAE0; --tone-rgb: 158,78,40; }
.region[data-tone="teal"]   { --tone: #1F7A72; --tone-tint: #DFF0EE; --tone-rgb: 31,122,114; }
.region[data-tone="plum"]   { --tone: #85476A; --tone-tint: #F7EAF1; --tone-rgb: 133,71,106; }

.region__mark {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-family: "Unbounded", "Onest", sans-serif;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -.02em;
  color: var(--tone);
  background: var(--tone-tint);
  border-radius: 15px;
  box-shadow: inset 0 0 0 1px rgba(var(--tone-rgb), .16);
  transition: transform .2s var(--ease);
}
.region:hover .region__mark { transform: scale(1.06) rotate(-3deg); }

.region__body { min-width: 0; }

/* One line, always: a wrapped name would make its card taller than the six
   beside it and break the grid's rhythm. Hence the short labels in the data. */
.region__name {
  display: block;
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.25;
  letter-spacing: -.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region__cities {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Count and chevron share the trailing column: the number answers "is it
   worth tapping?", the chevron says the card is a door. */
.region__end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.region__count {
  min-width: 32px;
  padding: 4px 9px;
  text-align: center;
  font-family: "Unbounded", "Onest", sans-serif;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: -.01em;
  color: var(--tone);
  background: var(--tone-tint);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(var(--tone-rgb), .16);
}
.region__count[hidden] { display: none; }

/* Regions we have not mapped yet stay tappable — the map still opens there
   and explains itself — but they should not compete for attention. */
.region.is-empty::before { opacity: .28; }
.region.is-empty .region__mark { opacity: .55; box-shadow: none; }
.region.is-empty .region__count {
  font-family: "Onest", sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
}

/* Regions that are not open yet. Unlike .is-empty these have no destination
   at all, so the card must read as inert on sight: the hover lift, the growing
   edge and the chevron are all promises of a tap that would go nowhere.
   It is a <span>, so there is no cursor or focus behaviour to undo. */
.region--soon {
  cursor: default;
  border-style: dashed;
}
.region--soon::before { opacity: .18; }
.region--soon::after  { display: none; }
.region--soon:hover {
  border-color: var(--line);
  box-shadow: none;
  transform: none;
}
.region--soon:hover::before { opacity: .18; }
.region--soon .region__mark {
  opacity: .4;
  box-shadow: none;
  filter: grayscale(.55);
}
.region--soon:hover .region__mark { transform: none; }
.region--soon .region__name   { color: var(--faint); }
.region--soon .region__cities { opacity: .6; }
.region--soon .region__count {
  font-family: "Onest", sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
}

.region__go {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--faint);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: color .18s, background .18s, border-color .18s, transform .18s var(--ease);
}
.region__go svg { width: 15px; height: 15px; }

/* The chevron picks up the card's own tone rather than the brand clay, so it
   lands with the edge that grows in beside it instead of against it. */
.region:hover .region__go {
  color: var(--surface);
  background: var(--tone);
  border-color: var(--tone);
  transform: translateX(2px);
}

/* ── noscript + footer ──────────────────────────────────── */

.pick__note {
  margin: 20px 0 0;
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.pick__foot {
  border-top: 1px solid var(--line);
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
}
.pick__foot p { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--faint); }

/* ── desktop: one screen, no scroll ─────────────────────── */

/* Above this width the page turns into a split: the hero holds the left
   column, the seven cards the right. Card metrics are tied to viewport
   height as well as width, so the grid contracts on a short laptop screen
   instead of pushing the footer off the bottom. */
@media (min-width: 940px) {
  :root { --shell: 1240px; }

  .pick { height: 100dvh; }

  /* One inset for the bar, the hero and the footer, so the three left edges
     stack. .brand keeps its own vertical padding. */
  .wrap { padding-left: 32px; padding-right: 32px; }
  .pick__bar .brand { padding-left: 32px; padding-right: 32px; }

  /* The hero takes the smaller share: seven cards with a name, a town list,
     a count and a chevron need every pixel of their column before the middle
     ones start truncating. */
  .pick__main {
    display: grid;
    grid-template-columns: minmax(280px, 30%) 1fr;
    align-items: center;
    gap: clamp(30px, 3.6vw, 56px);
    min-height: 0;
    padding-top: clamp(24px, 4vh, 52px);
    padding-bottom: clamp(24px, 4vh, 52px);
  }

  .pick__title { font-size: clamp(32px, 3.4vw, 44px); }
  .pick__lead  { max-width: 34ch; }

  /* Card metrics ride the viewport height, not just its width: on a tall
     screen the grid opens up to fill the column, on a short laptop it packs
     down instead of pushing the footer off the bottom. */
  .regions {
    margin: 0;
    gap: clamp(9px, 2.4vh, 18px);
  }

  .region {
    padding: clamp(10px, 3.2vh, 24px) 16px;
    gap: clamp(11px, 2vh, 16px);
  }

  .region__mark {
    width: clamp(38px, 7.5vh, 56px);
    height: clamp(38px, 7.5vh, 56px);
    font-size: clamp(16px, 2.8vh, 22px);
    border-radius: clamp(13px, 2.2vh, 18px);
  }

  .region::after { top: 14%; bottom: 14%; }
}

/* At a sane window height the split is guaranteed to fit, so lock the page
   down: no stray scrollbar, no half-pixel overflow wobble. Short windows
   keep their scroll rather than losing content off the bottom. */
@media (min-width: 940px) and (min-height: 600px) {
  html, body { height: 100%; overflow: hidden; }
}

/* ── narrow phones ──────────────────────────────────────── */

@media (max-width: 420px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .pick__bar .brand { padding: 11px 16px; }

  .region { gap: 12px; padding: 13px 13px; border-radius: var(--r-md); }
  .region__mark { width: 44px; height: 44px; font-size: 17px; border-radius: 13px; }
  .region__name { font-size: 15px; }
  .region__cities { font-size: 12px; }
  .region__end { gap: 8px; }
  .region__go { width: 29px; height: 29px; }
  .region__go svg { width: 14px; height: 14px; }
}

/* Very narrow phones: the town list is the first thing that can go. */
@media (max-width: 330px) {
  .region__cities { display: none; }
}
