/* Pulse dashboard features (public/pulse.js). Uses the site tokens
   from style.css, so light and dark both follow the theme. */

/* Plan chip: cancel */
.dash-plan-cancel {
  background: none; border: none; padding: 0; margin-left: 4px; font: inherit;
  font-size: 0.875rem; font-weight: 600; color: var(--text-2); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.dash-plan-cancel:hover { color: var(--danger-text); }
.dash-plan-cancel[hidden] { display: none; }

/* (a) Status pill on each card row (.dc-heart keeps the heartbeat's
   state in data-hb). One word, colored by state. */
.dc-pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; white-space: nowrap;
  padding: 3px 10px 3px 8px; border-radius: 999px; font-size: var(--step-micro); font-weight: 600; line-height: 1.4;
  background: var(--surface-alt); color: var(--text-2); border: 1px solid var(--border);
}
.dc-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.dc-pill-green { background: var(--accent-soft); color: var(--accent-tag); border-color: var(--accent-light); }
.dc-pill-amber, .dc-pill-pending { background: var(--warning-light); color: var(--warning-text); border-color: rgb(var(--warning-rgb) / 0.4); }
.dc-pill-red, .dc-pill-declined { background: var(--danger-light); color: var(--danger-text); border-color: rgb(239 68 68 / 0.35); }
.dc-pill-new .dc-pill-dot, .dc-pill-paused .dc-pill-dot { background: var(--text-3); }

/* The schedule's reasoning is in the card's panel, not the row. */
.dc .dc-why { display: none; }
.panel-why { margin-top: 6px; }
.dc-skip-note { color: var(--text-3); font-weight: 500; }

/* (g) Row actions. Pointer devices: revealed when the row is hovered or
   holds focus, so a list of cards reads as names and dates. Touch
   devices: one quiet strip along the bottom of the row. */
.dc-actions { display: flex; }
.dc-act {
  font: inherit; font-size: var(--step-small); font-weight: 600; color: var(--text-2);
  background: transparent; border: none; cursor: pointer;
}
.dc-act:hover { color: var(--text); }
.dc-act-danger:hover { color: var(--danger-text); }
.dc-act[disabled] { opacity: 0.6; cursor: wait; }
#card-list.selecting .dc-actions { display: none; }
/* The hover strip is absolutely placed at the row's right, 52px in and
   about 271px wide, so it clears the row's middle only once the list is
   700px or wider. Below that (a narrow window with a mouse, a tablet in
   split view) a click on the middle of a row landed on "Skip next charge";
   narrow lists get the touch strip instead. */
#card-list { container-type: inline-size; }
@media (hover: hover) and (pointer: fine) {
  @container (min-width: 700px) {
    .dc { position: relative; }
    .dc-actions {
      position: absolute; right: 52px; top: 50%; transform: translateY(-50%);
      gap: 6px; padding: 0; background: none; border: 0; box-shadow: none;
    }
    .dc:has(.dc-actions) .dc-info { padding-right: 240px; }
    .dc-act {
      padding: 6px 12px; min-height: 36px; border-radius: 8px; font-size: 0.875rem;
      border: 1px solid var(--border); background: var(--surface);
      transition: background-color 0.12s ease, border-color 0.12s ease;
    }
    .dc-act:hover { background: var(--surface-alt); border-color: var(--text-3); }
    .dc-act-danger:hover { background: var(--danger-light); }
  }
  @container (max-width: 699.98px) {
    .dc { flex-direction: column; align-items: stretch; }
    .dc-actions { border-top: 1px solid var(--border-light); }
    .dc-act { flex: 1 1 0; min-height: 46px; padding: 8px 6px; white-space: nowrap; }
    .dc-act + .dc-act { border-left: 1px solid var(--border-light); }
  }
}
@media (hover: none), (pointer: coarse) {
  .dc { flex-direction: column; align-items: stretch; }
  .dc-actions { border-top: 1px solid var(--border-light); } /* edge to edge: dashboard.html sets the margins */
  .dc-act { flex: 1 1 0; min-height: 46px; padding: 8px 6px; white-space: nowrap; }
  .dc-act + .dc-act { border-left: 1px solid var(--border-light); }
}

