/* Country, phone, address and map (CountryPicker, PhoneInput, AddressInput, MapPreview). The demo has none of them: they are
   built from its field (app.css .field, kit.css .field.dd, .with-icon), list box (kit.css .lb-list, .lb-opt, .lb-search) in the
   floating popover, dialog scrim and tokens. List rows keep the list box's 33.5px line at a fixed height with no gap, so the
   virtual list can place them. */

/* Flags: the vendored 4:3 SVGs at 20 by 15, on a hairline so white flags keep their edge. Images only: the demo's volume line has
   its own « Above threshold » .flag (app.css .mount-sub .flag), which a bare .flag squeezed into a 20px box past the card edge. */
img.flag { flex: none; width: 20px; height: 15px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px var(--line); background: var(--sunken); }

/* Country picker: flag, name (ellipsized) and chevron in the .field.dd trigger; code or calling code on the right of each row. */
.cty-pick { justify-content: flex-start; min-width: 0; }
.cty-pick .cty-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cty-pick > .icon { margin-left: auto; }
.popover.cty-pop { width: min(340px, calc(100vw - 16px)); }
.cty-list { display: block; }
.cty-list .lb-opt { position: relative; height: 33.5px; padding-block: 0; cursor: pointer; white-space: nowrap; }
.cty-list .lb-opt.is-active { background: var(--sunken); }
.cty-list .lb-opt.is-lead::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 1px; background: var(--line); }
.cty-opt .cty-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lb-opt.cty-opt .cty-hint { flex: none; margin-left: 0; }
.lb-opt.cty-opt > .icon { margin-left: -4px; }

/* Phone: the prefix (flag, calling code, chevron) joined to the number, one control on one 32.5px line. */
.phone-input { display: flex; min-width: 0; }
.phone-input > .cty-prefix { flex: none; width: auto; gap: 6px; padding: 0 8px; border-top-right-radius: 0; border-bottom-right-radius: 0; font-variant-numeric: tabular-nums; }
.phone-input > .cty-prefix .cty-value { flex: none; }
.phone-input > input.field { flex: 1; min-width: 0; margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; font-variant-numeric: tabular-nums; }
.phone-input > .field:focus, .phone-input > .field[aria-expanded="true"], .phone-input > .field.invalid { position: relative; z-index: 1; }
.fgroup .phone-input, .srow-control .phone-input { width: 100%; }

/* Address: the search above the structured fields, at most the 560px of a settings control. */
.addr { display: grid; gap: 10px; min-width: 0; max-width: 560px; margin: 0; padding: 0; border: 0; }
.addr > legend { padding: 0; margin-bottom: 6px; }
.addr-search { position: relative; }
.addr-search .field { width: 100%; }
.addr-search .addr-spin { position: absolute; right: 10px; top: 50%; margin-top: -6.5px; color: var(--ink-3); }
.addr-search input[type="search"]::-webkit-search-cancel-button { margin-right: 18px; }
/* The « coming soon » hint holds the search field's 32.5px line, so the fields below never move when the answer comes back. */
.addr-soon { display: flex; align-items: center; gap: 6px; min-height: 32.5px; margin: 0; }
.addr-soon .icon { flex: none; }
.addr-grid { display: grid; gap: 10px 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); grid-template-areas: "street street" "postal city" "region country"; }
.addr-grid.no-region { grid-template-areas: "street street" "postal city" "country country"; }
.addr-grid.with-line2 { grid-template-areas: "street street" "line2 line2" "postal city" "region country"; }
.addr-grid.with-line2.no-region { grid-template-areas: "street street" "line2 line2" "postal city" "country country"; }
.addr-grid .field { width: 100%; }
.addr-street { grid-area: street; }
.addr-line2 { grid-area: line2; }
.addr-postal { grid-area: postal; }
.addr-city { grid-area: city; }
.addr-region { grid-area: region; }
.addr-country { grid-area: country; }
.addr-map { margin-top: 2px; }
@media (max-width: 520px) {
  .addr-grid, .addr-grid.no-region { grid-template-areas: "street street" "postal city" "region region" "country country"; }
  .addr-grid.with-line2, .addr-grid.with-line2.no-region { grid-template-areas: "street street" "line2 line2" "postal city" "region region" "country country"; }
}
.popover.addr-pop { max-width: calc(100vw - 16px); }
.addr-list { display: block; }
.addr-list .lb-opt { height: 46px; padding-block: 0; cursor: pointer; }
.addr-list .lb-opt.is-active { background: var(--sunken); }
.addr-pin { flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-3); }
.addr-lines { display: grid; min-width: 0; line-height: 1.35; }
.addr-lines > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-opt .addr-lines .addr-detail { margin-left: 0; }
.addr-attr { margin-top: 4px; padding: 6px 8px 1px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); }

