/* Companion styles layered on top of the compiled Tailwind (app.css).
   Loaded after app.css so these rules win. Added 2026-07-02 for the rates-UI
   refinements: sort chips, carrier grouping, logos, weight units, save-address. */

/* ---- Rate results: sort chips ---- */
.rate-sort { display: flex; gap: 6px; margin-left: auto; }
.sort-chip {
  font-family: var(--font-body); cursor: pointer;
  border: 1.5px solid var(--color-line); background: var(--color-card-2); color: var(--color-muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13.5px; font-weight: 700;
  transition: border-color .15s, background-color .15s, color .15s, box-shadow .15s;
}
.sort-chip:hover { border-color: var(--color-cyan); color: var(--color-cyan); }
.sort-chip.is-active { background: var(--color-cyan); border-color: var(--color-cyan); color: #06121a;
  box-shadow: 0 0 14px -3px rgba(46,242,255,.6); }

/* ---- Carrier group headers (full-width row inside the rate grid) ---- */
.carrier-group-head {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px;
  margin: 10px 0 2px; padding-bottom: 8px; border-bottom: 2px dashed var(--color-line);
}
.carrier-group-head:first-child { margin-top: 0; }
.carrier-group-name { font-family: var(--font-display); color: var(--color-pine); font-size: 16px; font-weight: 800; }
.carrier-group-count { font-family: var(--font-mono); color: var(--color-muted); font-size: 12px; margin-left: auto; }

/* ---- Carrier logos ---- */
.carrier-logo { height: 20px; width: auto; display: block; }
.carrier-logo.lg { height: 26px; }
.rate-card-top { display: flex; align-items: center; gap: 8px; min-height: 24px; }

/* ---- Uniform rate cards: anchor the buy button to the bottom ---- */
.rate-card .btn { margin-top: auto; }

/* ---- Weight: number + unit selector ----
   The dims row is L / W / H / Weight. Weight also carries the unit <select>, so
   give it a wider cell (span 2 of a 5-col grid) and a real min-width on the
   number input so its value shows, not just the spinner arrows. */
.dims { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dims .weight-field { grid-column: span 2; }
.weight-input { display: flex; gap: 6px; align-items: stretch; }
.weight-input input { flex: 1 1 auto; min-width: 3.5rem; }
.weight-input select { flex: 0 0 auto; width: auto; padding-inline: 8px 24px; }
@media (max-width: 720px) {
  .dims { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dims .weight-field { grid-column: span 2; }  /* full-width row on phones */
}

/* ---- Save-to-address-book checkbox ---- */
.grid-fields label.save-addr {
  grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 9px;
  color: var(--color-ink); font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 2px;
}
.grid-fields label.save-addr input[type=checkbox] {
  appearance: auto; -webkit-appearance: auto;
  width: 17px; height: 17px; flex: none; padding: 0; border: 0; border-radius: 0;
  background: initial; accent-color: var(--color-pine);
}
/* Hide "Save … to the address book" while an unmodified address-book address is loaded
   (address-book.js adds .addr-from-book to the section; any edit removes it). */
.addr-from-book .save-addr { display: none; }

/* ---- Ship-from / Ship-to: side-by-side grid row-mates ----
   These are adjacent .panel siblings, so the global `.panel + .panel
   { margin-top:18px }` rule (meant for vertically-stacked panels) wrongly
   shoved #to-section down 18px — misaligning the two panels' tops and, when
   combined with a forced height, spilling its bottom onto the Package panel
   below. Zero that stray margin; the grid's default align-items:stretch then
   equalizes their heights on its own. */
#from-section, #to-section { margin-top: 0; }

/* ---- Always-on debug error surface ---- */
.debug-error .debug-detail { margin-top: 6px; font-weight: 600; }
.debug-details { margin-top: 10px; }
.debug-details summary {
  cursor: pointer; font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--color-alert);
}
.debug-trace {
  margin-top: 8px; max-height: 320px; overflow: auto; white-space: pre;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.45; color: #ffd0d7;
  background: #17102a; border: 1px solid rgba(255,92,116,.35); border-radius: 8px; padding: 10px 12px;
}

/* ---- Get-rates loading indicator + disabled button ---- */
.htmx-indicator { opacity: 0; transition: opacity .15s ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.rates-spinner { display: inline-flex; align-items: center; gap: 8px; color: var(--color-muted); font-weight: 600; font-size: 14px; }
.rates-spinner .spin {
  width: 15px; height: 15px; border-radius: 50%; display: inline-block;
  border: 2.5px solid var(--color-line); border-top-color: var(--color-pine);
  animation: rates-spin .7s linear infinite;
}
@keyframes rates-spin { to { transform: rotate(360deg); } }
.btn:disabled, .btn[disabled] { opacity: .6; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .rates-spinner .spin { animation: none; } }

/* Address-scan confirmation overlay */
.scan-overlay{position:fixed;inset:0;z-index:60;display:flex;align-items:center;
  justify-content:center;padding:20px}
.scan-overlay[hidden]{display:none}
.scan-overlay-backdrop{position:absolute;inset:0;background:rgba(4,3,10,.72)}
.scan-overlay-panel{position:relative;max-width:420px;width:100%;
  background:var(--color-card);border:1px solid var(--color-line);
  border-radius:var(--radius-card);padding:22px;box-shadow:0 24px 60px -20px #000}
.scan-overlay h3{font-family:var(--font-display);color:var(--color-ink);
  font-size:19px;font-weight:700;margin-bottom:6px}
.scan-cand{border:1.5px solid var(--color-line);border-radius:12px;padding:12px 14px;
  margin-top:10px;color:var(--color-ink);cursor:pointer;display:block}
.scan-cand:has(input:checked){border-color:var(--color-cyan);
  box-shadow:inset 0 0 0 1px var(--color-cyan)}
.scan-cand .scan-cand-line{color:var(--color-muted);font-size:14px}
.scan-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}
.scan-msg{color:var(--color-muted);margin-top:8px}

/* Scan-address call-to-action (top of each address block) */
.scan-cta{margin:0 0 14px}
.scan-cta .scan-address-btn{width:100%;justify-content:center}

/* Scan processing spinner + verification badges (colors come from tokens → per-brand) */
.scan-spinner{width:34px;height:34px;margin:14px auto 6px;border-radius:50%;
  border:3px solid var(--color-line);border-top-color:var(--color-cyan);
  animation:scan-spin .8s linear infinite}
@keyframes scan-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.scan-spinner{animation:none}}
.scan-badge{display:inline-block;font-size:11px;font-weight:700;line-height:1.6;
  padding:1px 9px;border-radius:999px;border:1px solid;margin-bottom:6px}
.scan-badge.is-verified{color:var(--color-fresh);border-color:var(--color-fresh);background:var(--color-fresh-050)}
.scan-badge.is-cleaned{color:var(--color-sky);border-color:var(--color-sky);background:var(--color-sky-050)}
.scan-badge.is-unverified{color:var(--color-alert);border-color:var(--color-alert);background:var(--color-alert-050)}
.scan-cand-note{color:var(--color-muted);font-size:12.5px;margin-top:3px}

/* Voice dictation: recording state + "heard" transcript line */
.dictate-address-btn.is-recording{color:var(--color-alert);border-color:var(--color-alert)}
.dictate-address-btn.is-recording::before{content:"● ";animation:scan-pulse 1s ease-in-out infinite}
@keyframes scan-pulse{50%{opacity:.35}}
@media (prefers-reduced-motion:reduce){.dictate-address-btn.is-recording::before{animation:none}}
.scan-heard{color:var(--color-muted);font-size:12.5px;font-style:italic;margin-top:10px}
.scan-heard b{font-style:normal;color:var(--color-ink)}

/* --- Label tracking modal --- */
.track-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.track-head h3 { font-family: var(--font-display); color: var(--color-ink); font-size: 19px; font-weight: 700; }
.track-code { font-family: var(--font-mono); color: var(--color-muted); font-size: 13px; }
.track-status { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1px solid; margin-bottom: 10px; }
.track-status.is-delivered { color: var(--color-fresh); border-color: var(--color-fresh); }
.track-status.is-transit { color: var(--color-sky); border-color: var(--color-sky); }
.track-status.is-failure { color: var(--color-alert); border-color: var(--color-alert); }
.track-status.is-unknown { color: var(--color-muted); border-color: var(--color-line); }
.track-eta { color: var(--color-ink); font-size: 14px; margin-bottom: 10px; }
.track-timeline { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow-y: auto; }
.track-event { border-left: 2px solid var(--color-line); padding: 0 0 14px 14px; position: relative; }
.track-event:last-child { padding-bottom: 0; }
.track-event::before { content: ""; position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-cyan); }
.track-event-status { color: var(--color-ink); font-weight: 600; font-size: 14px; }
.track-event-msg { color: var(--color-muted); font-size: 13px; }
.track-event-meta { color: var(--color-muted); font-size: 12px; font-family: var(--font-mono); margin-top: 2px; }

/* ── Top-nav "Log out" pill (both brands; only rendered when auth is enabled) ──
   Sized/typed to match the mode pill for visual harmony; token-colored so the
   Skipper and Rabino themes re-color it for free. */
.logout-form { margin: 0; display: inline-flex; }
.logout-pill {
  cursor: pointer;
  font-family: var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  border: 1.5px solid var(--color-line);
  color: var(--color-muted);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11.5px; font-weight: 700;
  transition: color .15s, border-color .15s, background-color .15s;
}
.logout-pill:hover {
  color: var(--color-alert);
  border-color: var(--color-alert);
  background: var(--color-alert-050);
}

/* ── New-shipment form: mobile accordion (first three steps) ──────────────────
   Collapsible only on phones (≤767.98px, where the from/to grid is already a
   single column) AND only once ship-accordion.js has added `has-accordion`
   (progressive enhancement — no JS ⇒ every field stays visible). Desktop is
   untouched. Token-colored, so both brands re-color for free. */
.step-chevron { display: none; }     /* only appears on mobile */
.step-summary { display: none; }     /* only appears on mobile while collapsed */

@media (max-width: 767.98px) {
  .has-accordion .is-collapsible > .step-head {
    cursor: pointer;
    -webkit-user-select: none; user-select: none;
    align-items: center;
    margin-bottom: 0;
  }
  .has-accordion .is-collapsible.is-open > .step-head { margin-bottom: 14px; }
  .has-accordion .is-collapsible > .step-head:active { opacity: .82; }
  /* keep the tappable row tidy — the summary carries the at-a-glance info */
  .has-accordion .is-collapsible > .step-head .step-hint { display: none; }

  .has-accordion .is-collapsible > .step-head .step-chevron {
    display: inline-flex;
    margin-left: auto;               /* push chevron to the right edge */
    color: var(--color-muted);
    transition: transform .18s ease;
    flex: none;
  }
  .has-accordion .is-collapsible.is-open > .step-head .step-chevron {
    transform: rotate(180deg);
  }

  .has-accordion .is-collapsible:not(.is-open) > .step-summary {
    display: block;
    color: var(--color-muted);
    font-size: 14px; font-weight: 500;
    margin: 2px 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .has-accordion .is-collapsible:not(.is-open) > .step-body { display: none; }
}

@media (prefers-reduced-motion: reduce) { .has-accordion .is-collapsible > .step-head .step-chevron { transition: none; } }

/* ---- Even vertical spacing between the four stacked ship sections on phones ----
   When the from/to grid stacks (≤767.98px) the sections' gaps otherwise come from
   three inconsistent sources: the grid row-gap (16px) between Ship-from and Ship-to,
   nothing (0px) between the grid and Mail type, and nothing (0px) between Mail type
   and Carriers — the .panel + .panel rule can't reach Carriers because <script> tags
   sit between the two panels. Normalize all three to a single gap. Ungated by
   .has-accordion so the spacing is even even without JS; desktop is untouched. */
@media (max-width: 767.98px) {
  #ship-form > .grid { row-gap: 14px; }              /* Ship-from ↔ Ship-to */
  #package-section, #carriers-section { margin-top: 14px; }  /* ↔ Mail type, ↔ Carriers */
}

/* ---- Desktop mirror of the above ----
   On ≥768px the from/to grid is side-by-side (not a .panel), and a <script> tag
   still sits between Customs and Carriers, so `.panel + .panel { margin-top:18px }`
   can't add the gap before Mail type or before Carriers — leaving them flush
   against the row above. Restore the 18px panel-stack gap for just those two.
   (Advanced options already gets it: Carriers → Advanced are adjacent panels.) */
@media (min-width: 768px) {
  #package-section, #carriers-section { margin-top: 18px; }
}

/* ---- Advanced options (section 05): all-viewport disclosure ----
   Collapsed by default on every screen, but only once advanced-options.js has
   added `has-disclosure` (no JS ⇒ fields stay visible). Reuses the accordion's
   chevron/summary treatment; token-colored for both themes. */
.has-disclosure .is-disclosure > .step-head {
  cursor: pointer; -webkit-user-select: none; user-select: none;
  align-items: center; margin-bottom: 0;
}
.has-disclosure .is-disclosure.is-open > .step-head { margin-bottom: 16px; }
.has-disclosure .is-disclosure > .step-head:active { opacity: .82; }
.has-disclosure .is-disclosure > .step-head .step-chevron {
  display: inline-flex; margin-left: auto; color: var(--color-muted);
  transition: transform .18s ease; flex: none;
}
.has-disclosure .is-disclosure.is-open > .step-head .step-chevron { transform: rotate(180deg); }
.has-disclosure .is-disclosure:not(.is-open) > .step-summary {
  display: block; color: var(--color-muted); font-size: 14px; font-weight: 500;
  margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.has-disclosure .is-disclosure:not(.is-open) > .step-body { display: none; }
@media (prefers-reduced-motion: reduce) { .has-disclosure .is-disclosure > .step-head .step-chevron { transition: none; } }

/* option groups inside the panel */
.adv-grid { display: grid; gap: 18px; }
@media (min-width: 640px) { .adv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.adv-group {
  border: 1px solid var(--color-line); border-radius: 12px;
  padding: 14px 16px; display: grid; gap: 12px; min-width: 0; align-content: start;
}
.adv-group > legend {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .12em;
  font-size: 11px; font-weight: 700; color: var(--color-pink); padding: 0 6px;
}
.adv-check {
  display: flex; align-items: center; gap: 10px; color: var(--color-ink);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.adv-check input { width: 17px; height: 17px; accent-color: var(--color-cyan); flex: none; }
.adv-hint { color: var(--color-muted); font-weight: 500; font-size: 12.5px; }
.adv-money { display: inline-flex; align-items: center; gap: 6px; }
.adv-money-sign { color: var(--color-muted); font-weight: 700; }
/* conditional sub-fields: revealed only when their checkbox is ticked (no JS) */
.adv-sub { display: none; margin-left: 27px; }
.adv-contents:has(input[name="hazmat_on"]:checked) .adv-hazmat-type { display: flex; }
.adv-contents:has(input[name="dry_ice"]:checked) .adv-dryice-weight { display: flex; }

/* ---- Delivery-estimate format toggle + the estimate line on each rate card ----
   The toggle mirrors the existing .rate-sort chips; tokens only, so both themes
   re-color for free. */
.est-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.est-toggle-label {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .1em;
  font-size: 11px; font-weight: 700; color: var(--color-muted);
}
.est-chip {
  cursor: pointer; border: 1.5px solid var(--color-line); background: var(--color-card-2);
  color: var(--color-muted); border-radius: 999px; padding: 6px 12px;
  font-size: 12.5px; font-weight: 700;
  transition: color .15s, border-color .15s, background-color .15s;
}
.est-chip:hover { border-color: var(--color-cyan); color: var(--color-cyan); }
.est-chip.is-active { background: var(--color-cyan); border-color: var(--color-cyan); color: #06121a; }
.rate-est { font-family: var(--font-mono); margin-top: 6px; font-size: 13px; }
.rate-est .est-head { color: var(--color-muted); }
.rate-est .est-sub { color: var(--color-muted); opacity: .8; font-size: 12px; margin-top: 1px; }

/* ---- Dropdown option list: recolor per brand ----
   app.css hardcodes `select option { background-color:#17133a }` (Skipper indigo), which
   doesn't recolor for Rabino. Drive it from the input-fill token so BOTH themes match the
   select's own fill (Skipper indigo / Rabino cream). */
.field select option,
.grid-fields select option,
.stack-form select option { background-color: var(--color-card-2); }

/* ---- Package preview: 12 oz Hamm's can, standing beside the box's front-left corner ----
   Bottom-align the can and box on a shared baseline so their heights compare directly
   (was centered/stacked, floating in the foreground). The can is a static Hamm's-can SVG,
   identical on both brands; JS sizes it true-to-scale against the package. */
.viz-stage { display: flex; flex-direction: row; align-items: flex-end; justify-content: center; gap: 20px; }
.scale-ref {
  background: url("/static/img/hamms-can.svg?v=2") center bottom / contain no-repeat;
  box-shadow: none; border-radius: 0;
}
.scale-ref::before { content: none; }   /* remove the old abstract band */
.viz-stage > .hint { margin: auto; }     /* keep the empty-state hint centered under flex */

/* ---- International mode: reveal customs/country, grey the domestic-only controls ----
   .intl-only is hidden until #ship-form has data-intl; domestic-only controls dim when
   international. Tokens only, so both themes re-color. */
.ship-intl-toggle {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  color: var(--color-ink); font-size: 15px; font-weight: 600; cursor: pointer;
}
.ship-intl-toggle input { width: 17px; height: 17px; accent-color: var(--color-cyan); flex: none; }

.intl-only { display: none; }
#ship-form[data-intl] .intl-only { display: grid; }
#ship-form[data-intl] section.intl-only,
#ship-form[data-intl] #customs-section.intl-only { display: block; }

#ship-form[data-intl] .domestic-only { opacity: .45; pointer-events: none; }

/* customs item rows: a compact grid matching .grid-fields */
.customs-items-head { font-family: var(--font-display); color: var(--color-ink); font-size: 16px; font-weight: 700; margin: 16px 0 8px; }
.customs-item {
  display: grid; gap: 8px; margin-bottom: 8px; align-items: center;
  grid-template-columns: minmax(0,2fr) 64px minmax(0,1fr) minmax(0,1fr) minmax(0,1.2fr) 64px 34px;
}
.customs-item input {
  background-color: var(--color-card-2); border: 1.5px solid var(--color-line);
  color: var(--color-ink); border-radius: 10px; padding: 9px 10px; font-size: 14px; min-width: 0;
}
.customs-remove {
  cursor: pointer; background: transparent; border: 1.5px solid var(--color-line);
  color: var(--color-alert); border-radius: 9px; padding: 6px 0; font-weight: 700;
}
.customs-remove:hover { border-color: var(--color-alert); background: var(--color-alert-050); }
@media (max-width: 720px) { .customs-item { grid-template-columns: 1fr 1fr; } .customs-item .ci-desc { grid-column: 1 / -1; } }

/* ---- Address book: "normalize on Add" offer + saved feedback ----
   Reuses the .addr-suggest card (already themed for both brands); token-colored. */
.addr-offer { margin-top: 12px; }
/* Hide the slot when it holds no element children — covers both the initial empty
   state and the whitespace-only text nodes htmx leaves after an out-of-band list swap
   (plain :empty would not match those, leaving a lingering gap). */
.addr-offer:not(:has(*)) { display: none; }
.addr-offer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.addr-offer-actions form { margin: 0; }
.addr-suggest .as-was {
  display: block; margin-top: 2px;
  color: var(--color-muted); font-weight: 500; font-size: 13px;
}

/* "Ship by voice" call-to-action on the ship page */
.voice-cta {
  display: flex; align-items: center; gap: 16px; margin: 0 0 22px;
  padding: 15px 18px; border-radius: var(--radius-card); text-decoration: none;
  background: linear-gradient(100deg,
              color-mix(in srgb, var(--color-cyan) 12%, var(--color-card)) 0%, var(--color-card) 62%);
  border: 1px solid color-mix(in srgb, var(--color-cyan) 45%, var(--color-line));
  box-shadow: inset 0 1px rgba(255,255,255,.05), 0 0 22px -12px color-mix(in srgb, var(--color-cyan) 70%, transparent);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.voice-cta:hover {
  transform: translateY(-2px);
  border-color: var(--color-cyan);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-cyan) 30%, transparent),
              0 0 28px -10px color-mix(in srgb, var(--color-cyan) 85%, transparent);
}
.voice-cta-orb {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  color: #06121a; background: radial-gradient(120% 120% at 30% 25%,
              color-mix(in srgb, var(--color-cyan) 92%, white) 0%, var(--color-cyan) 65%);
  box-shadow: 0 0 18px -4px color-mix(in srgb, var(--color-cyan) 80%, transparent);
}
.voice-cta-text { display: flex; flex-direction: column; gap: 2px; }
.voice-cta-text strong {
  font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--color-cyan);
}
.voice-cta-text span { color: var(--color-muted); font-size: 14px; }
.voice-cta-go {
  margin-left: auto; font-family: var(--font-mono); font-size: 22px; font-weight: 700;
  color: var(--color-cyan); transition: transform .15s;
}
.voice-cta:hover .voice-cta-go { transform: translateX(3px); }