/* (e) Early warning */
.pulse-warnings { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.pulse-warnings[hidden] { display: none; }
.pw-item {
  border: 1px solid var(--warning); background: var(--warning-light); color: var(--text);
  border-radius: 12px; padding: 14px 16px; font-size: 0.9375rem; line-height: 1.5;
}
.pw-item.pw-hard { border-color: var(--danger); background: var(--danger-light); }
.pw-head { font-weight: 700; margin-bottom: 4px; }
.pw-code { font-weight: 500; color: var(--text-2); }
.pw-item p { margin: 0 0 8px; color: var(--text-2); }
.pw-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.pw-links a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.pw-links a:hover { text-decoration: underline; }

/* (b) (d) extras inside the two tiles */
.pi-extra:empty { display: none; }
.pi-extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); font-size: 0.875rem; color: var(--text-2); }
/* A label and its figure. The figure is one unit: "$15,000 of $28,000
   (53.6%)" never breaks inside itself, which left "(53.6%)" alone on a
   line. When it does not fit beside its label, the whole figure takes
   the next line, still right-aligned. */
.pi-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px; padding: 3px 0; }
.pi-row > span { flex: 1 1 8em; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.pi-row > strong { margin-left: auto; color: var(--text); white-space: nowrap; text-align: right; }
.pi-row em { font-style: normal; color: var(--danger-text); font-weight: 600; }
.pi-sub { margin: 8px 0 2px; font-size: 0.875rem; color: var(--text-2); }
.pi-note { margin: 8px 0 0; font-size: 0.875rem; color: var(--text-3); line-height: 1.5; }
.pi-milestone { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; }
.pi-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: var(--step-micro); font-weight: 700; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent-tag); border: 1px solid var(--accent-light);
}
.pi-badge-scaler, .pi-badge-maximizer { background: linear-gradient(90deg, var(--accent-soft), var(--warning-light)); }
.pi-next { font-size: 0.875rem; color: var(--text-3); }
.pi-share {
  margin-top: 10px; font: inherit; font-size: 0.875rem; font-weight: 600; color: var(--accent-text);
  background: none; border: 1px solid var(--accent-light); border-radius: 8px; padding: 6px 12px; min-height: 32px; cursor: pointer;
}

/* (c) (f) panels. One above the other: side by side in the 712px card
   column each was 300px inside, too narrow for the card picker (it read
   "Chase Sapphire Preferred ($1...") and for the what-if figures. */
.pulse-insights { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 24px 0; }
.pulse-insights[hidden] { display: none; }
.pi-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; font-size: 0.9375rem; min-width: 0; container-type: inline-size; }
.pi-title { margin: 0 0 12px; font-size: 0.92rem; font-weight: 700; color: var(--text); }
.pi-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.pi-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; font-weight: 600; color: var(--text-2); }
.pi-form select, .pi-form input {
  font: inherit; font-size: var(--step-small); font-weight: 500; color: var(--text); background-color: var(--surface);
  border: 1.5px solid var(--border); border-radius: 10px; padding: 9px 12px; min-height: 44px; width: 100%; box-sizing: border-box;
}
/* background-color, not the shorthand: style.css draws the select's
   arrow as a background image, which `background:` would wipe. The
   right padding keeps a long card name clear of the arrow. */
.pi-form select { padding-right: 40px; text-overflow: ellipsis; }
/* A wide panel puts the card and the balance side by side, their fields
   lined up along the bottom. */
@container (min-width: 520px) {
  .pi-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: end; }
}
/* A currency sign inside an input: the same size and baseline as the
   number typed after it, with room to breathe: 15px on desktop, 16px on
   phones, where style.css raises every field so iOS does not zoom. */
.pi-dollar { position: relative; display: block; }
.pi-dollar > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: var(--step-small); line-height: 1; color: var(--text-2); font-weight: 500; pointer-events: none; }
/* .pi-form scoping outranks style.css's input[type="text"] padding,
   which otherwise lands the number on top of the sign. */
.pi-form .pi-dollar input { padding-left: 30px; font-size: var(--step-small); font-variant-numeric: tabular-nums; }
/* style.css raises every field to 16px under 768px; the sign follows. */
@media (max-width: 768px) { .pi-dollar > span { font-size: 16px; } }
.pi-result { min-height: 3.2em; }
.pi-util .pi-warn { color: var(--warning-text); }
.pi-util .pi-bad { color: var(--danger-text); }
.pi-total { border-top: 1px solid var(--border-light); margin-top: 4px; padding-top: 6px; }