/* Map: a sunken frame (md radius, hairline) holding Leaflet, isolated so its panes never rise over the topbar or a popover. */
.map-prev { position: relative; isolation: isolate; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--sunken); }
.map-canvas { position: absolute; inset: 0; z-index: 0; }
/* Leaflet's stylesheet is added after this one on first use: the overrides below carry one class more (.map-leaf is the container,
   which Leaflet marks .leaflet-container). */
.map-leaf.leaflet-container { background: var(--sunken); font: inherit; }
.map-expand { position: absolute; top: 8px; right: 8px; z-index: 1; box-shadow: var(--shadow-1); }
.map-note { display: flex; align-items: center; justify-content: center; gap: 10px; height: 100%; padding: 14px 17px; font-size: 12.5px; text-align: left; }
.map-note p { display: grid; gap: 2px; max-width: 40ch; min-width: 0; }
/* A place without a map (not located yet, no tile source): a faint street grid behind the card, never mistaken for a real map. */
.map-prev.is-note { background-image: linear-gradient(color-mix(in oklab, var(--line) 60%, transparent) 1px, transparent 1px),
  linear-gradient(90deg, color-mix(in oklab, var(--line) 60%, transparent) 1px, transparent 1px); background-size: 22px 22px; background-position: -1px -1px; }
.map-prev.is-note { display: flex; align-items: center; justify-content: center; padding: 10px; }
.map-prev.is-note .map-note { height: auto; max-width: 100%; max-height: 100%; padding: 9px 13px 9px 11px; overflow: hidden; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow-1); }
.map-note-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 600; }
.map-note .link { font-weight: 600; color: var(--accent); }
.map-note-pin { flex: none; fill: none; stroke: var(--ink-3); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.map-pin { background: none; border: 0; }
.map-pin svg { display: block; overflow: visible; filter: drop-shadow(0 2px 2px rgba(6, 22, 65, 0.3)); }
.map-pin-body { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.map-pin-dot { fill: var(--surface); }
.map-leaf.leaflet-container .leaflet-control-attribution { padding: 1px 6px; border-top-left-radius: 6px; background: color-mix(in oklab, var(--surface) 88%, transparent); color: var(--ink-2); font-size: 10.5px; line-height: 1.5; }
.map-leaf.leaflet-container .leaflet-control-attribution a { color: var(--accent); }
.map-leaf.leaflet-container .leaflet-bar { border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.map-leaf.leaflet-container .leaflet-bar a { background: var(--surface); color: var(--ink); border-bottom-color: var(--line); }
.map-leaf.leaflet-container .leaflet-bar a:hover, .map-leaf.leaflet-container .leaflet-bar a:focus { background: var(--sunken); }
.map-leaf.leaflet-container .leaflet-tooltip { padding: 6px 9px; border: 0; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 11.5px; font-weight: 500; box-shadow: var(--shadow-pop); }
.map-leaf.leaflet-container .leaflet-tooltip-top::before { border-top-color: var(--ink); }
/* At night the day tiles are turned to the navy well instead of glaring white. */
[data-theme="dark"] .map-leaf.leaflet-container .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.88) contrast(0.88) saturate(0.55); }

/* The large view: the dialog's chrome, wide enough for a map. */
.map-host { position: fixed; inset: 0; z-index: 90; }
.dialog.map-dialog { width: min(960px, 100%); padding: 14px; }
.map-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.map-dialog-head h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.map-big { position: relative; isolation: isolate; height: min(70vh, 640px); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.map-big:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
