/*
 * Dealnite alerts. Loaded only on the preview page, never on production.
 * Uses the paper theme tokens from body.paper in Base.astro.
 */

.dn-hidden,
[hidden].dn-row,
[hidden].dn-done,
[hidden].dn-sheet-install,
[hidden].dn-sheet-safari,
[hidden].dn-step-more,
[hidden].dn-copy-field,
[hidden].dn-sheet-aside,
[hidden].dn-panel,
[hidden].dn-sheet { display: none !important; }

/* ------------------------------------------------------------------ */
/* Bell button in the controls row                                     */
/* ------------------------------------------------------------------ */

.dn-bell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.dn-bell:hover { border-color: var(--ink-3); color: var(--ink); }
.dn-bell[aria-expanded='true'] { border-color: var(--ink); color: var(--ink); }

.dn-bell svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Off: red, gently pulsing, with a "!" badge, so it is the first thing seen.
   On: a calm blue that stays put. Until alerts.js has checked which one this
   device is, the button keeps its neutral look so nobody sees a red flash. */
.dn-bell { position: relative; }

.dn-bell-alert {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #d93025;
  color: #fff;
  border: 2px solid var(--paper);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 13px;
  text-align: center;
}

.dn-bell.is-off {
  color: #fff;
  background: #d93025;
  border-color: #d93025;
  font-weight: 600;
  animation: dn-pulse 2s ease-out infinite;
}
.dn-bell.is-off:hover { color: #fff; background: #c5221f; border-color: #c5221f; }
.dn-bell.is-off .dn-bell-alert { display: block; background: #fff; color: #d93025; border-color: #d93025; }
.dn-bell.is-off svg { animation: dn-ring 4s ease-in-out infinite; transform-origin: 50% 10%; }

.dn-bell.is-on {
  color: #1d5fa8;
  background: #edf4fc;
  border-color: #b9d3ef;
}
.dn-bell.is-on:hover { color: #174e8c; border-color: #8fb7e3; }
.dn-bell.is-on[aria-expanded='true'] { border-color: #1d5fa8; }
.dn-bell.is-on .dn-bell-count { background: #1d5fa8; color: #fff; }

@keyframes dn-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(217, 48, 37, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0); }
}

@keyframes dn-ring {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(14deg); }
  90% { transform: rotate(-12deg); }
  94% { transform: rotate(8deg); }
  97% { transform: rotate(-4deg); }
}

.dn-bell-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.dn-bell:focus-visible,
.dn-btn:focus-visible,
.dn-link:focus-visible,
.dn-kw button:focus-visible,
.dn-close:focus-visible {
  outline: 2px solid var(--deal);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.dn-btn {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.dn-btn:hover { opacity: 0.88; }
.dn-btn[disabled] { opacity: 0.5; cursor: progress; }

.dn-btn.is-quiet {
  color: var(--ink-2);
  background: transparent;
  border-color: var(--line);
  font-weight: 500;
}

.dn-btn.is-quiet:hover { border-color: var(--ink-3); color: var(--ink); opacity: 1; }

.dn-link {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--ink-3);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dn-link:hover { color: var(--ink); }

/* ------------------------------------------------------------------ */
/* "Create alert" row under the search bar                             */
/* ------------------------------------------------------------------ */

.dn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 11px 12px 11px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.dn-row > svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--deal);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dn-row-copy {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--ink-2);
}

.dn-row-copy strong { color: var(--ink); font-weight: 600; }

.dn-row-count {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--ink-3);
}

.dn-row.is-set { border-color: var(--ink-3); }

/* ------------------------------------------------------------------ */
/* Success, in place of the row, right after an alert is created       */
/* ------------------------------------------------------------------ */

.dn-done {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px 12px 12px 14px;
  background: #f0f7f2;
  border: 1px solid #b7dbc2;
  border-radius: 10px;
}

.dn-done > svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #2f7a4a;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dn-done-copy {
  flex: 1 1 220px;
  min-width: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--ink-2);
}

.dn-done-copy strong { display: block; color: var(--ink); font-weight: 600; }

.dn-done-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dn-done .dn-btn.is-quiet { background: #fff; }

/* ------------------------------------------------------------------ */
/* Alerts panel                                                        */
/* ------------------------------------------------------------------ */

.dn-panel {
  margin: 12px 0 0 auto;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 14px;
}

.dn-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dn-panel-head h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.dn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--ink-3);
}

.dn-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.dn-status.is-on { color: var(--ink-2); }
.dn-status.is-on::before { background: #3f8f5a; }

.dn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: -6px -8px -6px 0;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--ink-3);
  cursor: pointer;
}

.dn-close:hover { background: var(--paper-2); color: var(--ink); }

.dn-close svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.dn-panel p.dn-lead {
  margin-top: 10px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.dn-panel .dn-btn.is-wide { margin-top: 14px; }

.dn-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
}

.dn-section-title {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 9px;
}

.dn-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.dn-toggle input {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  accent-color: var(--ink);
  cursor: pointer;
}

