/* ============================================================
   iQMS Patient ticket page — mobile-first PWA stylesheet.
   Same brand tokens as public/qms-caller/style.css so the two PWAs
   (staff caller, patient ticket) read as one product family.
   ============================================================ */

:root {
    --primary: #3b5bdb;
    --primary-light: #60a5fa;
    --primary-ink: #3b5bdb;
    --primary-bg: rgba(59, 91, 219, .10);
    --ink: #1e293b;
    --muted: #64748b;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --success-text: #047857;
    --success-bg: #ecfdf5;
    --warn-text: #c2410c;
    --warn-bg: #fff7ed;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
}

/* Dark mode is opt-in: light unless the patient flips the switch on /semak
   (stored as iqms.patient.theme, applied as html[data-theme="dark"] by a
   one-line script in each page's <head>). The OS setting does not change it. */
html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] {
    --ink: #f1f5f9;
    --muted: #94a3b8;
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --primary-ink: #60a5fa;
    --primary-bg: rgba(96, 165, 250, .16);
    --success-text: #6ee7b7;
    --success-bg: rgba(16, 185, 129, .12);
    --warn-text: #fdba74;
    --warn-bg: rgba(249, 115, 22, .14);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, .14);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.fa-svg {
    height: 1em;
    width: auto;
    display: inline-block;
    vertical-align: -.125em;
    overflow: visible;
    flex-shrink: 0;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
}

.wrap {
    max-width: 480px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
}

.facility-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--muted);
}

.offline-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 2px 8px;
    border-radius: 999px;
}

.state-card {
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    padding: 28px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: background .3s ease;
}

.ticket-number {
    font-size: 56px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

.state-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
}

.state-near { background: var(--warn-bg); }
.state-near .state-label { color: var(--warn-text); }

.state-called {
    background: var(--success-bg);
    animation: pulse 1.4s ease-in-out 3;
}
.state-called .ticket-number,
.state-called .state-label { color: var(--success-text); }

.state-done {
    background: var(--success-bg);
}
.state-done .ticket-number,
.state-done .state-label { color: var(--success-text); }

.state-no_show { background: var(--warn-bg); }
.state-no_show .state-label { color: var(--warn-text); }

.state-dropped { background: var(--danger-bg); }
.state-dropped .ticket-number,
.state-dropped .state-label { color: var(--danger); }

