/* explore.css -- the Explore page (explore.html).
 *
 * Two layers, in this order:
 *  1. THE DIRECTORY: the page every visitor gets without WebGL or without JS.
 *     A building directory board: mono level numbers in the one accent,
 *     hairline rows, the site's tokens throughout. It is a complete page on its
 *     own, not a loading state.
 *  2. THE SCENE (later phases): canvas, HUD, panel, joystick. Everything in
 *     that layer is scoped under `.explore.is-3d`, which explore.js adds only
 *     once the scene has rendered, so a failed boot leaves layer 1 untouched.
 *
 * Touch targets are written in px, never rem: styles.css drops :root to 15px
 * at 480px, so a rem target shrinks on exactly the phones that need it.
 */

/* ---- 1. the directory ----------------------------------------------------- */
.explore-directory {
    max-width: 880px;
    margin: 0 auto;
    /* clears the fixed navbar (64px, 71px in the 481-620px band) with room */
    padding: 128px 16px 96px;
}

.explore-head {
    margin-bottom: 2.5rem;
}

.explore-kicker {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.explore-head h1 {
    margin-bottom: 1rem;
}

.explore-lede {
    color: var(--color-text-secondary);
    max-width: 640px;
    line-height: 1.7;
}

.floors {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--color-border);
}

.floor {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1fr);
    column-gap: 1.25rem;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.floor-level {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    color: var(--color-primary);
    padding-top: 0.2rem;
}

.floor-body h2 {
    font-size: clamp(1.25rem, 2.5vw, 1.6rem);
    margin-bottom: 0.5rem;
}

.floor-body p {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.floor-facts {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

/* A 44px-tall target that still reads as a text link. */
.floor-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    gap: 0.4rem;
    color: var(--color-primary);
    font-weight: 500;
    text-decoration: none;
}

@media (hover: hover) {
    .floor-link:hover {
        text-decoration: underline;
        text-underline-offset: 3px;
    }
}

.floor-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (max-width: 480px) {
    .floor {
        grid-template-columns: 2.75rem minmax(0, 1fr);
        column-gap: 0.75rem;
    }
}

@media print {
    .explore-directory {
        padding-top: 0;
    }

    .floor {
        break-inside: avoid;
    }

    .floor-level,
    .floor-link,
    .explore-kicker {
        color: #555;
    }
}

/* ---- 2. the scene ---------------------------------------------------------- *
 * explore-boot.js puts <html> into .is-booting before the body paints (WebGL2,
 * no ?flat); explore.js swaps that for .is-3d once a frame is on screen. Every
 * rule below keys off those two classes, so the directory is untouched unless
 * the scene is actually on its way. */
.explore-stage,
.explore-loading,
.explore-skip,
.explore-lost {
    display: none;
}

html.is-booting .explore-directory,
html.is-booting .footer,
html.is-3d .explore-directory,
html.is-3d .footer,
html.is-3d #scroll-to-top {
    display: none;
}

/* A full-viewport app: nothing scrolls, the fixed navbar floats over the sky. */
html.is-3d,
html.is-3d body {
    overflow: hidden;
    height: 100%;
}

html.is-booting .explore-stage,
html.is-3d .explore-stage {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 0;
    background: #05070d;
}

/* Built while hidden, so the first thing anyone sees is a finished frame. */
html.is-booting .explore-stage {
    visibility: hidden;
}

.explore-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

html.is-booting .explore-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: #05070d;
    color: var(--color-text-secondary);
}

.explore-loading-text {
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    color: var(--color-text-primary);
}

/* ---- the HUD -------------------------------------------------------------- *
 * Static markup in explore.html; explore.js only shows, hides and labels it.
 * A `hidden` attribute must beat every display rule below -- the UA rule alone
 * loses to an author `display: flex`, the trap logged on the pro/con list. */
.explore [hidden] {
    display: none !important;
}

.explore-hud {
    display: none;
}

html.is-booting .explore-hud,
html.is-3d .explore-hud {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;   /* the scene gets every pointer the HUD does not claim */
}

.explore-hud > *,
.hud-actions > * {
    pointer-events: auto;
}

/* While loading, the only thing offered is the way out. */
html.is-booting .explore-hud > :not(.hud-actions),
html.is-booting .hud-actions > :not(.explore-skip) {
    display: none;
}

.hud-hint {
    position: absolute;
    top: 84px;
    left: 16px;
    max-width: min(560px, calc(100% - 32px));
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    pointer-events: none;
}

.hud-actions {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: calc(100% - 32px);
}

/* 44px targets, in px (styles.css drops :root to 15px at 480px). Translucent, never
   blurred: DESIGN.md has no glassmorphism. */
.hud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    background: rgba(18, 18, 20, 0.78);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}

@media (hover: hover) {
    .hud-btn:hover {
        color: var(--color-text-primary);
        border-color: var(--color-border-strong);
    }
}

.hud-btn:active {
    border-color: var(--color-primary);
}