.dn-toggle span { font-size: 0.84rem; color: var(--ink); line-height: 1.4; }
.dn-toggle small { display: block; font-size: 0.74rem; color: var(--ink-3); margin-top: 2px; }

.dn-kws {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.dn-kw {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 4px 3px 11px;
}

.dn-kw button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--ink-3);
  cursor: pointer;
}

.dn-kw button:hover { background: var(--line); color: var(--ink); }

.dn-kw svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.dn-empty { font-size: 0.8rem; line-height: 1.5; color: var(--ink-3); }

.dn-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dn-msg {
  margin-top: 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink);
}

.dn-msg:empty { display: none; }
.dn-msg.is-error { color: var(--deal); }

/* "Alerts Dashboard" button at the foot of the homepage panel. */
.dn-dash {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  text-decoration: none;
}

.dn-dash svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dn-note {
  margin-top: 12px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ */
/* iPhone install sheet                                                */
/* ------------------------------------------------------------------ */

.dn-sheet {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dn-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.46);
}

.dn-sheet-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--paper);
  border-radius: 16px;
  padding: 22px 22px 20px;
  box-shadow: 0 18px 50px rgba(20, 16, 12, 0.22);
}

.dn-sheet-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.015em;
  padding-right: 30px;
}

.dn-sheet-card > .dn-close {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
}

.dn-sheet-sub {
  margin-top: 8px;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.dn-sheet-aside {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--paper-2);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.dn-steps {
  list-style: none;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dn-steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
}

.dn-step-n {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.8rem;
  font-weight: 700;
}

.dn-steps strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  padding-top: 3px;
}

.dn-steps span.dn-step-more {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* Inline glyphs that look like the buttons being described. */
.dn-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  margin: 0 1px;
  vertical-align: -4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.dn-key svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: #1a73e8;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dn-steps span.dn-copy-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
}

.dn-copy-field {
  width: 100%;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.dn-sheet-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* On a wide screen the panel is a dropdown under the bell, so opening it
   never shoves the grid down. Its position is set by alerts.js. */
@media (min-width: 621px) {
  .board { position: relative; }
  .dn-panel {
    position: absolute;
    z-index: 50;
    width: 380px;
    max-width: calc(100% - 48px);
    margin: 0;
    box-shadow: 0 14px 40px rgba(20, 16, 12, 0.14);
  }
}

/* On a phone the sheet comes up from the bottom, where the thumb already is. */
@media (max-width: 620px) {
  /* Search gets the whole first row; Sort and Alerts share the row under it. */
  .board .controls .search { flex: 1 1 100%; max-width: none; }
  .board .controls .sort { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .board .controls .sort select { width: 100%; }
  .board .controls .dn-bell { flex: 1 1 calc(50% - 4px); box-sizing: border-box; justify-content: center; padding-top: 8px; padding-bottom: 8px; }

  .dn-row { flex-wrap: wrap; padding: 11px 12px; }
  .dn-row .dn-btn { width: 100%; }
  .dn-done-actions { width: 100%; }
  .dn-done-actions .dn-btn { flex: 1 1 0; white-space: normal; }
  .dn-panel { max-width: none; margin-left: 0; }

  .dn-sheet { align-items: flex-end; padding: 0; }
  .dn-sheet-card {
    max-width: none;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .dn-bell, .dn-btn { transition: none; }
  /* Still red with the "!" badge, just without the movement. */
  .dn-bell.is-off, .dn-bell.is-off svg { animation: none; }
}

/* ------------------------------------------------------------------ */
/* /alerts dashboard: pieces built by alerts-page.js                   */
/* ------------------------------------------------------------------ */

.ap-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #1d5fa8;
  background: #edf4fc;
  border: 1px solid #b9d3ef;
  border-radius: 999px;
  padding: 6px 6px 6px 13px;
  max-width: 100%;
}

.ap-bubble span { overflow-wrap: anywhere; }

.ap-bubble button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  color: #4b7fb8;
  cursor: pointer;
}

.ap-bubble button:hover { background: #d6e6f8; color: #174e8c; }
.ap-bubble button[disabled] { opacity: 0.5; cursor: progress; }

.ap-bubble svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.ap-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
}

.ap-chip:hover { border-color: var(--ink-3); }
.ap-chip small { font-size: 0.72rem; color: var(--ink-3); }

.ap-chip.is-added {
  color: #1d5fa8;
  background: #edf4fc;
  border-color: #b9d3ef;
  cursor: default;
}

.ap-chip.is-added small { color: #4b7fb8; }
.ap-chip[disabled] { cursor: progress; }

.ap-match a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}

.ap-match a:hover { border-color: var(--ink-3); }

.ap-match img {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
}

.ap-match-text { min-width: 0; }

.ap-match-name {
  display: block;
  font-size: 0.8rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-match-price { font-size: 0.78rem; font-weight: 700; }
.ap-match-off { font-size: 0.72rem; color: var(--deal); margin-left: 6px; font-weight: 600; }

.ap-chip:focus-visible,
.ap-bubble button:focus-visible,
.ap-match a:focus-visible { outline: 2px solid var(--deal); outline-offset: 2px; }
