/* "Add it to your home screen" (Terry msg 3552): the pop-up and the steps, on both sides (templates/_pwa.html). Written against the shared
   theme tokens (shared/ui.css: Light, Dark, Navy), with plain fallbacks for a page without them. Only the way that fits this phone and
   browser shows: pwa.js sets <html data-pwa="..."> before the first paint. Nothing fades or slides. */
[data-pwa-v] { display: none; }
html[data-pwa="prompt"] [data-pwa-v~="prompt"], html[data-pwa="android"] [data-pwa-v~="android"], html[data-pwa="ios-safari"] [data-pwa-v~="ios-safari"],
html[data-pwa="ios-other"] [data-pwa-v~="ios-other"], html[data-pwa="desktop"] [data-pwa-v~="desktop"], html[data-pwa="done"] [data-pwa-v~="done"] { display: block; }
html[data-pwa="app"] [data-pwa-hide-app] { display: none !important; }   /* opened from the home screen: nothing to add */
html:not([data-pwa]) [data-pwa-hide-app] { display: none !important; }    /* no script: no buttons that can't work */

.pwa-sheet { --pwa-fg: rgb(var(--v3-fg, 21 23 28)); --pwa-fg2: rgb(var(--v3-fg-2, 91 96 112)); --pwa-fg3: rgb(var(--v3-fg-3, 130 135 150));
  --pwa-card: rgb(var(--v3-surface, 255 255 255)); --pwa-card2: rgb(var(--v3-surface-2, 244 244 246)); --pwa-line: rgb(var(--v3-line, 227 228 232));
  --pwa-accent: rgb(var(--v3-accent, 244 55 88));
  padding: 0; border: 1px solid var(--pwa-line); border-radius: 16px; background: var(--pwa-card); color: var(--pwa-fg);
  width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 18px 48px rgb(0 0 0 / .28); }
