/* Feel: how the brand moves and answers. Import after tokens.css, before a page's own styles.
   Behaviour only: no colours of its own, no type sizes, no layout, so it's safe on any page.
   Everything here is progressive: a browser that lacks a feature simply skips it, and under
   reduced motion everything still works, it just doesn't move.

   The five rules:
   1. Answer at once. A press shows within a frame; nothing waits for an animation to finish.
   2. Settle, don't perform. Short travel (8px), ease-out, one time. Nothing loops or bounces.
   3. Leave faster than you came. Exits are quieter than entrances.
   4. Same place, same way back. A sheet that rises from the bottom goes back down.
   5. Say it quietly. Confirmations whisper and fade; they never block the page. */

/* ---------- Reading ---------- */
:where(h1, h2, h3, h4) { text-wrap: balance; }
:where(p, li, dd, figcaption, blockquote) { text-wrap: pretty; }
::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); color: inherit; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
:where([id]) { scroll-margin-top: 16px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---------- Touch ---------- */
:where(button, a, summary, label, [role="button"]) { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:where(summary, [role="button"], label[for]) { cursor: pointer; }
:where(input, select, textarea) { font-size: max(16px, 1em); } /* 16px or more: iPhone doesn't zoom in on focus */

/* Press: everything tappable gives a little under the finger, straight away */
:where(button, .btn, [role="button"], .press) {
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-quick), border-color var(--dur-quick),
    color var(--dur-quick), box-shadow var(--dur-quick), opacity var(--dur-quick);
}
:where(button, .btn, [role="button"], .press):not(:disabled, [aria-disabled="true"]):active { transform: scale(var(--press-scale)); }

/* Hover lifts only where there's a real pointer, so a phone never keeps a "stuck" hover after a tap.
   Use .lift on cards and tiles that open something. */
@media (hover: hover) and (pointer: fine) {
  :where(.lift) { transition: transform var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick), border-color var(--dur-quick); }
  :where(.lift):hover { transform: translateY(-1px); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 14%, transparent); }
}

/* ---------- Folds (<details>) ---------- */
/* Open and close smoothly where the browser can animate to auto height; elsewhere they simply open. */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  details::details-content {
    block-size: 0; overflow-y: clip; opacity: 0;
    transition: block-size var(--dur-base) var(--ease-out), opacity var(--dur-quick) var(--ease-out),
      content-visibility var(--dur-base) allow-discrete;
  }
  details[open]::details-content { block-size: auto; opacity: 1; }
}
/* A chevron that turns with the fold: <summary>Title <span class="chev" aria-hidden="true"></span></summary> */
.chev { display: inline-block; width: .5em; height: .5em; margin-left: .4em; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: translateY(-.15em) rotate(45deg); transition: transform var(--dur-quick) var(--ease-out); opacity: .7; }
details:not([open]) > summary .chev { transform: translateY(0) rotate(-45deg); }

/* ---------- Arriving ---------- */
/* Content that loads (from the API, after a choice) fades in rather than popping. */
.appear { animation: feel-appear var(--dur-base) var(--ease-out) both; }
@keyframes feel-appear { from { opacity: 0; transform: translateY(calc(var(--rise) / 2)); } }
/* First-load entrances, once, as each part scrolls into view: brand.js adds .is-in */
.reveal { opacity: 0; transform: translateY(var(--rise)); transition: opacity var(--dur-settle) var(--ease-out), transform var(--dur-settle) var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }
/* Siblings arriving together: a short stagger, capped so the last never waits long. Set --i on each (0, 1, 2…). */
.reveal.is-in, .appear { transition-delay: calc(min(var(--i, 0), 5) * 40ms); animation-delay: calc(min(var(--i, 0), 5) * 40ms); }

/* Waiting: calm placeholder lines the shape of what's coming. Still, no shimmer. */
.hush { display: block; height: .9em; margin: .45em 0; max-width: var(--w, 100%); background: color-mix(in srgb, var(--text) 8%, transparent); }

/* Moving between pages (dashboard, Japan, Town): a soft cross-fade instead of a white flash. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: var(--dur-quick); }
::view-transition-new(root) { animation-duration: var(--dur-base); }

/* ---------- Sheets ---------- */
/* <div class="sheet" hidden><div class="sheet-veil"></div><div class="sheet-card" role="dialog">…</div></div>
   Rises from the bottom on a phone, settles in the middle on a computer, leaves the way it came. brand.js opens it. */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-veil { position: absolute; inset: 0; background: var(--veil); opacity: 0; transition: opacity var(--dur-quick) var(--ease-out); }
.sheet-card { position: relative; width: min(560px, 100%); max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--bg); box-shadow: var(--lift); padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform var(--dur-quick) var(--ease-in-out); }
.sheet.is-open .sheet-veil { opacity: 1; transition-duration: var(--dur-base); }
.sheet.is-open .sheet-card { transform: none; transition: transform var(--dur-calm) var(--ease-out); }
@media (min-width: 701px) {
  .sheet { align-items: center; }
  .sheet-card { max-height: 80vh; transform: translateY(var(--rise)); opacity: 0; transition: transform var(--dur-quick), opacity var(--dur-quick); }
  .sheet.is-open .sheet-card { opacity: 1; transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
}
html:has(.sheet.is-open) { overflow: hidden; }

/* ---------- Whisper: a quiet confirmation ("Saved", "Moved to Done · Undo") ---------- */
/* brand.js makes it: Brand.whisper("Saved") or Brand.whisper("Removed", { undo: () => … }) */
.whisper { position: fixed; left: 50%; bottom: calc(var(--whisper-bottom, 24px) + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: var(--space-3); width: max-content; max-width: calc(100vw - 32px); padding: 10px 16px;
  background: var(--text); color: var(--bg); font-size: var(--step--1); box-shadow: var(--lift);
  transform: translate(-50%, var(--rise)); opacity: 0; pointer-events: none;
  transition: transform var(--dur-quick) var(--ease-out), opacity var(--dur-quick) var(--ease-out); }
.whisper.is-in { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; transition-duration: var(--dur-base); }
.whisper button { background: none; border: 0; padding: 4px 0; min-height: 0; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Edges ---------- */
:where(.scroll-x) { overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; }
:where(.scroll-x) > * { scroll-snap-align: start; }
:where(.scroll-x)::-webkit-scrollbar { display: none; }

/* ---------- Reduced motion: everything still works, nothing travels ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .reveal { opacity: 1; transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  :where(button, .btn, [role="button"], .press):active { transform: none; }
}