.state-expired { opacity: .6; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.go-to-row, .called-row {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.go-to-caption, .called-caption {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.go-to-location, .called-room {
    font-size: 22px;
    font-weight: 700;
}

.go-to-aras { font-size: 13px; color: var(--muted); }

.ahead-row {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ahead-count { font-size: 32px; font-weight: 700; }
.ahead-label { font-size: 12px; color: var(--muted); }
.ahead-estimate { font-size: 11px; color: var(--muted); font-style: italic; }

.done-row {
    margin-top: 8px;
    display: flex;
    justify-content: center;
}

.done-caption {
    font-size: 13px;
    color: var(--success-text);
    line-height: 1.5;
}

.no-show-row {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.no-show-caption {
    font-size: 13px;
    font-weight: 600;
    color: var(--warn-text);
    line-height: 1.5;
}

.state-dropped .no-show-caption { color: var(--danger); }

.no-show-recall {
    font-size: 12px;
    color: var(--muted);
}

.alert-row { text-align: center; }
.alert-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* What enabling notifications actually did: on / blocked / unsupported. */
.alert-status {
    margin: 8px 0 0;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    text-align: left;
}

.alert-status.is-ok { background: var(--success-bg); color: var(--success-text); }
.alert-status.is-warn { background: var(--warn-bg); color: var(--warn-text); }

.btn {
    border: none;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-block { width: 100%; }
a.btn { display: block; box-sizing: border-box; text-align: center; text-decoration: none; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 0 0 8px;
}

.list { display: flex; flex-direction: column; gap: 6px; }

.list-item {
    background: var(--surface);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: var(--ink);
    box-shadow: var(--shadow-card);
}

.recent-number { font-weight: 700; }
.recent-facility { color: var(--muted); font-size: 13px; }

.install-row { margin-top: 4px; }

.ios-hint {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.footer-note {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
    margin-top: 8px;
}

.footer-note a {
    color: var(--primary);
    text-decoration: none;
}

/* ---- lost-ticket lookup (/semak) ---- */
.lookup-card {
    text-align: left;
    align-items: stretch;
    gap: 14px;
}

#lookupForm {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.lookup-title {
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    text-align: center;
}

.lookup-hint {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    text-align: center;
    line-height: 1.5;
}

.lookup-hint-flow {
    font-size: 12px;
    opacity: .8;
}

.lookup-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.lookup-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary-bg);
    color: var(--primary-ink);
    display: grid;
    place-items: center;
    font-size: 26px;
}

.geo-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
}

.geo-status.is-found {
    color: var(--success-text);
    background: var(--success-bg);
}

.geo-status .fa-svg {
    display: none;
}

.geo-status.is-detecting .geo-icon-detecting,
.geo-status.is-found .geo-icon-found {
    display: inline-block;
}

.form-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.form-error .fa-svg {
    font-size: 18px;
    margin-top: 1px;
}

/* ---- stage reminder banner (near + vital-sign / doctor-return) ---- */
.stage-reminder {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

/* ---- journey flow stepper ---- */
.flow-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.flow-head .section-title { margin: 0; }

.flow-progress-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-ink);
    background: var(--primary-bg);
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
}

.flow-bar {
    height: 5px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    margin-bottom: 16px;
}

.flow-bar-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 999px;
    transition: width .4s ease;
}

.flow-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.flow-step {
    position: relative;
    display: flex;
    gap: 12px;
    padding-bottom: 18px;
}

.flow-step:last-child {
    padding-bottom: 0;
}

.flow-step::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 24px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.flow-step:last-child::before {
    display: none;
}

.flow-marker {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    background: var(--surface);
    border: 2px solid var(--border);
}

.flow-body {
    flex: 1;
    padding-top: 2px;
}

.flow-label {
    font-size: 14px;
    font-weight: 600;
}

.flow-location {
    font-size: 12px;
    color: var(--muted);
}

.flow-caption {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-variant-numeric: tabular-nums;
}

.flow-step.is-done .flow-marker {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.flow-step.is-done .flow-caption { color: var(--success-text); }

.flow-step.is-current .flow-marker {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 0 var(--primary-bg);
    animation: flow-pulse 1.8s ease-out infinite;
}

.flow-step.is-current .flow-label { color: var(--primary-ink); }
.flow-step.is-current .flow-caption { color: var(--primary-ink); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
    .flow-step.is-current .flow-marker { animation: none; }
}

@keyframes flow-pulse {
    0% { box-shadow: 0 0 0 0 var(--primary-bg); }
    70% { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.step {
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: .5;
    transition: opacity .2s ease;
}

.step.is-active {
    opacity: 1;
}

.step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    min-height: 28px;
    cursor: pointer;
}

.step-text {
    flex: 1;
}

.step-icon {
    color: var(--primary-ink);
    font-size: 15px;
}

.step-badge {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--border);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.step.is-active .step-badge {
    background: var(--primary);
    color: #fff;
}

.step.is-done .step-badge {
    background: var(--success);
    color: #fff;
}

.step-check {
    display: none;
    font-size: 11px;
}

.step.is-done .step-num {
    display: none;
}

.step.is-done .step-check {
    display: block;
}

.select-wrap,
.input-wrap {
    position: relative;
}

.select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 44px;
}

.select-caret {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted);
    font-size: 14px;
}

.step.is-active .select-caret {
    color: var(--primary-ink);
}

.step select,
.step input {
    width: 100%;
    font: inherit;
    font-size: 16px; /* 16px stops iOS Safari from zooming in on focus */
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
}

.step select:disabled {
    opacity: .6;
}

.step select:focus-visible,
.step input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}

.input-wrap input#number {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .04em;
    text-align: center;
    min-height: 56px;
    padding-left: 44px;
    padding-right: 48px;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 16px;
    pointer-events: none;
}

