/* ==========================================================================
   TravelOptions — light and dark
   Shared by the public site (layout_inner_page2) and the signed-in panel
   (panel/shell), loaded from partials/theme-boot right after each area's own
   token block. partials/theme-boot sets <html data-theme="light|dark"> before
   the first paint; nothing here ever tests "system".

   1. Semantic tokens both themes need (light values here, dark below)
   2. The dark palette: the same token names, re-pointed
   3. Swapping themes without a flicker
   4. Things only the theme decides: logos, the switches themselves

   Rules for new CSS: never write a raw #fff / #000 / grey for something that
   should follow the theme. Use:
     --to-page      the page behind everything
     --to-card      cards, menus, popovers, fields that sit on the page
     --to-surface   wells, chips, hover fills, field fills (raised in dark)
     --to-ink / --to-on-ink   ink as a fill (primary dark button) and the text on it
     --to-night     a deliberately dark band (photo captions, the AI band): dark in both themes
     --to-ok/-bad/-warn/-info (+ -bg)   status text on its own tint, AA in both themes
   White text on a photo or on the brand red stays #fff: it is white in both.
   ========================================================================== */

/* ---------- 1. Semantic tokens (light) ---------- */
:root {
    color-scheme: light;

    --to-page: #fff;
    --to-on-ink: #fff;
    --to-ink-hover: #000;
    --to-night: #15151a;
    --to-line-3: #b9b9c4;             /* a border under the pointer */
    --to-surface-hover: #eef0f3;      /* a surface-filled field under the pointer */
    --to-placeholder: #8d8d98;
    --to-faint: #a9a9b3;              /* disabled text, past days */
    --to-glass: rgba(255, 255, 255, .88);
    --to-scrim: rgba(15, 15, 20, .38);
    --to-ring: 0 0 0 3px rgba(21, 21, 26, .08);
    --to-photo: #e3e5ea;              /* behind a photo that has not loaded */

    --to-ok: #067647;   --to-ok-bg: #ecfdf3;   --to-ok-line: #abefc6;
    --to-bad: #b42318;  --to-bad-bg: #fef3f2;  --to-bad-line: #d92d20;
    --to-warn: #8a5300; --to-warn-bg: #fff4e0; --to-warn-line: #f5dca0;
    --to-info: #1b56c4; --to-info-bg: #e9f0fe; --to-info-line: #c7d8fb;
    --to-star: #f5a524;

    /* Accent pairs used for category tiles (icon ink on its tint). */
    --to-blue: #2563eb;   --to-blue-bg: #e8f1ff;
    --to-green: #15803d;  --to-green-bg: #e6f6ec;
    --to-orange: #c2410c; --to-orange-bg: #fff3e0;
    --to-violet: #6d28d9; --to-violet-bg: #f1ebff;
}

/* ---------- 2. Dark ----------
   Cool near-black, the same family as the app's dark palette (mobile/src/theme/tokens.ts).
   Elevation reads as "lighter", not "more shadow": page < card < surface. Shadows get
   deeper and every one carries a faint light hairline so edges survive on black. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --to-ink: #f3f3f6;
    --to-ink-2: #c9c9d1;
    --to-muted: #9b9ba6;
    --to-line: #2a2a31;
    --to-line-2: #3a3a43;
    --to-line-3: #52525c;
    --to-surface: #222228;
    --to-surface-2: #1b1b20;
    --to-surface-hover: #2a2a31;
    --to-card: #17171c;
    --to-page: #0e0e11;

    --to-on-ink: #15151a;
    --to-ink-hover: #fff;
    --to-night: #1c1c22;
    --to-placeholder: #7f7f8a;
    --to-faint: #5f5f69;
    --to-glass: rgba(14, 14, 17, .8);
    --to-scrim: rgba(0, 0, 0, .62);
    --to-ring: 0 0 0 3px rgba(255, 255, 255, .12);
    --to-photo: #26262d;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
    --sh-2: 0 8px 28px -8px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .07);
    --sh-3: 0 20px 52px -16px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .08);

    --to-ok: #5cc98f;   --to-ok-bg: #11251a;   --to-ok-line: #1f5a3a;
    --to-bad: #f48b81;  --to-bad-bg: #2d1615;  --to-bad-line: #e5605a;
    --to-warn: #e9a94e; --to-warn-bg: #2a2010; --to-warn-line: #5e451c;
    --to-info: #8db4ff; --to-info-bg: #131f38; --to-info-line: #2a4272;
    --to-star: #f5b13d;

    --to-blue: #8db4ff;   --to-blue-bg: #15203a;
    --to-green: #5cc98f;  --to-green-bg: #12261b;
    --to-orange: #f59e5b; --to-orange-bg: #2c1a0f;
    --to-violet: #b79cff; --to-violet-bg: #211a38;

    /* Bootstrap 5.3 (public site) builds its components on these. */
    --bs-body-bg: var(--to-page);
    --bs-body-color: var(--to-ink-2);
    --bs-emphasis-color: var(--to-ink);
    --bs-heading-color: var(--to-ink);
    --bs-secondary-color: var(--to-muted);
    --bs-secondary-bg: var(--to-surface);
    --bs-tertiary-bg: var(--to-surface-2);
    --bs-border-color: var(--to-line);
    --bs-border-color-translucent: rgba(255, 255, 255, .1);
    --bs-gray-100: var(--to-surface-2);
    --bs-gray-200: var(--to-surface);
    --bs-gray-300: var(--to-line-2);
    /* alerts, badges and list groups: status text on its own tint */
    --bs-primary-bg-subtle: var(--to-brand-tint); --bs-primary-text-emphasis: var(--to-brand-ink); --bs-primary-border-subtle: rgba(var(--to-brand-rgb), .35);
    --bs-success-bg-subtle: var(--to-ok-bg);      --bs-success-text-emphasis: var(--to-ok);         --bs-success-border-subtle: var(--to-ok-line);
    --bs-danger-bg-subtle: var(--to-bad-bg);      --bs-danger-text-emphasis: var(--to-bad);         --bs-danger-border-subtle: color-mix(in srgb, var(--to-bad) 35%, transparent);
    --bs-warning-bg-subtle: var(--to-warn-bg);    --bs-warning-text-emphasis: var(--to-warn);       --bs-warning-border-subtle: var(--to-warn-line);
    --bs-info-bg-subtle: var(--to-info-bg);       --bs-info-text-emphasis: var(--to-info);          --bs-info-border-subtle: var(--to-info-line);
    --bs-secondary-bg-subtle: var(--to-surface);  --bs-secondary-text-emphasis: var(--to-ink-2);    --bs-secondary-border-subtle: var(--to-line);
    --bs-light-bg-subtle: var(--to-surface-2);    --bs-light-text-emphasis: var(--to-ink-2);        --bs-light-border-subtle: var(--to-line);
    --bs-dark-bg-subtle: var(--to-surface);       --bs-dark-text-emphasis: var(--to-ink);           --bs-dark-border-subtle: var(--to-line-2);
}

