/* ============================================================
   Time zone picker (js/tz-picker.js) on /sessions/, /booking, /el/booking and
   /de/termin-buchen. Loaded after /css/site.css.

   .tz             the root (the page gives it its width, see .sx-tz)
   .tz-button      the closed control: flag, city, offset, caret
   .tz-panel       the dropdown: .tz-search, then .tz-list of .tz-group
                   headings and .tz-option rows, .tz-none when nothing matches
   .tz-flag        one 20x15 cell of /img/flags.webp (16 columns, --fx/--fy)
   Motion          the panel fades and drops 4px in, the same way out
============================================================ */

.tz { position: relative; min-width: 0; --e: var(--ease-in-out); }
.tz:hover, .tz.is-open { --e: var(--ease-out); }

.tz-button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--line-2); border-radius: var(--r-control);
    background: var(--surface); color: var(--ink);
    font: 500 14px/1.2 var(--sans); text-align: left; cursor: pointer;
    transition: border-color var(--dur-1) var(--e), background-color var(--dur-1) var(--e), box-shadow var(--dur-1) var(--e);
}
.tz-button:focus { outline: none; }
.tz-button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tz.is-open .tz-button { border-color: var(--honey); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--honey) 22%, transparent); }
@media (hover: hover) {
    .tz-button:hover { border-color: rgba(31, 27, 22, .28); background: #fff; }
    .tz-button:hover .tz-caret { translate: 0 calc(var(--nudge) / 2); }
}
.tz-current { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.tz-current-city { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tz-current-off { margin-left: auto; color: var(--ink-3); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tz-caret {
    width: 16px; height: 16px; flex: 0 0 16px;
    fill: none; stroke: var(--ink-3); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
    transition: translate var(--dur-2) var(--e), rotate var(--dur-2) var(--e);
}
.tz.is-open .tz-caret { rotate: 180deg; translate: 0 0; }

/* Flags: one sprite, 20x15 cells. The inset line keeps white flags (Japan, Cyprus) visible. */
.tz-flag {
    position: relative; flex: 0 0 20px; width: 20px; height: 15px; overflow: hidden;
    border-radius: 3px;
    background: var(--bg-2) url("/img/flags.webp?v=1") no-repeat;
    background-size: 320px auto;
    background-position: calc(var(--fx, 0) * -20px) calc(var(--fy, 0) * -15px);
}
.tz-flag::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(31, 27, 22, .12);
}
.tz-flag--none { display: inline-flex; align-items: center; justify-content: center; background: none; }
.tz-flag--none::after { content: none; }
.tz-flag--none svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 1.75; }

/* ---- Panel ---- */
.tz-panel {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
    width: 360px; min-width: 100%; max-width: calc(100vw - 32px);
    display: flex; flex-direction: column;
    border: 1px solid var(--line); border-radius: var(--r-card);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(31, 27, 22, .05), 0 24px 48px -20px rgba(31, 27, 22, .3);
    opacity: 0; translate: 0 -4px;
    transition: opacity 160ms var(--ease-out), translate 180ms var(--ease-out);
}
.tz-panel.is-right { left: auto; right: 0; }
.tz-panel.is-in { opacity: 1; translate: 0 0; }

.tz-search { position: relative; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.tz-search-icon {
    position: absolute; left: 22px; top: 50%; translate: 0 calc(-50% + 1px);
    width: 16px; height: 16px; pointer-events: none;
    fill: none; stroke: var(--ink-3); stroke-width: 1.75; stroke-linecap: round;
}
.tz-input {
    display: block; width: 100%; height: 38px; padding: 0 12px 0 36px;
    border: 1px solid var(--line-2); border-radius: var(--r-control);
    background: var(--bg); color: var(--ink);
    font: 400 15px/1.2 var(--sans);
    transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.tz-input::placeholder { color: var(--ink-3); }
.tz-input:focus { outline: none; border-color: var(--honey); background: #fff; }

.tz-list {
    max-height: min(340px, 50vh); margin: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain;
    list-style: none; scroll-padding: 8px;
    scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.tz-list:focus { outline: none; }
.tz-group { padding: 10px 10px 6px; font-size: 12px; font-weight: 500; line-height: 1.2; color: var(--ink-3); }
.tz-group:first-child { padding-top: 6px; }

.tz-option {
    display: flex; align-items: center; gap: 12px;
    min-height: 44px; padding: 6px 10px;
    border-radius: 8px; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-in-out);
    /* ~420 rows: only the ones in view get laid out and painted */
    content-visibility: auto; contain-intrinsic-size: auto 44px;
}
.tz-option.is-active { background: var(--bg-2); transition-timing-function: var(--ease-out); }
.tz-option[aria-selected="true"] { background: color-mix(in srgb, var(--honey-soft) 45%, var(--surface)); }
.tz-option[aria-selected="true"].is-active { background: color-mix(in srgb, var(--honey-soft) 70%, var(--surface)); }
.tz-name { display: grid; flex: 1; min-width: 0; line-height: 1.25; }
.tz-city { overflow: hidden; font-size: 14px; font-weight: 500; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.tz-sub { overflow: hidden; font-size: 12.5px; color: var(--ink-3); text-overflow: ellipsis; white-space: nowrap; }
.tz-off { flex: 0 0 auto; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tz-check {
    width: 16px; height: 16px; flex: 0 0 16px; visibility: hidden;
    fill: none; stroke: var(--honey-ink); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
}
.tz-option[aria-selected="true"] .tz-check { visibility: visible; }

.tz-none { margin: 0; padding: 20px 16px 24px; font-size: 14px; line-height: 1.5; color: var(--ink-3); text-align: center; }

@media (max-width: 600px) {
    .tz-option { min-height: 48px; }
    .tz-input { font-size: 16px; } /* no zoom on focus in iOS Safari */
}

@media (prefers-reduced-motion: reduce) {
    .tz-panel { translate: none; transition: opacity 120ms linear; }
    .tz-caret { transition: none; }
}
