/* ===========================================================================
   alerts.css — price alerts (alerts.js, alerts-form.js, alerts-push.js):
   the bell in the top bar and its count, the inbox it opens (a popover; a
   sheet from the bottom on a phone, popover.js), the Manage alerts dialog,
   the card dialog's "Price alerts" block and Preferences' part.

   Quiet on purpose: the bell is one more icon button until something is
   unread, and then only its count is coloured. Up and down are the Insights
   page's green and rose (4.5:1 or better as text in either theme). The only
   motion is the count arriving (a short pop, at Full only).
   =========================================================================== */

:root {
  --al-up: #34d399;
  --al-down: #fb7185;
}
:root[data-theme="light"] {
  --al-up: #047857;
  --al-down: #be123c;
}

/* ------------------------------------------------------------------ the bell */
.bell-btn { position: relative; }
.bell-btn svg { transition: transform var(--t-2) var(--ease-spring); }
.bell-btn.has-unread svg { color: var(--ink); }
.bell-count {
  position: absolute; top: -3px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--accent-fill); color: var(--accent-ink);
  font-size: 10.5px; font-weight: 750; line-height: 1; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg-2);
  pointer-events: none;
  animation: al-count-in var(--t-2) var(--ease-spring);
}
@keyframes al-count-in { from { transform: scale(.4); opacity: 0; } }
:root:not([data-motion="full"]) .bell-count { animation: none; }
.bell-btn[aria-expanded="true"] { background: var(--bg-3); border-color: color-mix(in srgb, var(--ink) 18%, var(--line)); }

/* ------------------------------------------------------------- the inbox */
.popover.al-pop {
  width: min(400px, calc(100vw - 16px));
  max-height: min(600px, calc(100dvh - 72px));
  padding: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
/* As a sheet it spans the screen like every other (the popover width above would
   otherwise leave it pinned left with a gap on the right). */
.popover.al-pop.is-sheet { width: 100%; max-height: 82dvh; padding: 0 0 env(safe-area-inset-bottom, 0px); }
.al-inbox { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.al-head {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 12px 10px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.al-title { margin: 0 auto 0 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.al-list {
  list-style: none; margin: 0; padding: 6px;
  overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1;
}
.al-list > li + li { margin-top: 2px; }

.al-item {
  width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) 10px; align-items: center; gap: 12px;
  padding: 9px 10px; border: 0; border-radius: 12px;
  background: transparent; text-align: left; cursor: pointer;
  transition: background var(--t-1) var(--ease-out);
}
.al-item:hover { background: var(--bg-3); }
.al-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.al-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.al-item-title { font-size: 13.5px; font-weight: 550; color: var(--ink-2); overflow-wrap: anywhere; }
.al-item.is-unread .al-item-title { font-weight: 700; color: var(--ink); }
.al-item-line { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.al-item.is-up .al-item-line::before, .al-item.is-down .al-item-line::before {
  display: inline-block; margin-right: 5px; font-weight: 800;
}
.al-item.is-up .al-item-line::before { content: "↑"; color: var(--al-up); }
.al-item.is-down .al-item-line::before { content: "↓"; color: var(--al-down); }
.al-item-time { font-size: 11px; color: var(--ink-3); }
.al-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }

/* A card's art, a binder's cover, or the bell. */
.al-thumb {
  width: 40px; height: 40px; flex: none; border-radius: 9px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--bg-3); color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.al-thumb.is-card { width: 32px; height: 45px; margin: 0 4px; border-radius: 4px; background: var(--pocket); box-shadow: var(--shadow-1); }
.al-thumb.is-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.al-thumb.is-binder {
  width: 32px; height: 40px; margin: 0 4px; border-radius: 3px 7px 7px 3px;
  background: linear-gradient(90deg, color-mix(in srgb, #000 28%, var(--cover)) 0 5px, var(--cover) 5px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), var(--shadow-1);
}
.al-bell-ico { display: inline-flex; }

.al-skel { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; padding: 9px 10px; }
.al-skel-line { height: 30px; }
.al-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 28px 22px 26px; color: var(--ink-3); font-size: 13px;
}
.al-empty b { color: var(--ink); font-size: 14px; }
.al-empty-ico {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 4px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-3)); color: var(--accent-text);
}
.al-empty-ico svg { width: 20px; height: 20px; }
.al-older { align-self: center; margin: 2px 0 8px; }

/* The inbox's foot: the offer of notifications on this device (or why not). */
.al-push.is-compact {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 11px 16px 13px; border-top: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.al-push.is-compact .al-push-text { margin: 0; flex: 1 1 180px; font-size: 12.5px; color: var(--ink-2); }
.al-push:not(.is-compact) { display: flex; flex-direction: column; gap: 8px; }
.al-push-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------- the form */
.al-form {
  display: flex; flex-direction: column; gap: 9px;
  padding: 12px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--glass-edge);
}
.al-form-label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.al-form-label .input { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13.5px; color: var(--ink); }
.al-kinds { max-width: 100%; }
.al-kinds .seg-opt { height: 28px; padding: 0 11px; font-size: 12.5px; }
.al-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.al-sym { color: var(--ink-2); font-weight: 650; min-width: 1ch; text-align: right; }
.al-unit { color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.al-amount { width: 130px; }
.al-pct { width: 84px; }
.al-select { width: auto; flex: 0 1 auto; }
.al-hint { min-height: 1.45em; }
.al-form-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------------------------ the card dialog's block */
.al-watch {
  display: flex; flex-direction: column; gap: 9px;
  padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.al-watch-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.al-watch-head h3 {
  margin: 0; font-size: var(--fs-micro); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-text);
}
.al-watch-head .btn { gap: 6px; }
.al-watch-list { display: flex; flex-direction: column; gap: 6px; }
.al-watch-item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px;
  padding: 8px 8px 8px 12px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--glass-edge);
}
.al-watch-item.is-paused .al-watch-text { opacity: .55; }
.al-watch-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 180px; }
.al-watch-text b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.al-watch-text span { font-size: 12px; color: var(--ink-3); }
.al-row-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }
.al-row-actions .btn { height: 26px; padding: 0 9px; font-size: 12px; }