.pwa-sheet::backdrop { background: rgb(0 0 0 / .45); }
.pwa-in { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.pwa-in:focus { outline: none; }   /* opened: focus starts on the pop-up itself (Tab reaches each button), no ring on the × */
@media (max-width: 640px) {   /* a phone: a sheet from the bottom, clear of the home bar */
  .pwa-sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .pwa-in { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}
.pwa-head { display: flex; align-items: flex-start; gap: 12px; }
.pwa-icon { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.pwa-ht { flex: 1; min-width: 0; }
.pwa-ht h2 { margin: 1px 0 2px; font-size: 16px; line-height: 1.3; font-weight: 700; }
.pwa-ht p { margin: 0; font-size: 13px; color: var(--pwa-fg2); }
.pwa-x { flex: none; width: 36px; height: 36px; margin: -6px -6px 0 0; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--pwa-fg2); cursor: pointer; }
.pwa-x:hover, .pwa-x:focus-visible { background: var(--pwa-card2); color: var(--pwa-fg); }
.pwa-x svg { stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.pwa-foot { display: flex; justify-content: flex-end; }

.pwa-steps { --pwa-fg: rgb(var(--v3-fg, 21 23 28)); --pwa-fg2: rgb(var(--v3-fg-2, 91 96 112)); --pwa-fg3: rgb(var(--v3-fg-3, 130 135 150));
  --pwa-card2: rgb(var(--v3-surface-2, 244 244 246)); --pwa-line: rgb(var(--v3-line, 227 228 232)); --pwa-accent: rgb(var(--v3-accent, 244 55 88));
  font-size: 14px; line-height: 1.45; color: var(--pwa-fg); }
.pwa-steps > div { display: none; }
html[data-pwa="prompt"] .pwa-steps > [data-pwa-v~="prompt"], html[data-pwa="android"] .pwa-steps > [data-pwa-v~="android"],
html[data-pwa="ios-safari"] .pwa-steps > [data-pwa-v~="ios-safari"], html[data-pwa="ios-other"] .pwa-steps > [data-pwa-v~="ios-other"],
html[data-pwa="desktop"] .pwa-steps > [data-pwa-v~="desktop"] { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.pwa-p { margin: 0; color: var(--pwa-fg2); }
.pwa-ok { color: var(--pwa-fg); font-weight: 600; }
.pwa-fine { margin: 0; font-size: 12.5px; color: var(--pwa-fg3); }
.pwa-ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; color: var(--pwa-fg); }
.pwa-ol li::marker { color: var(--pwa-fg3); font-weight: 600; }
.pwa-key { display: inline-block; min-width: 20px; padding: 0 4px; border: 1px solid var(--pwa-line); border-radius: 6px; text-align: center; font-weight: 700; line-height: 18px; background: var(--pwa-card2); }
.pwa-k { display: inline-block; width: 15px; height: 17px; vertical-align: -3px; fill: none; stroke: var(--pwa-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pwa-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px;
  background: var(--pwa-accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; max-width: 100%; text-align: center; }
.pwa-btn-2 { background: var(--pwa-card2); color: var(--pwa-fg); border: 1px solid var(--pwa-line); }
.pwa-btn:focus-visible, .pwa-x:focus-visible { outline: 2px solid var(--pwa-accent); outline-offset: 2px; }
.pwa-btn[hidden], .pwa-ol[hidden] { display: none; }

/* the small picture of Safari's Share, then Add to Home Screen */
.pwa-pic { width: 100%; max-width: 280px; height: auto; display: block; }
.pwa-pic .pp-bar, .pwa-pic .pp-row { fill: var(--pwa-card2); stroke: var(--pwa-line); stroke-width: 1.5; }
.pwa-pic .pp-row { stroke: var(--pwa-accent); stroke-width: 2; }
.pwa-pic .pp-ic, .pwa-pic .pp-ic * { fill: none; stroke: var(--pwa-fg3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pwa-pic g.pp-ic:first-of-type * { stroke: var(--pwa-accent); }
.pwa-pic .pp-ring { fill: none; stroke: var(--pwa-accent); stroke-width: 2.5; }
.pwa-pic .pp-arrow { fill: none; stroke: var(--pwa-fg3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pwa-pic .pp-txt { fill: var(--pwa-fg); font: 600 14px system-ui, -apple-system, "Segoe UI", sans-serif; }

/* the creator's Account card holding the steps */
.pwa-card { padding: 14px; }

/* ---- The notch and the home bar (Terry msg 3644: "the white space at the top: the colour just fills the space"). Opened from the home
   screen, an iPhone draws its clock over the page (black-translucent + viewport-fit=cover: templates/_pwa_head.html), so the page's own
   colour fills that space instead of a white band. The clock is always white, so what sits behind it is always dark:
   - Dark and Navy: the top bar grows by the notch and paints it in its own colour (the brand side's .ds-top; the creator's .cd-top already
     pads itself), and a strip of that same colour keeps anything scrolling past from showing under the clock;
   - Light: the strip is the brand's navy, so the time stays readable over a light page.
   Pages without either top bar (sign-in, the public pages) move down by the notch. Only inside the app (html[data-pwa="app"], set by pwa.js
   before the first paint): Safari itself looks exactly as before. */
html[data-pwa="app"] { --pwa-top: env(safe-area-inset-top, 0px); }
html[data-pwa="app"] body::after { content: ""; position: fixed; z-index: 2147482999; top: 0; left: 0; right: 0; height: var(--pwa-top);
  background: #0E1A25; pointer-events: none; }
/* Dark and Navy: the strip is the top bar's own colour (the brand side's phone bar is its card colour; wider, the page's) */
html[data-pwa="app"][data-theme="dark"] body::after, html[data-pwa="app"][data-theme="navy"] body::after { background: rgb(var(--v3-surface)); }
@media (min-width: 768px) { html[data-pwa="app"][data-theme="dark"] body::after, html[data-pwa="app"][data-theme="navy"] body::after { background: rgb(var(--v3-bg)); } }
/* the creator side and the other pages: the page's own colour (the creator's top bar is the page colour) */
html[data-pwa="app"][data-cw-theme="dark"] body::after, html[data-pwa="app"][data-cw-theme="navy"] body::after { background: inherit; }
@media (prefers-color-scheme: dark) { html[data-pwa="app"]:not([data-theme]):not([data-cw-theme]) body::after { background: inherit; } }
/* the brand side's top bar starts under the clock and keeps its own height below it (it stays at the top as the page scrolls) */
html[data-pwa="app"] .ds-top { height: calc(48px + var(--pwa-top)); padding-top: var(--pwa-top); }
@media (min-width: 768px) {
  html[data-pwa="app"] .ds-top { height: calc(52px + var(--pwa-top)); padding-top: calc(8px + var(--pwa-top)); }
  html[data-pwa="app"] .ds-top::before { top: calc(8px + var(--pwa-top)); }
  html[data-pwa="app"] .ds-top::after { height: calc(7px + var(--pwa-top)); }
  html[data-pwa="app"] .ds-side { padding-top: var(--pwa-top); }   /* an iPad: the sidebar starts under the clock too */
}
/* bars that stay put just under the top bar move down with it */
html[data-pwa="app"] :is(.crp-chips, .cc-sbar, .ct-head) { top: calc(52px + var(--pwa-top)); }
html[data-pwa="app"] .de-bar { top: calc(60px + var(--pwa-top)); }
@media (max-width: 480px) { html[data-pwa="app"] .de-bar { top: calc(52px + var(--pwa-top)); } }
/* a page with neither top bar: everything moves down by the notch */
html[data-pwa="app"]:not(:has(.ds-top, .cd-top)) { padding-top: var(--pwa-top); }
/* the bottom: the brand side's phone tab bar grows by the home bar (its buttons stay their full height above it) */
html .ds-tabbar { height: calc(3.5rem + env(safe-area-inset-bottom, 0px)); }
/* the phone's More sheet rises from the bottom: its last row stays above the home bar */
html [data-more-sheet] { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
