/* Responsive full-screen presentation for viewer controls, legends, dialog, and parcel details. */
:root {
    color-scheme: light;
    --ink: #17211e;
    --muted: #69726e;
    --paper: rgba(250, 249, 245, .94);
    --paper-solid: #faf9f5;
    --line: rgba(23, 33, 30, .14);
    --accent: #f0643b;
    --accent-dark: #a83b20;
    --shadow: 0 18px 54px rgba(17, 27, 24, .18), 0 2px 8px rgba(17, 27, 24, .1);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body, #app, #viewport { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body { color: var(--ink); background: #b9c9cf; }

button, input, select { font: inherit; }

button { color: inherit; }

#viewport canvas { display: block; width: 100%; height: 100%; outline: none; }

#viewport canvas:focus-visible { box-shadow: inset 0 0 0 3px rgba(240, 100, 59, .75); }

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* --topbar-h is the topbar's real height (min-height + padding + border). The search panel,
   the HUD stack and the detail panel all hang off it, so a change here moves them together
   instead of leaving five hand-tuned `top` values to drift apart. */
/* box-sizing is border-box, so min-height IS the rendered height: 60 desktop, 54 mobile. */
:root { --topbar-gap: 14px; --topbar-h: 60px; --hud-gap: 16px; }

.topbar {
    position: fixed;
    z-index: 20;
    top: max(var(--topbar-gap), env(safe-area-inset-top));
    left: max(var(--topbar-gap), env(safe-area-inset-left));
    right: max(var(--topbar-gap), env(safe-area-inset-right));
    min-height: 60px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 14px;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.46);
    border-radius: 14px;
    background: var(--paper);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(1.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 192px;
    color: inherit;
    text-decoration: none;
    padding: 0 7px 0 3px;
}

.brand__mark { width: 38px; height: 38px; color: var(--accent); flex: none; }
.brand span { display: grid; line-height: 1.05; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 18px; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }

/* The search used to occupy a permanent 260-510px column in the topbar grid. Together with a
   toolbar of nowrap controls that column made the bar need ~1220px, so below that the toolbar
   overflowed and sat on top of the search. It is a panel the search icon opens now. */
.parcel-search {
    position: fixed;
    z-index: 21;
    top: calc(max(var(--topbar-gap), env(safe-area-inset-top)) + var(--topbar-h) + var(--hud-gap));
    left: 50%;
    width: min(510px, calc(100vw - 2 * var(--topbar-gap)));
    display: grid;
    grid-template-columns: minmax(92px, .75fr) auto minmax(120px, 1fr) 42px;
    height: 46px;
    align-items: center;
    transform: translateX(-50%);
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(1.2);
    transition: border-color .18s, box-shadow .18s;
}
/* Without this the display:grid above would defeat the hidden attribute entirely. */
.parcel-search[hidden] { display: none; }

.parcel-search:focus-within { border-color: rgba(240,100,59,.65); box-shadow: 0 0 0 3px rgba(240,100,59,.12); }
.parcel-search input { min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; padding: 0 11px; color: var(--ink); }
.parcel-search input::placeholder { color: #8a928f; }
.parcel-search__separator { color: #a3aaa7; }
.parcel-search > button { align-self: stretch; border: 0; border-left: 1px solid var(--line); background: transparent; cursor: pointer; border-radius: 0 9px 9px 0; }
.parcel-search > button:hover { background: rgba(240,100,59,.1); color: var(--accent-dark); }
.parcel-search svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.parcel-search.is-loading > button svg { animation: search-pulse .75s alternate infinite; }
.parcel-search[aria-disabled="true"] { opacity: .56; }

.search-results {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 0; right: 0;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--paper-solid);
    box-shadow: var(--shadow);
}

.search-results button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 7px; background: none; text-align: left; cursor: pointer; }
.search-results button:hover, .search-results button:focus-visible { background: #f0eee8; outline: none; }

.toolbar { justify-self: end; display: flex; align-items: center; gap: 8px; min-width: 0; }
.segmented { display: inline-flex; min-width: 0; height: 39px; padding: 3px; margin: 0; border: 1px solid var(--line); border-radius: 10px; background: rgba(23,33,30,.055); }
.segmented button, .mobile-mode button { border: 0; border-radius: 7px; background: transparent; padding: 0 10px; font-size: 12px; font-weight: 680; cursor: pointer; white-space: nowrap; }
.segmented button:hover { background: rgba(255,255,255,.55); }
.segmented button[aria-pressed="true"], .mobile-mode button[aria-pressed="true"] { background: white; color: var(--accent-dark); box-shadow: 0 1px 4px rgba(17,27,24,.15); }
.segmented--secondary button { padding-inline: 9px; }

.capacity-select {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 39px;
    padding: 3px 7px 3px 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255,255,255,.45);
    color: var(--muted);
    font-size: 10px;
    font-weight: 760;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.capacity-select select {
    width: 178px;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}
.capacity-select--mobile { display: none; }

.icon-button {
    display: grid; place-items: center;
    width: 39px; height: 39px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255,255,255,.45);
    cursor: pointer;
}
.icon-button:hover { background: white; color: var(--accent-dark); }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.legend {
    position: fixed;
    z-index: 11;
    left: max(20px, env(safe-area-inset-left));
    bottom: max(22px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,.38);
    border-radius: 10px;
    background: var(--paper);
    box-shadow: 0 5px 20px rgba(17,27,24,.12);
    font-size: 11px;
    font-weight: 630;
    backdrop-filter: blur(12px);
}

.capacity-legend {
    position: fixed;
    z-index: 11;
    left: max(20px, env(safe-area-inset-left));
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 52px));
    width: min(560px, calc(100vw - 40px));
    padding: 11px 13px;
    border: 1px solid rgba(255,255,255,.38);
    border-radius: 10px;
    background: var(--paper);
    box-shadow: 0 5px 20px rgba(17,27,24,.12);
    backdrop-filter: blur(12px);
}
.capacity-legend[hidden] { display: none; }
.capacity-legend strong { display: block; margin-bottom: 8px; font-size: 11px; }
.capacity-legend__scale { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.capacity-legend__scale span { display: inline-flex; align-items: center; gap: 5px; color: #414c48; font-size: 10px; }
.capacity-legend__scale i { width: 11px; height: 11px; border: 1px solid rgba(0,0,0,.12); border-radius: 2px; background: var(--capacity-color); }
.capacity-legend small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; }
.legend > div, .legend summary, .legend__details span { display: flex; align-items: center; gap: 6px; }
.legend summary { cursor: pointer; list-style: none; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary::after { content: "⌃"; color: var(--muted); transform: rotate(0); }
.legend details[open] summary::after { transform: rotate(180deg); }
.legend__details { position: absolute; left: 0; bottom: calc(100% + 8px); display: grid; gap: 8px; min-width: 180px; padding: 11px; border-radius: 10px; background: var(--paper-solid); box-shadow: var(--shadow); border: 1px solid var(--line); }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.14); }
.swatch--current { background: #c7c5bf; }
.swatch--maximum { background: #f0643b; }
.line { width: 18px; height: 3px; border-radius: 2px; }
.line--reconstruction { background: #4c78a8; }
.line--deferred { background: #8f63b8; }
.line--blocked { background: #c43d4d; }
.line--other { background: #666; }

.hud-stack {
    position: fixed;
    z-index: 19;
    top: calc(max(var(--topbar-gap), env(safe-area-inset-top)) + var(--topbar-h) + var(--hud-gap));
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 16px);
    transform: translateX(-50%);
    transition: transform .2s;
    pointer-events: none;
}
.hud-stack > * { pointer-events: auto; }
/* Move the stack clear of the search panel rather than letting the two overlap. */
#app:has(#parcel-search:not([hidden])) .hud-stack { transform: translate(-50%, 54px); }

.viewer-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(24,34,31,.82);
    color: white;
    font-size: 11px;
    letter-spacing: .01em;
    pointer-events: none;
    transition: opacity .25s;
}
.viewer-status.is-idle { opacity: 0; }
.viewer-status.is-warning { opacity: 1; background: rgba(126,59,31,.92); }
.viewer-status.is-guidance { opacity: 1; background: rgba(24,34,31,.88); }
.viewer-status__pulse { width: 7px; height: 7px; border-radius: 50%; background: #f58b67; box-shadow: 0 0 0 0 rgba(245,139,103,.55); animation: pulse 1.5s infinite; }
.viewer-status.is-idle .viewer-status__pulse, .viewer-status.is-warning .viewer-status__pulse,
.viewer-status.is-guidance .viewer-status__pulse { animation: none; }

.navigation-help { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(48px, calc(env(safe-area-inset-bottom) + 26px)); margin: 0; padding: 7px 10px; border-radius: 8px; background: rgba(24,34,31,.67); color: rgba(255,255,255,.9); font-size: 10px; pointer-events: none; }
.attribution { position: fixed; z-index: 9; right: max(20px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); margin: 0; padding: 4px 7px; border-radius: 5px; background: rgba(250,249,245,.78); color: #4f5955; font-size: 9px; }
.attribution a { color: inherit; }

.detail-panel {
    position: fixed;
    z-index: 18;
    top: calc(max(var(--topbar-gap), env(safe-area-inset-top)) + var(--topbar-h) + var(--hud-gap));
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: min(360px, calc(100vw - 28px));
    overflow: auto;
    padding: 25px 24px 26px;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 14px;
    background: var(--paper);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(1.1);
    transform: translateX(calc(100% + 28px));
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.detail-panel[aria-hidden="false"] { transform: translateX(0); }
.detail-panel__close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(23,33,30,.06); color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.detail-panel__close:hover { background: rgba(23,33,30,.12); color: var(--ink); }
.eyebrow { margin: 0 0 7px; color: var(--accent-dark); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.detail-panel h2 { margin: 0 36px 6px 0; font-family: Georgia, "Times New Roman", serif; font-size: 27px; font-weight: 600; letter-spacing: -.03em; }
.detail-panel__status { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.detail-panel__warning { margin: -8px 0 16px; padding: 9px 10px; border-radius: 7px; background: #fff1dd; color: #7c4a1f; font-size: 10px; line-height: 1.45; }
.comparison-toggle { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; width: 100%; margin: 0 0 18px; padding: 10px 11px; border: 1px solid rgba(47,128,193,.26); border-radius: 9px; background: rgba(47,128,193,.08); text-align: left; cursor: pointer; }
.comparison-toggle i { width: 13px; height: 13px; border: 2px solid #2f80c1; border-radius: 3px; background: rgba(47,128,193,.24); }
.comparison-toggle span { font-size: 11px; font-weight: 680; }
.comparison-toggle strong { color: #175f91; font-size: 9px; text-transform: uppercase; }
.comparison-toggle[aria-pressed="false"] { opacity: .67; }
.comparison-toggle[aria-pressed="false"] i { background: transparent; }
.detail-sections { display: grid; gap: 19px; }
.detail-section h3 { margin: 0 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 14px; margin: 0; border-top: 1px solid var(--line); }
.detail-grid dt, .detail-grid dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { max-width: 180px; font-weight: 650; text-align: right; overflow-wrap: anywhere; }
/* Jump from a GUP 2025 concept in the panel to the provision that imposes it. */
.detail-grid .gup-link { color: inherit; text-decoration: underline dotted rgba(23,33,30,.42); text-underline-offset: 3px; }
.detail-grid .gup-link:hover, .detail-grid .gup-link:focus-visible { color: var(--accent-dark); text-decoration-color: var(--accent-dark); }
.detail-panel__action { display: inline-flex; align-items: center; justify-content: center; width: 100%; margin-top: 18px; padding: 11px 14px; border-radius: 9px; background: var(--ink); color: white; text-decoration: none; font-size: 12px; font-weight: 700; }
.detail-panel__action:hover { background: #2d3b37; }
.detail-panel__links { display: grid; gap: 7px; margin-top: 22px; }
.detail-panel__links a { display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 700; }
.detail-panel__links a::after { content: "→"; color: var(--accent-dark); }
.detail-panel__links a:hover { border-color: rgba(240,100,59,.45); background: rgba(240,100,59,.06); }
.detail-panel__version { margin: 18px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.detail-panel__version.is-warning { color: #8a5426; }
.detail-panel__legal { margin: 18px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: max(74px, calc(env(safe-area-inset-bottom) + 16px)); transform: translateX(-50%); max-width: min(460px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 9px; background: #17211e; color: white; box-shadow: var(--shadow); font-size: 12px; text-align: center; }

.info-dialog { width: min(560px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 30px; border: 1px solid rgba(255,255,255,.4); border-radius: 15px; background: var(--paper-solid); color: var(--ink); box-shadow: var(--shadow); }
.info-dialog::backdrop { background: rgba(15,22,20,.42); backdrop-filter: blur(4px); }
.info-dialog h1 { margin: 0 0 14px; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 600; letter-spacing: -.03em; }
.info-dialog p { font-size: 13px; line-height: 1.58; }
.info-dialog__lead { font-size: 16px !important; }
.info-dialog__close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 8px; background: #ece9e2; font-size: 24px; cursor: pointer; }
.info-dialog__meta { color: var(--muted); font-size: 11px !important; }
.info-dialog__related { font-size: 12px !important; line-height: 1.6; }
.info-dialog__related a { color: var(--accent-dark); }
.notice { margin: 20px 0; padding: 15px 16px; border-left: 4px solid var(--accent); background: #f3eee7; }
.notice p { margin-bottom: 0; }
.mobile-mode { display: none; }

@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(245,139,103,0); } 100% { box-shadow: 0 0 0 0 rgba(245,139,103,0); } }
@keyframes search-pulse { to { opacity: .25; } }

@media (max-width: 1120px) {
    .segmented--secondary { display: none; }
    .segmented--primary button { padding-inline: 8px; }
    .capacity-select span { display: none; }
    .capacity-select select { width: 150px; }
}

@media (max-width: 980px) and (min-width: 791px) {
    .capacity-select--desktop { display: none; }
    .capacity-select--mobile {
        display: flex;
        border-color: rgba(255,255,255,.46);
        background: var(--paper);
        box-shadow: 0 5px 20px rgba(17,27,24,.13);
        backdrop-filter: blur(15px);
    }
    .capacity-select--mobile span { display: block; }
    .capacity-select--mobile select { width: 190px; }
}

@media (max-width: 790px) {
    :root { --topbar-gap: 8px; --topbar-h: 54px; }
    .topbar {
        min-height: 54px;
        gap: 7px;
        padding: 6px;
    }
    .brand { min-width: 0; padding-left: 1px; }
    .brand__mark { width: 34px; height: 34px; }
    .brand strong { font-size: 16px; }
    .brand small { font-size: 9px; }
    .parcel-search { height: 44px; }
    .segmented--primary, .segmented--secondary { display: none; }
    .mobile-mode {
        display: flex;
        height: 39px;
        padding: 3px;
        border: 1px solid rgba(255,255,255,.46);
        border-radius: 10px;
        background: var(--paper);
        box-shadow: 0 5px 20px rgba(17,27,24,.13);
        backdrop-filter: blur(15px);
    }
    .mobile-mode__terrain { margin-left: 3px; padding-left: 10px !important; border-left: 1px solid var(--line) !important; border-radius: 0 7px 7px 0 !important; color: var(--muted); }
    .capacity-select--desktop { display: none; }
    .capacity-select--mobile {
        display: flex;
        width: min(280px, calc(100vw - 24px));
        border-color: rgba(255,255,255,.46);
        background: var(--paper);
        box-shadow: 0 5px 20px rgba(17,27,24,.13);
        backdrop-filter: blur(15px);
    }
    .capacity-select--mobile span { display: block; white-space: nowrap; }
    .capacity-select--mobile select { width: 100%; }
    .legend { left: max(8px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); gap: 9px; padding: 7px 9px; }
    .capacity-legend { left: max(8px, env(safe-area-inset-left)); bottom: max(58px, calc(env(safe-area-inset-bottom) + 50px)); width: min(520px, calc(100vw - 16px)); }
    .navigation-help { display: none; }
    .attribution { right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); }
    .detail-panel {
        top: auto;
        left: 0; right: 0; bottom: 0;
        width: 100%;
        max-height: min(68dvh, 620px);
        padding: 29px max(20px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
        border-width: 1px 0 0;
        border-radius: 18px 18px 0 0;
        transform: translateY(calc(100% + 24px));
    }
    .detail-panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px; transform: translateX(-50%); border-radius: 2px; background: #c7cbc8; }
    .detail-panel[aria-hidden="false"] { transform: translateY(0); }
}

@media (max-width: 430px) {
    .brand span { max-width: 156px; }
    .parcel-search { grid-template-columns: minmax(80px,.8fr) auto minmax(112px,1fr) 39px; }
    .parcel-search input { padding-inline: 8px; font-size: 13px; }
    .legend details { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