.input-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 18px;
    cursor: pointer;
}

.input-clear:active {
    background: var(--primary-bg);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
}

.section-title .fa-svg,
.footer-note .fa-svg {
    margin-right: 6px;
}

.recent-item {
    gap: 10px;
    min-height: 48px;
}

.recent-icon {
    color: var(--primary-ink);
}

.recent-number {
    flex: 1;
}

.recent-go {
    color: var(--muted);
}

/* ---- Select2 (searchable facility/service pickers) — skinned to match
   the .step inputs above instead of Select2's default light theme ---- */
.select-wrap.js-select2 .select-caret {
    display: none;
}

.select-wrap .select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    height: 48px;
    display: flex;
    align-items: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--ink);
    font-size: 16px;
    line-height: normal;
    padding-left: 14px;
    padding-right: 36px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--muted);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 46px;
    right: 10px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--muted) transparent transparent transparent;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--muted) transparent;
}

.select2-container--default.select2-container--disabled .select2-selection--single {
    background: var(--surface);
    opacity: .6;
    cursor: not-allowed;
}

.select2-dropdown {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.select2-search--dropdown {
    padding: 8px;
    background: var(--surface);
}

.select2-search--dropdown .select2-search__field {
    font-size: 16px; /* 16px stops iOS Safari from zooming in on focus */
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--ink);
    outline: none;
}

.select2-results__option {
    padding: 10px 14px;
    font-size: 15px;
    color: var(--ink);
}

.select2-results__group {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: 8px 14px 4px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--primary);
    color: #fff;
}

.select2-results__option[aria-selected="true"] {
    background: var(--primary-bg);
    color: var(--primary-ink);
}

/* ============================================================
   /semak — layout polish + motion (body.lookup-page only, so the ticket
   page that shares this stylesheet is untouched).

   Motion is calm and purposeful: ease-out, 150–450ms, no bounce. The
   entrance is keyed off html.lk-js (set by a one-line inline script in
   the page <head>), so it starts on first paint with no flash, and a
   page without JS simply shows everything. Entrance keyframes only
   define `from`, so the end state is always the element's own style.
   Everything is switched off under prefers-reduced-motion (bottom).
   ============================================================ */
@keyframes lk-rise {
    from { opacity: 0; transform: translateY(12px); }
}

@keyframes lk-drop {
    from { opacity: 0; transform: translateY(-8px); }
}

@keyframes lk-pop {
    from { opacity: 0; transform: scale(.85); }
}

@keyframes lk-reveal {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
}

@keyframes lk-tick {
    from { opacity: 0; transform: translateY(6px); }
}

@keyframes lk-ring {
    0% { opacity: .55; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.45); }
}

@keyframes lk-breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

@keyframes lk-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

@keyframes lk-spin {
    to { transform: rotate(360deg); }
}

/* ---- entrance: top bar -> card -> hero -> title/hints -> footer ---- */
.lk-js .lookup-page .lk-enter {
    animation: lk-rise .45s cubic-bezier(.2, .8, .2, 1) both;
}

.lk-js .lookup-page .lookup-card.lk-enter { animation-delay: .05s; }
.lk-js .lookup-page .footer-note.lk-enter { animation-delay: .2s; }

.lk-js .lookup-page .lookup-icon {
    animation: lk-pop .45s cubic-bezier(.2, .8, .2, 1) .12s both;
}

.lk-js .lookup-page .lookup-title {
    animation: lk-rise .4s cubic-bezier(.2, .8, .2, 1) .18s both;
}

.lk-js .lookup-page .lookup-hint {
    animation: lk-rise .4s cubic-bezier(.2, .8, .2, 1) .24s both;
}

.lk-js .lookup-page .lookup-hint-flow {
    animation-delay: .28s;
}

.lk-js .lookup-page #lookupForm {
    animation: lk-rise .45s cubic-bezier(.2, .8, .2, 1) .26s both;
}

