/* Paid passes (js/pass-ui.js): header chip, gate notice, Settings row and the pass sheet.
   Nothing here matches anything unless passes are switched on (the elements only exist then).
   Same platform floor as styles.css (≈ Chromium 88): no :has(), dvh, container queries,
   nesting, color-mix() or @layer. Motion: opacity fades only, ≤ .25 s while calm. */

.mono, .pass-code-text, .pass-input.mono {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', 'JetBrains Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-variant-ligatures: none;
}

/* ---- header chip (inside .brand, right of the name) ------------------------------------ */

/* Quick taps on the logo (js/pass-ui.js) shouldn't select its name or zoom the page */
.has-pass .brand { -webkit-user-select: none; user-select: none; touch-action: manipulation; }

.pass-chip {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; margin-left: 8px; padding: 0 18px 0 14px;
  border-radius: 24px;
  border: 1px solid rgba(var(--accent-rgb), .55);
  background-color: rgba(var(--accent-rgb), .1);
  font-size: 13px; font-weight: 600; line-height: 16px; letter-spacing: 0;
  text-align: left;
  transition: background-color .3s, border-color .6s;
}
/* 56 px touch target, like the icon buttons */
.pass-chip::before { content: ''; position: absolute; top: -4px; right: -4px; bottom: -4px; left: -4px; border-radius: 28px; }
.pass-chip svg { width: 18px; height: 18px; color: rgb(var(--accent-rgb)); transition: color .6s; }
/* .brand span is hidden in some header layouts; the chip's text is not that span. One line,
   always: tight headers get the short wording from js/pass-ui.js */