/* Issuer picker */
.issuer-other { margin-top: 6px; }
.issuer-other[hidden] { display: none; }
.issuer-why { display: block; margin-top: 4px; font-size: 0.875rem; font-weight: 400; color: var(--text-2); line-height: 1.45; }
.issuer-why:empty { display: none; }
.waiver-hint { display: block; margin-top: 6px; font-size: 0.875rem; font-weight: 400; color: var(--text-2); line-height: 1.45; }
.waiver-hint[hidden] { display: none; }
.waiver-bump {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; font-weight: 600; color: var(--link, var(--accent-tag));
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.waiver-bump:hover { color: var(--link-hover, var(--accent)); }

/* (h) Safety */
.pulse-safety {
  margin: 24px 0; padding: 18px 20px; border-radius: 12px;
  background: var(--surface-alt); border: 1px solid var(--border);
}
.pulse-safety[hidden] { display: none; }
.pulse-safety h3 { margin: 0 0 10px; font-size: 0.92rem; }
.pulse-safety ul { margin: 0 0 10px; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.pulse-safety li { font-size: 0.875rem; color: var(--text-2); line-height: 1.45; padding-left: 22px; position: relative; }
.pulse-safety li::before {
  content: ''; position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-soft); border: 1.5px solid var(--accent);
}
.pulse-safety li strong { color: var(--text); }
.pulse-safety a { font-size: 0.875rem; font-weight: 600; color: var(--accent-text); text-decoration: none; }

@media (max-width: 640px) {
  .pulse-insights { grid-template-columns: 1fr; }
  .pulse-safety ul { grid-template-columns: 1fr; }
  /* Tap targets: 44px on phones (docs/DESIGN.md). */
  .pi-share { min-height: 44px; padding: 8px 16px; }
  .dash-plan-cancel { display: inline-flex; align-items: center; min-height: 44px; }
  .pulse-safety a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* Demo banner actions and the guided tour (demo-tour.js) */
.demo-banner-actions { display: inline-flex; align-items: center; gap: 14px; flex-shrink: 0; }
.demo-tour-btn {
  font: inherit; font-size: 0.875rem; font-weight: 700; color: var(--accent-text); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--accent); border-radius: 8px; padding: 6px 12px; min-height: 36px;
}
.tour-spot {
  position: fixed; z-index: 9000; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(15, 23, 42, 0.55);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.tour-spot[hidden] { display: none; }
.tour-pop {
  position: fixed; z-index: 9001; width: 360px; max-width: calc(100vw - 32px); box-sizing: border-box;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 18px 18px 14px;
}
.tour-pop[hidden] { display: none; }
.tour-pop.tour-end {
  top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); width: 420px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55), var(--shadow-lg);
}
.tour-count { font-size: var(--step-micro); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-tag); margin-bottom: 6px; }
.tour-title { margin: 0 0 6px; font-size: 1.125rem; font-weight: 800; line-height: 1.3; }
.tour-body { margin: 0 0 14px; font-size: 0.9375rem; line-height: 1.55; color: var(--text-2); }
.tour-cta { margin: 0 0 12px; }
.tour-cta[hidden] { display: none; }
.tour-plans { display: block; text-align: center; text-decoration: none; padding: 12px 16px; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-nav { display: inline-flex; gap: 8px; }
.tour-nav button { padding: 8px 14px; font-size: 0.9375rem; min-height: 40px; }
.tour-nav button[hidden] { display: none; }
.tour-skip { background: none; border: none; font: inherit; font-size: 0.9375rem; font-weight: 600; color: var(--text-2); cursor: pointer; padding: 0 4px; min-height: 44px; display: inline-flex; align-items: center; }
.tour-skip:hover { color: var(--text); }
@media (max-width: 639px) {
  .tour-pop:not(.tour-end) { left: 16px !important; right: 16px; bottom: 16px; top: auto !important; width: auto; max-width: none; }
  .tour-pop.tour-end { width: calc(100vw - 32px); }
  .tour-nav button, .tour-skip { min-height: 44px; }
  .demo-tour-btn { min-height: 44px; padding: 8px 16px; }
}
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
body.tour-on .demo-keep { display: none !important; }