/* Bootstrap's white/light/dark utilities share one RGB variable between text and
   background (.text-white and .bg-white both read --bs-white-rgb), so re-pointing the
   variable would turn white captions on photos dark. Re-point the backgrounds only. */
:root[data-theme="dark"] .bg-white { background-color: var(--to-card) !important; }
:root[data-theme="dark"] .bg-light { background-color: var(--to-surface) !important; }
:root[data-theme="dark"] .text-dark, :root[data-theme="dark"] .text-black { color: var(--to-ink) !important; }

/* ---------- 3. Swapping ---------- */
/* For the frame of a swap, nothing transitions: otherwise every element with a
   colour transition fades at its own speed and the page shimmers. */
.to-theme-swap *, .to-theme-swap *::before, .to-theme-swap *::after { transition: none !important; }

/* Where the browser supports view transitions, the whole page cross-fades once. */
.to-theme-fade::view-transition-old(root),
.to-theme-fade::view-transition-new(root) { animation-duration: 240ms; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }

/* ---------- 4. Theme-owned details ---------- */

/* Logos: print both, show the one that reads on this background. */
.to-logo-dark { display: none !important; }
:root[data-theme="dark"] .to-logo-light { display: none !important; }
:root[data-theme="dark"] .to-logo-dark { display: inline-block !important; }

/* Photos and user content keep their colours; only decorative images that are drawn
   for a light background get a soft lift so they do not glare. */
:root[data-theme="dark"] img.to-dim-dark { filter: brightness(.9) contrast(1.05); }

/* Device / Light / Dark switch */
.to-tswitch {
    display: inline-flex; gap: 2px; padding: 3px;
    border-radius: 999px; background: var(--to-surface);
    box-shadow: inset 0 0 0 1px var(--to-line);
}
.to-tswitch__opt {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
    background: transparent; color: var(--to-muted);
    font: 600 13px/1 var(--to-font, system-ui, sans-serif); cursor: pointer; white-space: nowrap;
    transition: background-color 160ms cubic-bezier(.22, 1, .36, 1), color 160ms cubic-bezier(.22, 1, .36, 1), box-shadow 160ms cubic-bezier(.22, 1, .36, 1);
}
.to-tswitch__opt:hover { color: var(--to-ink); }
.to-tswitch__opt[aria-checked="true"] { background: var(--to-card); color: var(--to-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--to-line); }
.to-tswitch__opt:focus-visible { outline: 2px solid var(--to-ink); outline-offset: 1px; }
.to-tswitch__opt svg { flex-shrink: 0; }
.to-tswitch--icons .to-tswitch__opt { width: 32px; padding: 0; }
.to-tswitch--icons .to-tswitch__opt span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (pointer: coarse) { .to-tswitch__opt { min-height: 44px; } .to-tswitch--icons .to-tswitch__opt { width: 44px; } }

/* One-tap toggle: moon in light (tap for dark), sun in dark (tap for light).
   The glyph turns as it changes, like a dial. */
.to-ttoggle { position: relative; }
.to-ttoggle svg { transition: transform 320ms cubic-bezier(.34, 1.4, .64, 1), opacity 200ms cubic-bezier(.22, 1, .36, 1); }
.to-ttoggle .to-ttoggle__sun { position: absolute; inset: 0; margin: auto; opacity: 0; transform: rotate(-90deg) scale(.6); }
:root[data-theme="dark"] .to-ttoggle .to-ttoggle__moon { opacity: 0; transform: rotate(90deg) scale(.6); }
:root[data-theme="dark"] .to-ttoggle .to-ttoggle__sun { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    .to-tswitch__opt, .to-ttoggle svg { transition: none; }
}