.brand .pass-chip .pc-text {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.pass-chip:hover { background-color: rgba(var(--accent-rgb), .16); }
.pass-chip:active { background-color: rgba(var(--accent-rgb), .22); }
.pass-chip[data-state="active"] { border-color: rgba(255, 255, 255, .12); background-color: var(--surface); }
.pass-chip[data-state="active"]:hover { border-color: rgba(255, 255, 255, .22); }
.pass-chip[data-state="pending"] { border-color: rgba(251, 191, 36, .5); background-color: rgba(251, 191, 36, .08); }
.pass-chip[data-state="pending"] svg, .pass-chip[data-state="stale"] svg { color: var(--warn); }
.pass-chip[data-state="stale"] { border-color: rgba(251, 191, 36, .4); background-color: var(--surface); }

/* ---- gate notice: in the ring, between the speed and the gear line ---------------------- */

.pass-gate {
  position: absolute; left: 50%; top: 71.6%;
  z-index: 2;
  width: max-content; max-width: 62%;
  display: flex; flex-direction: column; align-items: center;
  gap: max(6px, calc(var(--rs) * .012));
  transform: translate(-50%, -50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.pass-gate.on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .25s ease, visibility 0s; }
.pass-gate-text {
  margin: 0;
  font-size: max(12px, calc(var(--rs) * .026)); font-weight: 600; line-height: 1.3;
  text-align: center;
  color: rgba(238, 243, 248, .86);
}
.pass-gate-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: max(48px, calc(var(--rs) * .088));
  padding: 0 max(18px, calc(var(--rs) * .038));
  border-radius: 999px;
  border: 1.5px solid rgb(var(--accent-rgb));
  background-color: rgb(var(--accent-rgb));
  color: #05070b;
  font-size: max(13px, calc(var(--rs) * .026)); font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 0 24px rgba(var(--accent-rgb), .3);
}
.pass-gate-btn::before { content: ''; position: absolute; top: -4px; right: -4px; bottom: -4px; left: -4px; border-radius: 999px; }
.pass-gate-btn svg { width: 1.2em; height: 1.2em; }
/* small rings (phones): lower, over the gear line, which hides while locked */
.pass-gate.compact { top: 76%; gap: 5px; }
.pass-gate.compact .pass-gate-text { font-size: 12px; }
.pass-gate.compact .pass-gate-btn { height: 42px; padding: 0 16px; font-size: 13px; }
.pass-locked-compact .read-bottom { opacity: 0; transition: opacity .25s ease; }
/* tiny rings (phone on its side, Pure): just the button, lower, clear of the scale */
.pass-gate.tiny { top: 88%; }
.pass-gate.tiny .pass-gate-text { display: none; }
.pass-gate.tiny .pass-gate-btn { height: 40px; padding: 0 13px; gap: 6px; font-size: 12.5px; }
/* while driving the notice stays quiet: an outline, not a lit button */
.calm .pass-gate-btn {
  background: transparent;
  color: rgb(var(--accent-rgb));
  border: 1.5px solid rgb(var(--accent-rgb));
  box-shadow: none;
}

/* ---- Settings row ------------------------------------------------------------------------ */

.pass-row { cursor: default; }
.pass-row .pbtn { flex: none; }

/* ---- buttons -------------------------------------------------------------------------------- */

.pbtn {
  position: relative;
  height: 56px; padding: 0 24px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 28px;
  border: 1.5px solid rgb(var(--accent-rgb));
  background-color: rgb(var(--accent-rgb));
  color: #05070b;
  font-size: 16px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  box-shadow: 0 0 30px rgba(var(--accent-rgb), .22);
  transition: background-color .45s, border-color .6s, box-shadow .6s, opacity .2s, transform .1s;
}
.pbtn:active { transform: scale(.985); }
.pbtn:disabled { opacity: .55; cursor: default; transform: none; }
.pbtn.ghost {
  border: 1px solid rgba(255, 255, 255, .14);
  background-color: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: none;
}
.pbtn.ghost:hover { border-color: rgba(255, 255, 255, .26); }
.pbtn.ghost:active { background-color: rgba(255, 255, 255, .1); }
.pbtn.small { height: 48px; padding: 0 20px; border-radius: 24px; font-size: 14px; }

.plink {
  min-height: 48px; padding: 0 2px;
  border: 0; background: none;
  font-size: 14px; font-weight: 600;
  color: rgb(var(--accent-rgb));
  text-decoration: underline; text-underline-offset: 4px;
  transition: color .6s;
}
.plink:focus-visible { border-radius: 8px; }

/* ---- the sheet ------------------------------------------------------------------------------ */

.pass-dialog .pass-sheet { width: min(600px, calc(100vw - 24px)); }
.pass-sheet .sheet-head { margin-bottom: 10px; }
.pass-sheet .sheet-head h2 { font-size: 22px; line-height: 1.25; }
.pass-sheet .sheet-head h2:focus { outline: none; }
.pass-sheet p { margin: 0; }

.pv { display: flex; flex-direction: column; gap: 16px; }
.pv-in { animation: passFade .18s ease both; }
@keyframes passFade { from { opacity: 0; } to { opacity: 1; } }
.pv > .pbtn, .pass-form > .pbtn { width: 100%; }

.pass-sub { font-size: 15px; line-height: 1.5; color: rgba(238, 243, 248, .72); }
.pass-lead { font-size: 16px; line-height: 1.5; }
.pass-trust { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.45; color: rgba(238, 243, 248, .68); }
.pass-trust svg { width: 16px; height: 16px; margin-top: 1px; color: rgb(var(--accent-rgb)); }

.pass-error {
  padding: 11px 14px;
  border-radius: 14px;
  background-color: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  font-size: 14px; line-height: 1.45;
}
.pass-error[role="alert"] { border-color: rgba(255, 93, 108, .45); background-color: rgba(255, 93, 108, .08); color: #ffc9cf; }

.pass-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pass-actions.solo { grid-template-columns: minmax(0, 1fr); }
.pass-actions .pbtn { width: 100%; padding: 0 14px; }
.nw { white-space: nowrap; }

.pass-links {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0 16px;
  margin: -6px 0 -10px;
}
.pass-legal { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: rgba(238, 243, 248, .5); }
.pass-legal a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; min-width: 48px; padding: 0 6px;
  color: rgba(238, 243, 248, .72);
  text-decoration: underline; text-decoration-color: rgba(238, 243, 248, .3); text-underline-offset: 3px;
}
.pass-legal a:focus-visible { border-radius: 6px; outline-offset: 0; }
.notes .pass-legal { display: inline; font-size: inherit; white-space: nowrap; }
.notes .pass-legal a { display: inline; min-height: 0; }

.pass-notnow { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: -6px; text-align: center; }
.pass-notnow small { font-size: 13px; color: rgba(238, 243, 248, .6); }

/* disclaimers: small at a standstill, a banner while moving */
.pass-parked {
  margin-top: 16px !important; padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px; line-height: 1.45;
  color: rgba(238, 243, 248, .6);
}
.pass-moving {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 0 0 16px !important; padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(251, 191, 36, .5);
  background-color: rgba(251, 191, 36, .12);
  color: #ffe6ad;
  font-size: 16px; font-weight: 600; line-height: 1.4;
}
.pass-moving svg { width: 22px; height: 22px; margin-top: 1px; color: var(--warn); }

/* ---- A: plans ---- */

.plans { display: grid; gap: 10px; }
.plan { position: relative; display: block; cursor: pointer; }
.plan input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.plan-card {
  display: flex; align-items: center; gap: 16px;
  min-height: 80px; padding: 14px 20px 14px 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .1);
  background-color: var(--surface);
  transition: border-color .2s, background-color .2s;
}
.plan:hover .plan-card { border-color: rgba(255, 255, 255, .2); }
.plan input:checked + .plan-card { border-color: rgba(var(--accent-rgb), .75); background-color: rgba(var(--accent-rgb), .08); }
.plan input:focus-visible + .plan-card { outline: 2px solid #fff; outline-offset: 3px; }
.plan-radio {
  flex: none;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid rgba(238, 243, 248, .35);
  transition: border-color .2s;
}
.plan-radio::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background-color: rgb(var(--accent-rgb)); opacity: 0; transition: opacity .2s; }
.plan input:checked + .plan-card .plan-radio { border-color: rgb(var(--accent-rgb)); }
.plan input:checked + .plan-card .plan-radio::after { opacity: 1; }
.plan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.plan-name { font-size: 17px; font-weight: 600; line-height: 1.3; }
.plan-blurb { font-size: 13px; line-height: 1.4; color: rgba(238, 243, 248, .68); }
.plan-badge {
  display: inline-block;
  margin-right: 4px; padding: 2px 8px;
  border-radius: 999px;
  background-color: rgb(var(--accent-rgb));
  color: #05070b;
  font-size: 11px; font-weight: 700; line-height: 15px; letter-spacing: .06em; text-transform: uppercase;
  vertical-align: 1px;
}
.plan-rest { white-space: nowrap; }
.plan-price { flex: none; font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* ---- B: QR ---- */

.qr { display: flex; align-items: center; gap: 24px; }
.pass-dialog[data-pass-view="qr"] .pass-sheet { width: min(760px, calc(100vw - 24px)); }
.qr-tile {
  --q: max(240px, min(480px, 44vh, calc(100vw - 64px)));
  flex: none;
  width: var(--q); height: var(--q);
  display: grid; place-items: center;
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}
.qr-tile svg { display: block; width: 100%; height: 100%; }
/* every state without a live code (loading, checking, processing, errors, final answers):
   a dark tile; it grows with its text rather than clip it */
.qr-tile:not([data-state="ready"]) {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  height: auto; min-height: var(--q);
  padding: 24px 20px;
  background: rgba(255, 255, 255, .03);
  border: 1px dashed rgba(255, 255, 255, .2);
  text-align: center;
  overflow: visible;
}
.qr-msg { max-width: 100%; font-size: 15px; line-height: 1.45; color: rgba(238, 243, 248, .86); overflow-wrap: break-word; }
.qr-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.qr-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.qr-plan { font-size: 18px; font-weight: 600; line-height: 1.35; }
.qr-steps { margin: 0; padding: 0; list-style: none; counter-reset: qrstep; display: grid; gap: 8px; }
.qr-steps li {
  counter-increment: qrstep;
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; line-height: 1.35; color: rgba(238, 243, 248, .86);
}
.qr-steps li::before {
  content: counter(qrstep);
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid rgb(var(--accent-rgb));
  color: rgb(var(--accent-rgb));
  font-size: 13px; font-weight: 700;
}
.qr-screen { font-size: 14px; color: rgba(238, 243, 248, .72); }
.qr-screen b { display: block; margin-top: 2px; font-size: 22px; font-weight: 600; letter-spacing: .1em; color: var(--text); }
.qr-host { font-size: 12px; color: rgba(238, 243, 248, .6); word-break: break-all; }
.qr-status { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.qr-status i { flex: none; width: 8px; height: 8px; border-radius: 50%; background-color: rgb(var(--accent-rgb)); box-shadow: 0 0 10px rgba(var(--accent-rgb), .8); }
.qr-foot { font-size: 12px; line-height: 1.45; color: rgba(238, 243, 248, .6); }
.qr:not([data-state="ready"]) .qr-steps,
.qr:not([data-state="ready"]) .qr-screen, .qr:not([data-state="ready"]) .qr-host,
.qr:not([data-state="ready"]) .qr-status, .qr:not([data-state="ready"]) .qr-foot { display: none; }

/* ---- D / G: unlocked, manage ---- */

.done-head { display: flex; align-items: center; gap: 14px; }
.done-mark {
  flex: none;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid rgb(var(--accent-rgb));
  background-color: rgba(var(--accent-rgb), .14);
  color: rgb(var(--accent-rgb));
  box-shadow: 0 0 24px rgba(var(--accent-rgb), .25);
}
.done-mark svg { width: 24px; height: 24px; }
.done-line { font-size: 17px; font-weight: 600; line-height: 1.4; }
.pass-note { margin-top: 12px !important; font-size: 13px; line-height: 1.5; color: rgba(238, 243, 248, .68); }

.pass-code {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 14px 14px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background-color: var(--surface);
}
.pass-code[hidden] { display: none; }
.pass-list { display: grid; gap: 10px; }
.pass-list .pass-code-label { font-size: 13px; letter-spacing: .02em; text-transform: none; color: rgba(238, 243, 248, .72); }
.pass-list .pass-code-label b { font-weight: 600; color: var(--text); }
.pass-code-label { font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: rgb(var(--accent-rgb)); }
.pass-code-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; }
.pass-code-btns { display: flex; gap: 8px; }
.pass-code-btns .pbtn svg { width: 18px; height: 18px; margin-left: -2px; }
.pass-code-text {
  font-size: 28px; font-weight: 600; line-height: 1.25; letter-spacing: .06em;
  -webkit-user-select: all; user-select: all;
}

/* ---- E / F: forms ---- */

.pass-form { display: flex; flex-direction: column; gap: 14px; }
.pass-field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; color: rgba(238, 243, 248, .68); }
.pass-input {
  width: 100%; height: 60px; margin: 0; padding: 0 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .16);
  background-color: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 18px; font-weight: 500;
  transition: border-color .2s, box-shadow .2s;
}
.pass-input.mono { font-size: 24px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.pass-input::placeholder { color: rgba(238, 243, 248, .3); letter-spacing: inherit; }
.pass-input:focus, .pass-input:focus-visible { outline: none; border-color: rgba(var(--accent-rgb), .8); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .2); }