/* The card shakes once when the server sent the form back with an error. */
.lookup-page .lookup-card.lk-shake {
    animation: lk-shake .4s ease-in-out;
}

/* ---- hero icon with a soft ring that pulses twice ---- */
.lookup-hero {
    position: relative;
    display: inline-block;
    margin-bottom: 4px;
}

.lookup-hero::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: 16px;
    border: 2px solid var(--primary);
    opacity: 0;
    pointer-events: none;
}

.lk-js .lookup-page .lookup-hero::after {
    animation: lk-ring 1.6s ease-out .6s 2;
}

/* ---- progress bar across the top of the card ---- */
.lookup-progress {
    height: 4px;
    margin: -8px 0 4px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.lookup-progress-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .45s cubic-bezier(.2, .8, .2, 1), background-color .3s ease;
}

.lookup-progress.is-complete .lookup-progress-fill {
    background: var(--success);
}

/* ---- steps ---- */
.lookup-page .step {
    transition: opacity .25s ease, transform .25s ease;
}

.lookup-page .step:not(.is-active) {
    transform: translateY(3px);
}

.lookup-page .step-badge {
    transition: background-color .25s ease, color .25s ease;
}

.lookup-page .step.is-done .step-check {
    animation: lk-pop .3s cubic-bezier(.2, .8, .2, 1);
}

.lookup-page .step select,
.lookup-page .step input {
    transition: border-color .2s ease, box-shadow .2s ease;
}

.lookup-page .step select:focus,
.lookup-page .step input:focus,
.lookup-page .select2-container--focus .select2-selection--single,
.lookup-page .select2-container--open .select2-selection--single {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
    outline: none;
}

.lookup-page .select2-selection--single {
    transition: border-color .2s ease, box-shadow .2s ease;
}

.lookup-page .select2-dropdown {
    animation: lk-drop .18s ease-out;
}

/* The step a server error belongs to: red ring + red badge (its number, not
   a tick) until the patient changes it. */
.lookup-page .step.has-error .step-badge {
    background: var(--danger);
    color: #fff;
}

.lookup-page .step.has-error .step-check { display: none; }
.lookup-page .step.has-error .step-num { display: inline; }

.lookup-page .step.has-error select,
.lookup-page .step.has-error input,
.lookup-page .step.has-error .select2-selection--single {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-bg);
}

.lk-js .lookup-page .form-error {
    animation: lk-drop .35s ease-out .3s both;
}

/* ---- live "ticket stub" preview ---- */
.lookup-preview {
    display: flex;
    align-items: stretch;
    border-radius: 14px;
    background: var(--primary-bg);
    color: var(--ink);
    overflow: hidden;
}

.lookup-preview.lk-reveal {
    animation: lk-reveal .35s cubic-bezier(.2, .8, .2, 1);
}