.hud-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.hud-primary {
    color: var(--color-bg-primary);
    background: var(--color-primary);
    border-color: var(--color-primary);
}

@media (hover: hover) {
    .hud-primary:hover {
        color: var(--color-bg-primary);
        background: var(--color-primary-dark);
    }
}

/* Touch-only controls: a stick for flying, two buttons for height. */
.hud-stick,
.hud-alt {
    display: none !important;
}

.hud-stick {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    background: rgba(18, 18, 20, 0.6);
    border: 1px solid var(--color-border-strong);
    touch-action: none;
}

.hud-stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    background: var(--color-overlay);
    border: 1px solid var(--color-primary);
}

.hud-alt {
    position: absolute;
    right: 16px;
    bottom: 20px;
    flex-direction: column;
    gap: 8px;
}

.hud-alt-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    font-size: 16px;
    touch-action: none;
}

.hint-coarse {
    display: none;
}

@media (pointer: coarse) {
    .hint-fine {
        display: none;
    }

    .hint-coarse {
        display: inline;
    }

    .help-list.hint-coarse {
        display: block;
    }

    html.is-3d .hud-stick {
        display: block !important;
    }

    html.is-3d .hud-alt {
        display: flex !important;
    }

    /* the stick and the height buttons own the bottom corners; actions go up top */
    .hud-hint {
        display: none;
    }

    .hud-actions {
        top: 80px;
        bottom: auto;
    }
}

/* Narrow, whatever the pointer: five actions wrap into rows that climb into the
   prompt's place at the bottom, so they go up under the navbar (as on touch) and
   the hint, which would collide with them, steps aside. */
@media (max-width: 640px) {
    .hud-hint {
        display: none;
    }

    .hud-actions {
        top: 80px;
        bottom: auto;
    }
}

/* ---- floors: the menu, the prompt, the panel ---- */
.hud-floors {
    position: absolute;
    right: 16px;
    bottom: 76px;
    width: min(300px, calc(100% - 32px));
    max-height: calc(100% - 180px);
    overflow-y: auto;
    padding: 14px;
    background: var(--color-overlay);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.hud-floors .explore-kicker {
    margin-bottom: 8px;
}

.hud-floors-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hud-floors-list .hud-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    text-transform: none;
    letter-spacing: 0.02em;
    font-family: var(--font-primary);
    font-size: 15px;
    color: var(--color-text-primary);
}

.floor-tag {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-primary);
    min-width: 1.6em;
}

.hud-prompt {
    position: absolute;
    left: 50%;
    bottom: 76px;
    transform: translateX(-50%);
    min-height: 48px;
    max-width: calc(100% - 32px);
    padding: 0 20px;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-bg-primary);
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    touch-action: manipulation;
}

.hud-prompt:focus-visible {
    outline: 2px solid var(--color-text-primary);
    outline-offset: 3px;
}

.explore-panel {
    position: fixed;
    right: 16px;
    top: 84px;
    z-index: 6;
    width: min(400px, calc(100% - 32px));
    max-height: calc(100% - 168px);
    overflow-y: auto;
    padding: 24px;
    background: var(--color-overlay);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

html:not(.is-3d) .explore-panel {
    display: none;
}

.explore-panel h2 {
    font-size: 1.6rem;
    margin: 0 48px 0.75rem 0;    /* clear of the close button */
}

.explore-panel h2:focus {
    outline: none;               /* focus lands here so a reader starts at the title */
}

.panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 20px;
    padding: 0;
    width: 44px;
}

.panel-body p {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.panel-body .floor-facts {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

@media (pointer: coarse) {
    /* the stick and the arrows own the bottom corners: the prompt sits above them,
       and the menu and panel become bottom sheets over the controls they replace */
    .hud-prompt {
        bottom: 168px;
    }

    .hud-floors,
    .explore-panel {
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 8px;
        width: auto;
        max-height: 62%;
    }
}

/* ---- the controls card ---- */
.explore-help {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    width: min(440px, calc(100% - 32px));
    max-height: calc(100% - 120px);
    overflow-y: auto;
    padding: 24px;
    background: var(--color-overlay);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.explore-help h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.help-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    color: var(--color-text-secondary);
    line-height: 2;
}

.help-note {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.explore-help kbd {
    display: inline-block;
    min-width: 1.7em;
    padding: 0 0.35em;
    font-family: var(--font-mono);
    font-size: 0.8em;
    text-align: center;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-raised);
}

html:not(.is-3d) .explore-help {
    display: none;
}

.explore-stage canvas {
    touch-action: none;     /* the canvas owns every gesture: look, never scroll */
    cursor: grab;
}

.explore-stage canvas.is-looking {
    cursor: grabbing;
}

/* The 3D view died mid-visit (lost context, or a throw in the loop). */
html.is-3d-lost .explore-lost {
    display: block;
    max-width: 880px;
    margin: 96px auto 0;
    padding: 0 16px;
    color: var(--color-text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
}

html.is-3d-lost .explore-directory {
    padding-top: 24px;
}