/* ---- layouts ---------------------------------------------------------------------------------- */

/* phones: the chip shares the first header row with Help and Settings, so the name gives way */
@media (max-width: 479px) {
  .has-pass .brand > span { display: none; }
  .pass-chip { margin-left: 2px; }
}
/* 900–1099 px (car half screen): the left header column also holds the chip */
@media (min-width: 900px) and (max-width: 1099px) {
  .has-pass .top { grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1.2fr); }
}

/* narrow sheets: the QR stacks above its details */
@media (max-width: 619px) {
  .pass-actions { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .pass-actions .pbtn { font-size: 15px; }
  .qr { flex-direction: column; align-items: stretch; }
  .qr-tile { align-self: center; }
  .pass-dialog .pass-sheet { padding: 18px 18px 20px; }
  .plan-card { gap: 12px; padding: 12px 16px 12px 14px; }
  .plan-price { font-size: 20px; }
  .pass-code-text { font-size: 21px; letter-spacing: .04em; }
  .pass-code { padding-left: 16px; }
}

/* short screens (phones on their side): tighter sheet; the plans sit side by side */
@media (max-height: 500px) {
  .pass-sheet .sheet-head { margin-bottom: 4px; }
  .pv { gap: 12px; }
  .pass-sub { font-size: 14px; }
  .pass-moving { margin-bottom: 12px !important; padding: 10px 14px; font-size: 15px; }
  .pass-parked { margin-top: 12px !important; padding-top: 10px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .pass-dialog .pass-sheet { width: min(760px, calc(100vw - 24px)); }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "radio name price" "radio blurb blurb";
    align-items: center;
    gap: 2px 12px;
    min-height: 72px; padding: 10px 16px 10px 14px;
  }
  .plan-main { display: contents; }
  .plan-radio { grid-area: radio; }
  .plan-name { grid-area: name; font-size: 16px; }
  .plan-blurb { grid-area: blurb; }
  .plan-price { grid-area: price; font-size: 19px; }
}

/* ---- calm (driving) and reduced motion ------------------------------------------------------ */

.calm .pass-dialog[open] .sheet { animation: passFade .2s ease both; }
.calm .pass-chip, .calm .pass-chip svg, .calm .pbtn, .calm .plink, .calm .plan-card, .calm .plan-radio,
.calm .plan-radio::after, .calm .pass-input {
  transition-duration: .25s !important;
  transition-delay: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
  .pv-in, .calm .pass-dialog[open] .sheet { animation: none !important; }
}
