/* The first-run walkthrough (onboarding.js): a layer over the whole app, every step the same shape.
   Statement, why, then the action, which scrolls inside the step on a phone. Rows are the app's
   .rows/.row, the map its .smap.big. From 1024px (desktop.css) it's a centred column instead of the
   whole window, and the map step sets the map beside its rows. */
.ob {
  position: fixed; inset: 0; z-index: calc(var(--z-toast) - 1);
  touch-action: pan-x pan-y;      /* scrolls, but doesn't pinch or double-tap zoom (the map handles its own drags) */
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--page); color: var(--text-1);
  container-type: size;
}
/* nothing under the layer scrolls, bounces or pulls to refresh: a swipe on a step that has nothing to
   scroll would otherwise reach the page, and Safari's toolbar and refresh spinner answer it */
html:has(body.ob-open), body.ob-open { overflow: hidden; overscroll-behavior: none; }
/* the app under it isn't drawn at all: iOS's bar over the keyboard is see-through, and the page slides
   under a fixed layer as the keyboard comes, so any of it could show */
body.ob-open > :not(.ob, #toast) { visibility: hidden; opacity: 0; }   /* opacity too: a child's own visibility: visible can't undo it */
/* an error from a save or a follow still shows, over the layer */
body.ob-open .toast { bottom: 0; padding-bottom: calc(6px + var(--sab)); z-index: var(--z-toast); }

/* ---- header: Back, and the progress line */
.ob-top { position: relative; z-index: 2; padding-top: var(--sat); background: var(--page); }
.ob-nav { display: flex; align-items: center; height: 52px; padding: 0 var(--gut); }
.ob-back { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 44px; margin-left: -4px; color: var(--text-2); transition: color 150ms ease; }
.ob-back::before { content: ""; position: absolute; inset: 0 -10px; }
.ob-back:active { color: var(--text-1); }
.ob-prog { display: grid; grid-template-columns: repeat(var(--steps, 4), 1fr); gap: 4px; padding: 0 var(--gut) 12px; }
.ob-prog i { height: 2px; background: var(--line); transition: background-color 200ms var(--ease-out); }
.ob-prog i:nth-child(1),
.ob:not([data-step="0"]) .ob-prog i:nth-child(2),
.ob:is([data-step="2"], [data-step="3"], [data-step="4"]) .ob-prog i:nth-child(3),
.ob:is([data-step="3"], [data-step="4"]) .ob-prog i:nth-child(4),
.ob[data-step="4"] .ob-prog i:nth-child(5) { background: var(--text-1); }

/* ---- a step: the same head every time, then its action */
/* a step scrolls as one page under Back and the progress line: its heading goes up with its list */
.ob-panel { grid-row: 2; grid-column: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.ob-panel[hidden] { display: none; }
.ob-panel { padding-bottom: var(--kb, 0px); }   /* the keyboard's height, so the last results scroll up above it */
.ob-panel.in-r { animation: ob-in-r 200ms var(--ease-out); }
.ob-panel.in-l { animation: ob-in-l 200ms var(--ease-out); }
@keyframes ob-in-r { from { opacity: 0; translate: 20px 0; } }
@keyframes ob-in-l { from { opacity: 0; translate: -20px 0; } }
.ob-head { flex: none; padding: 12px var(--gut) 24px; }
.ob-head h1 { margin: 0; max-width: 14em; overflow-wrap: anywhere; }
.ob-head h1:focus { outline: none; }   /* focused so a screen reader starts there, not to show it */
.ob-why { margin: 10px 0 0; color: var(--text-2); font-size: 15px; line-height: 22px; max-width: 40ch; text-wrap: pretty; }
.ob-panel[data-step="0"] .ob-why { max-width: 48ch; }   /* the landing page's three lines, a line each where there's room */
.ob-body { flex: none; padding-bottom: 24px; }
.ob-sec { margin: 0; padding: 0 var(--gut) 8px; color: var(--text-3); }
.ob-list + .ob-sec { margin-top: 24px; }
.ob-msg { margin: 0; padding: 16px var(--gut); color: var(--text-2); font-size: 14px; line-height: 20px; text-wrap: pretty; overflow-wrap: anywhere; }

/* ---- 00: the welcome and the inviter's note */
.ob-hi { margin: 0 0 12px; color: var(--text-2); font-size: 17px; line-height: 26px; letter-spacing: -.011em; overflow-wrap: anywhere; }
/* the inviter's message, as one received: on the well, signed under it with their initial and name */
.ob-note { margin: 16px var(--gut) 0; }
.ob-note blockquote { margin: 0; padding: 14px 16px; background: var(--well); font-size: 16px; line-height: 24px; color: var(--text-1); overflow-wrap: anywhere; text-wrap: pretty; }
.ob-note figcaption { margin-top: 10px; text-align: right; color: var(--text-2); font-size: 15px; line-height: 20px; }   /* signed, as a note is */

/* ---- 02: search */
.ob-search { display: flex; align-items: center; gap: 8px; padding: 0 var(--gut) 12px; }
.ob-search .search-field { flex: 1; min-width: 0; }
.ob-done { position: relative; flex: none; height: 44px; padding: 0 0 0 8px; color: var(--text-1); }
.ob-done[hidden] { display: none; }
/* searching on a phone: the field at the top with Done, the results below it; no heading, no footer */
@media (max-width: 1023px) {
  .ob.searching [data-step="2"] .ob-head, .ob.searching .ob-mine, .ob.searching .ob-foot { display: none; }
  .ob.searching .ob-nav, .ob.searching .ob-prog { display: none; }
  /* the app's search band: 12px round the field, a rule under it */
  .ob.searching .ob-search { position: sticky; top: 0; z-index: 1; padding: 12px var(--gut); background: var(--page); border-bottom: 1px solid var(--line); }
}
.ob-res:empty { display: none; }
.ob-try { display: grid; gap: 12px; padding: 16px var(--gut) 24px; }
.ob-try[hidden] { display: none; }
.ob-try .hint { margin: 0; }

/* ---- 03: the map on top, square, as big as the screen allows with four rows under it; no scroll */
/* on a phone the step fits the screen: the map is the width of the page and takes the height the heading,
   the genre line and three rows leave, so it needn't be square (it places dots and reads drags on both
   axes, and measures itself on resize). Only a screen too short for its smallest scrolls */
.ob-map-box { flex: 1 1 0; min-height: 220px; display: flex; flex-direction: column; padding: 0 var(--gut) 12px; }
.ob-map-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ob-map.smap.big { flex: 1; min-height: 0; margin: 0; width: 100%; aspect-ratio: auto; }
/* the glow is a square twice the map's width, centred on the ring: the app's sizes it by the map's height
   too, and a top margin in % is of the width, so on a map wider than tall it sat away from the ring */
.ob-map.smap.big .glow { height: auto; aspect-ratio: 1; }
.ob-near-g { padding: 10px 0 0; }
.ob-near-g > span { white-space: normal; overflow: visible; }   /* every genre, wrapping if it must, none cut off */
.ob-map.dragging .stag, .ob-map.dragging .lb { transition: none; }
.ob-map .pin { z-index: 1; }
.ob-near { flex: none; }
.ob-near .row .t { -webkit-line-clamp: 1; }

/* ---- 04 (iPhone): the Home Screen */
.ob-how { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ob-how li { display: flex; align-items: flex-start; gap: 12px; padding: 14px var(--gut); border-bottom: 1px solid var(--line-faint); font-size: 15px; line-height: 22px; }
.ob-n { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--line-control); color: var(--text-2); }
.ob-key { display: inline-flex; vertical-align: -3px; }
.ob-key svg { width: 18px; height: 18px; }
.ob-note-s { margin: 0; padding: 16px var(--gut); font-size: 14px; line-height: 20px; color: var(--text-2); max-width: 46ch; text-wrap: pretty; }

/* ---- rows: the app's, centred, with one control at the end instead of the options button */
.ob-list { border-top: 1px solid var(--line); }
.ob-row { align-items: center; padding-right: var(--gut); }
.ob-row > .art { margin-top: 0; }
.ob-row .mast { font-variant-numeric: tabular-nums; }

/* a labelled toggle: an outlined mono word, an ink slab once on; 44px to tap, 32 to see */
.ob-tog {
  position: relative; flex: none; display: grid; place-items: center; min-width: 64px; height: 32px; padding: 0 8px;
  font-size: 11px; letter-spacing: .03em; color: var(--text-1); border: 1px solid var(--line-control);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, scale 150ms var(--ease-out);
}
.ob-tog[data-tog="dj"], .ob-tog[data-tog="show"] { min-width: 92px; }
.ob-tog::before { content: ""; position: absolute; inset: -6px -3px; }
.ob-tog[aria-pressed="true"] { background: var(--ink-bg); border-color: var(--ink-bg); color: var(--ink-fg); }
.ob-tog:active { scale: .96; }
.ob-tog:focus-visible { outline: 2px solid var(--text-1); outline-offset: 2px; }

/* ---- footer */
.ob-foot { padding: 12px var(--gut) calc(12px + var(--sab)); background: var(--page); border-top: 1px solid var(--line); }
.ob-later { display: block; width: 100%; height: 44px; margin-top: 4px; color: var(--text-2); }
.ob-later[hidden] { display: none; }
.sheet .ob-how { margin: 0 calc(-1 * var(--gut)); }   /* the steps run edge to edge in a sheet, as rows do */
.ob-go { height: 48px; font-variant-numeric: tabular-nums; }
.ob-go:focus-visible { outline: 2px solid var(--text-1); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .ob-back:hover { color: var(--text-1); }
  .ob-tog[aria-pressed="false"]:hover { background: var(--hover); }
}

/* ---- a wide window: one column down the middle of the page, the footer's button where the step ends.
   The whole layer scrolls, not each list, so the lists run as long as they are; the header stays. */
@media (min-width: 1024px) {
  .ob {
    --ob-w: 560px;
    grid-template-rows: auto auto auto; grid-template-columns: minmax(0, var(--ob-w));
    justify-content: center; align-content: start;
    overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--gut) 64px;
  }
  .ob[data-step="3"] { --ob-w: calc(440px + 32px + 440px + 2 * var(--gut)); }
  .ob-top { position: sticky; top: 0; padding-top: max(var(--sat), 24px); }
  .ob-panel, .ob-body, .ob-near { overflow: visible; }
  .ob-panel { min-height: auto; }
  .ob-body, .ob-near { flex: none; }   /* full length: the layer scrolls, so nothing squeezes a list under the button */
  .ob-head { padding-top: 24px; }
  .ob-body { padding-bottom: 8px; }
  .ob-foot { grid-row: 3; padding: 24px var(--gut) 0; border-top: 0; background: none; }
  .ob-go.btn-block { width: auto; min-width: 200px; padding: 0 24px; }

  /* the map step: the map on the left, at 440, and the heading and the four nearest on the right */
  .ob-mapstep:not([hidden]) {
    display: grid; grid-template-columns: calc(440px + var(--gut)) minmax(0, 1fr); grid-template-rows: auto auto 1fr;
    column-gap: 32px; align-items: start;
  }
  .ob-mapstep .ob-head { grid-column: 2; grid-row: 1; }
  .ob-map-box { grid-column: 1; grid-row: 1 / span 3; padding: 24px 0 0 var(--gut); }
  .ob-map-wrap { width: 440px; display: block; }
  .ob-map.smap.big { aspect-ratio: 1; }      /* square beside the list, where there's room for it */
  .ob-mapstep .ob-near { grid-column: 2; grid-row: 2 / span 2; }
  .ob[data-step="3"] .ob-foot { padding-left: calc(440px + 32px + 2 * var(--gut)); }
}

@media (prefers-reduced-motion: reduce) {
  .ob-panel.in-r, .ob-panel.in-l { animation: none; }
  .ob-prog i, .ob-tog, .ob-back { transition: none; }
}
