/*! notifications.css 1.0.0 | DJ2000-UK/app-workbench */
/* In-app notifications (notifications/notifications.js): glass cards that slide
   down from the top, as on an iPhone. Every colour is one of the app's own tokens
   (--panel-bright or --panel, --ink, --muted-bright, --void, --accent or
   --accent-rgb, --danger or --health, --warning or --amber), so the cards follow
   the palette in Kaizen, Shinpo, Hokyu and djcns.css alike.

   The stack is a clear, see-through layer from 5 px below the top of the page (or
   the foot of the status bar) to the bottom. It clips what rises above its top
   line, so nothing of a card ever reaches the very top, where iOS reads the
   status bar's colour (docs/IPHONE.md). It takes no touches itself; only the
   cards do. */

.notify-stack {
  --notify-gap: 4px;   /* a card at rest, under the stack's top line (TOP_GAP in the script) */
  --notify-width: 440px;
  --notify-accent: var(--accent, rgb(var(--accent-rgb)));
  --notify-danger: var(--danger, var(--health, var(--warning)));
  --notify-warning: var(--warning, var(--amber));
  --notify-glass: color-mix(in srgb, var(--panel-bright, var(--panel)) 84%, transparent);
  --notify-spring: cubic-bezier(.2, 1.18, .32, 1);
  position: fixed;
  z-index: var(--notify-z, 400);
  inset: max(5px, env(safe-area-inset-top, 0px)) 0 0 0;
  overflow: hidden;
  pointer-events: none;
  /* The popover the stack becomes over a modal dialog: none of the browser's own look. */
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.notify-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A card: the app's icon, the words, the action. */
.notify {
  position: absolute;
  top: var(--notify-gap);
  right: 0;
  left: 0;
  box-sizing: border-box;
  display: flex;
  width: min(var(--notify-width), calc(100% - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  min-height: 62px;
  margin-inline: auto;
  padding: 9px 9px 9px 11px;
  gap: 11px;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 22px;
  background: var(--notify-glass);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--ink) 9%, transparent),
    0 14px 36px color-mix(in srgb, var(--void) 58%, transparent),
    0 2px 8px color-mix(in srgb, var(--void) 34%, transparent);
  color: var(--ink);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: -.01em;
  text-transform: none;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
  transform-origin: 50% 100%;
  will-change: transform; /* its own layer, so the glass blurs what is under it while it rests too */
  transform: translate3d(0, calc(var(--notify-y, 0px) + var(--notify-drag, 0px)), 0) scale(var(--notify-s, 1));
  transition: transform 520ms var(--notify-spring), opacity 220ms ease;
}

/* Behind the front card: only its edge shows, a little dimmer. */
.notify > * { transition: opacity 180ms ease, visibility 180ms; }
.notify:not([data-depth="0"]) {
  border-color: color-mix(in srgb, var(--ink) 16%, transparent);
  background: color-mix(in srgb, var(--panel-bright, var(--panel)) 88%, var(--ink));
}
.notify:not([data-depth="0"]) > * { opacity: 0; visibility: hidden; }
/* While the front card is lifted, the next one shows its words, ready to come forward. */
.notify-stack.is-lifting .notify[data-depth="1"] { border-color: color-mix(in srgb, var(--ink) 12%, transparent); background: var(--notify-glass); }
.notify-stack.is-lifting .notify[data-depth="1"] > :not(.notify__close) { opacity: 1; visibility: visible; }
/* Arriving: above the stack's line, out of sight; it springs down from there. Leaving: back up. */
.notify[data-state="enter"],
.notify[data-state="leave"] { transform: translate3d(0, calc(-100% - 24px), 0); }
.notify[data-state="leave"] { transition: transform 320ms cubic-bezier(.45, 0, .85, .4), opacity 320ms ease; }
.notify[data-state="fade"] { opacity: 0; transition: opacity 240ms ease, transform 240ms ease; }
.notify.is-dragging { transition: none; }

.notify__icon { position: relative; flex: 0 0 auto; width: 38px; height: 38px; }
.notify__icon img { display: block; width: 100%; height: 100%; border-radius: 9px; object-fit: cover; }
.notify--plain .notify__icon { display: none; }
.notify--plain { padding-left: 16px; }
/* "error" and "warning": a small mark on the icon, as an iPhone badges one. */
.notify__badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: none;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border: 2px solid var(--panel-bright, var(--panel));
  border-radius: 999px;
  background: var(--notify-danger);
  color: var(--void);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.notify[data-tone] .notify__badge { display: grid; }
.notify[data-tone="warning"] .notify__badge { background: var(--notify-warning); }
.notify--plain[data-tone] { box-shadow: inset 3px 0 0 var(--notify-danger), 0 14px 36px color-mix(in srgb, var(--void) 58%, transparent); }

.notify__text { display: grid; min-width: 0; flex: 1 1 auto; gap: 1px; overflow-wrap: anywhere; }
.notify__title { font-weight: 650; }
.notify__title[hidden] { display: none; }
.notify__body { font-weight: 500; }
.notify__title:not([hidden]) + .notify__body { color: var(--muted-bright); font-weight: 450; }

.notify__action {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 44px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--notify-accent) 42%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--notify-accent) 16%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  touch-action: none;
}
.notify__action[hidden] { display: none; }
.notify__action:active { background: color-mix(in srgb, var(--notify-accent) 28%, transparent); }
.notify__action:focus-visible,
.notify__close:focus-visible { outline: 2px solid var(--notify-accent); outline-offset: 2px; }

/* The round ×: with a mouse, on the card's corner while it is pointed at or has the
   focus, as on a Mac. A finger swipes or taps instead. */
.notify__close {
  position: absolute;
  top: -7px;
  left: -7px;
  display: none;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: 50%;
  background: var(--panel-bright, var(--panel));
  color: var(--muted-bright);
  cursor: pointer;
  opacity: 0;
}
.notify__close svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
@media (hover: hover) and (pointer: fine) {
  .notify__close { display: grid; }
  .notify:hover .notify__close,
  .notify:focus-within .notify__close { opacity: 1; }
  .notify { cursor: pointer; }
}

@media (min-width: 900px) {
  .notify-stack { --notify-width: 400px; inset-block-start: max(12px, env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .notify,
  .notify[data-state="leave"],
  .notify[data-state="fade"] { transition: opacity 160ms ease; }
  .notify[data-state="enter"],
  .notify[data-state="leave"] {
    opacity: 0;
    transform: translate3d(0, calc(var(--notify-y, 0px) + var(--notify-drag, 0px)), 0) scale(var(--notify-s, 1));
  }
  .notify.is-dragging { transition: none; }
}