.lookup-preview-main {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lookup-preview-caption {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.lookup-preview-service,
.lookup-preview-facility {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lookup-preview-service {
    font-size: 15px;
    font-weight: 700;
}

.lookup-preview-facility {
    font-size: 12px;
    color: var(--muted);
}

/* The tear-off end: dashed perforation with a notch cut top and bottom
   (the notches take the card's own colour, so they read as holes). */
.lookup-preview-stub {
    position: relative;
    flex: 0 0 auto;
    min-width: 96px;
    padding: 12px 14px;
    border-left: 2px dashed var(--primary-bg);
    border-left-color: rgba(59, 91, 219, .35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lookup-preview-stub::before,
.lookup-preview-stub::after {
    content: "";
    position: absolute;
    left: -9px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface);
}

.lookup-preview-stub::before { top: -8px; }
.lookup-preview-stub::after { bottom: -8px; }

.lookup-preview-number {
    display: inline-block;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    color: var(--primary-ink);
    font-variant-numeric: tabular-nums;
}

.lookup-preview-number.lk-tick {
    animation: lk-tick .2s ease-out;
}

/* ---- submit: press feedback + busy spinner ---- */
.lookup-submit {
    box-shadow: 0 8px 18px -10px rgba(59, 91, 219, .8);
    transition: transform .12s ease, box-shadow .2s ease, opacity .2s ease;
}

.lookup-submit:active {
    transform: scale(.98);
}

@media (hover: hover) {
    .lookup-submit:hover {
        transform: translateY(-1px);
        box-shadow: 0 12px 22px -10px rgba(59, 91, 219, .85);
    }
}

.lookup-submit:disabled {
    cursor: progress;
    opacity: .9;
    transform: none;
}

.lookup-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lk-spin .7s linear infinite;
}

.lookup-submit.is-loading .lookup-spinner { display: inline-block; }
.lookup-submit.is-loading .lookup-submit-icon { display: none; }

.lookup-submit-icon {
    display: inline-flex;
}

/* ---- geolocation pill ---- */
.lookup-page .geo-status:not([hidden]) {
    animation: lk-pop .3s cubic-bezier(.2, .8, .2, 1);
}

.lookup-page .geo-status.is-detecting .geo-icon-detecting {
    animation: lk-breathe 1.2s ease-in-out infinite;
}

.lookup-page .geo-status.is-found .geo-icon-found {
    animation: lk-pop .35s cubic-bezier(.2, .8, .2, 1);
}

/* ---- dark-mode switch (top bar) ---- */
.theme-switch {
    flex-shrink: 0;
    margin: -8px -6px -8px 0;
    padding: 8px 6px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.theme-switch-track {
    position: relative;
    display: block;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    background: var(--border);
    transition: background-color .25s ease;
}

.theme-switch-icon {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30px;
    display: grid;
    place-items: center;
    font-size: 13px;
    color: var(--muted);
    transition: color .25s ease;
}

.theme-switch-sun { left: 0; }
.theme-switch-moon { right: 0; }

/* The knob sits over one icon; the other one shows what a tap switches to. */
.theme-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
    transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}

.theme-switch[aria-checked="true"] .theme-switch-track { background: var(--primary); }
.theme-switch[aria-checked="true"] .theme-switch-knob { transform: translateX(22px); }
.theme-switch[aria-checked="true"] .theme-switch-icon { color: rgba(255, 255, 255, .85); }

.theme-switch:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 0;
}

/* Colours cross-fade for ~300ms when the theme flips (lookup.js adds
   .theme-anim to <html> around the flip). Skipped for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
    html.theme-anim,
    html.theme-anim body,
    html.theme-anim body * {
        transition: background-color .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease !important;
    }
}

/* ---- reduced motion: everything still, except the busy spinner,
   which is feedback rather than decoration ---- */
@media (prefers-reduced-motion: reduce) {
    .lookup-page *,
    .lookup-page *::before,
    .lookup-page *::after {
        animation: none !important;
        transition: none !important;
    }

    .lookup-page .lookup-submit.is-loading .lookup-spinner {
        animation: lk-spin .7s linear infinite !important;
    }
}

/* ---- third-party QMS: notified only when called ---- */
.called-only-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-top: 12px;
    padding: 14px;
    border-radius: 14px;
    background: var(--warn-bg);
    border: 1px solid var(--warn-text);
    border-left-width: 5px;
    color: var(--ink);
    text-align: left;
}
.called-only-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--warn-text);
    color: #fff;
}
.called-only-icon .fa-svg { width: 18px; height: 18px; }
.called-only-body { min-width: 0; }
.called-only-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--warn-text);
}
.called-only-title-en { font-weight: 600; opacity: .85; }
.called-only-line { margin: 0; font-size: 14px; line-height: 1.45; font-weight: 500; }
.called-only-en {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
    color: var(--muted);
}
.called-only-card.is-compact { margin-top: 10px; padding: 12px; }
.called-only-card.is-compact .called-only-icon { width: 30px; height: 30px; }
.called-only-card.is-compact .called-only-icon .fa-svg { width: 15px; height: 15px; }
.called-only-card.is-compact .called-only-title { font-size: 14px; }
.called-only-card.is-compact .called-only-line { font-size: 13px; }
.called-only-card.is-compact .called-only-en { font-size: 12px; }