/* ------------------------------------------------------------ Manage alerts */
.modal.modal-alerts { width: min(640px, 100%); display: flex; flex-direction: column; }
.al-manage { display: flex; flex-direction: column; min-height: 0; }
.al-count { margin: 6px 0 0 !important; font-size: 12px !important; color: var(--ink-3) !important; font-variant-numeric: tabular-nums; }
.al-manage-body { display: flex; flex-direction: column; gap: 20px; }
.al-msec { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.al-msec > * { align-self: stretch; }
.al-msec > .btn { align-self: flex-start; gap: 6px; }
.al-msec h3 {
  margin: 0; font-size: var(--fs-micro); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-text);
}
.al-mlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.al-mrow {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 10px 10px 12px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--glass-edge);
}
.al-mrow.is-editing { display: flex; flex-direction: column; gap: 6px; padding: 0; border: 0; background: none; box-shadow: none; }
.al-edit-name { padding: 0 2px; }
.al-mrow.is-paused .al-mrow-text, .al-mrow.is-paused .al-thumb { opacity: .55; }
.al-mrow-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.al-mrow-name { font-size: 13.5px; font-weight: 650; overflow-wrap: anywhere; }
.al-mrow-sub { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.al-mrow-cond { font-size: 13px; font-weight: 650; color: var(--gold-text); font-variant-numeric: tabular-nums; }
.al-mrow-status { font-size: 12px; color: var(--ink-2); }
.al-newbinder { display: flex; flex-direction: column; gap: 10px; }
.al-newbinder > .al-form-label { max-width: 360px; }
.al-rules { max-width: 68ch; }

/* ------------------------------------------------------------- Preferences */
.al-prefs .al-push .form-help { max-width: 58ch; }

/* ------------------------------------------------------------------ phones */
@media (max-width: 640px) {
  .al-head { padding: 14px 12px 10px 16px; }
  .al-head .btn { height: 32px; }
  .al-item { padding: 11px 10px; }
  .al-mrow { grid-template-columns: 40px minmax(0, 1fr); }
  .al-mrow > .al-row-actions { grid-column: 1 / -1; justify-content: flex-end; margin-left: 0; }
  .al-kinds { display: flex; width: 100%; }
  .al-kinds .seg-opt { flex: 1 1 0; justify-content: center; padding: 0 6px; }
  .al-amount { flex: 1 1 120px; width: auto; }
}
@media (hover: none) {
  .al-row-actions .btn { height: 32px; padding: 0 11px; }
}
