/* ==========================================================================
   A-LAB APP SHELL — shared by the lab sub-apps
   (A-Spatial, A-Space, A-Studio DAW, glade)
   - .lab-app-bar     56px app bar: back to A-Lab · app name · info button
   - .lab-info        small "about / how to use" popover opened from the bar
   - .lab-desk-only   "best on desktop" screen for apps that need a big screen
   Theme hooks: every colour is a --lab-* variable so an app (glade) can
   re-skin the bar without touching this file.
   ========================================================================== */

:root {
    --lab-bar-h: 56px;
    --lab-bg: #08080c;
    --lab-bar-bg: rgba(8, 8, 12, 0.94);
    --lab-bar-fg: #f2f2ee;
    --lab-bar-muted: #9a9aa5;
    --lab-bar-border: rgba(255, 255, 255, 0.08);
    --lab-bar-border-strong: rgba(255, 255, 255, 0.22);
    --lab-bar-hover-bg: rgba(255, 255, 255, 0.05);
    --lab-accent: #A855F7;
    --lab-pop-bg: #101016;
    --lab-title-font: 'Space Grotesk', 'Poppins', system-ui, sans-serif;
    --lab-mono-font: 'JetBrains Mono', ui-monospace, monospace;
    --lab-body-font: 'Poppins', 'Inter', system-ui, sans-serif;
    --lab-safe-top: env(safe-area-inset-top, 0px);
    --lab-safe-left: env(safe-area-inset-left, 0px);
    --lab-safe-right: env(safe-area-inset-right, 0px);
    --lab-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Sprite icons (img/icons.svg) */
.icon {
    width: 1em;
    height: 1em;
    flex: none;
    vertical-align: -0.125em;
}

[tabindex="-1"]:focus { outline: none; }

/* --------------------------------------------------------------------------
   App bar
   -------------------------------------------------------------------------- */
.lab-app-bar {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    height: calc(var(--lab-bar-h) + var(--lab-safe-top));
    padding: var(--lab-safe-top) calc(0.75rem + var(--lab-safe-right)) 0 calc(0.75rem + var(--lab-safe-left));
    background: var(--lab-bar-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--lab-bar-border);
    color: var(--lab-bar-fg);
    flex: none;
    position: relative;
    z-index: 1000;
}

.lab-app-bar--fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}

.lab-app-bar__back {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    min-width: 44px;
    padding: 0 0.75rem;
    font-family: var(--lab-mono-font);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1;
    color: var(--lab-bar-muted);
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid var(--lab-bar-border);
    border-radius: 8px;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.lab-app-bar__back .icon { width: 14px; height: 14px; }

.lab-app-bar__title {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.6rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}
.lab-app-bar__name {
    font-family: var(--lab-title-font);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--lab-bar-fg);
    white-space: nowrap;
}
.lab-app-bar__sub {
    font-family: var(--lab-mono-font);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: var(--lab-bar-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lab-app-bar__end {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.lab-app-bar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    flex: none;
    color: var(--lab-bar-muted);
    background: transparent;
    border: 1px solid var(--lab-bar-border);
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.lab-app-bar__btn .icon { width: 20px; height: 20px; }
.lab-app-bar__btn[aria-expanded="true"] {
    color: var(--lab-bar-fg);
    border-color: var(--lab-bar-border-strong);
    background: var(--lab-bar-hover-bg);
}

.lab-app-bar a:focus-visible,
.lab-app-bar button:focus-visible,
.lab-info a:focus-visible,
.lab-info button:focus-visible,
.lab-desk-only a:focus-visible,
.lab-desk-only button:focus-visible {
    outline: 2px solid var(--lab-accent);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .lab-app-bar__back:hover,
    .lab-app-bar__btn:hover {
        color: var(--lab-bar-fg);
        border-color: var(--lab-bar-border-strong);
        background: var(--lab-bar-hover-bg);
    }
}

@media (max-width: 899px) {
    .lab-app-bar__sub { display: none; }
}
@media (max-width: 599px) {
    .lab-app-bar { gap: 0.5rem; padding-left: calc(0.5rem + var(--lab-safe-left)); padding-right: calc(0.5rem + var(--lab-safe-right)); }
    .lab-app-bar__back { padding: 0 0.6rem; }
    .lab-app-bar__name { font-size: 1rem; }
}

/* --------------------------------------------------------------------------
   Info popover
   -------------------------------------------------------------------------- */
.lab-info {
    box-sizing: border-box;
    position: fixed;
    top: calc(var(--lab-bar-h) + var(--lab-safe-top) + 8px);
    right: calc(8px + var(--lab-safe-right));
    z-index: 1001;
    width: min(360px, calc(100vw - 16px - var(--lab-safe-left) - var(--lab-safe-right)));
    max-height: calc(100dvh - var(--lab-bar-h) - var(--lab-safe-top) - 24px);
    overflow-y: auto;
    padding: 1.1rem 1.1rem 1rem;
    background: var(--lab-pop-bg);
    color: var(--lab-bar-fg);
    border: 1px solid var(--lab-bar-border-strong);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    font-family: var(--lab-body-font);
    font-size: 0.85rem;
    line-height: 1.55;
}
.lab-info[hidden] { display: none; }
.lab-info h2 {
    margin: 0 0 0.4rem;
    font-family: var(--lab-title-font);
    font-size: 1rem;
    font-weight: 700;
}
.lab-info p { margin: 0 0 0.6rem; color: var(--lab-bar-muted); }
.lab-info ul { margin: 0 0 0.4rem; padding-left: 1.1rem; color: var(--lab-bar-muted); }
.lab-info li { margin: 0.15rem 0; }
.lab-info kbd {
    font-family: var(--lab-mono-font);
    font-size: 0.72rem;
    padding: 0 0.3rem;
    border: 1px solid var(--lab-bar-border-strong);
    border-radius: 4px;
}
.lab-info__close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--lab-bar-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
.lab-info__close .icon { width: 16px; height: 16px; }
@media (pointer: coarse) {
    .lab-info__close { width: 44px; height: 44px; top: 2px; right: 2px; }
}

/* Pointer-dependent wording */
.hint-coarse { display: none; }
@media (pointer: coarse) {
    .hint-fine { display: none; }
    .hint-coarse { display: inline; }
}

/* --------------------------------------------------------------------------
   "Best on desktop" screen
   Shown on phones and touch tablets. The app stays mounted underneath (so it
   has real dimensions when the visitor picks "Open anyway") but is hidden.
   -------------------------------------------------------------------------- */
.lab-desk-only { display: none; }

@media (max-width: 767px), (pointer: coarse) and (max-width: 1024px) {
    html.lab-gated:not(.lab-open-anyway) .lab-desk-only {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 5000;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        background: var(--lab-bg);
        color: var(--lab-bar-fg);
        font-family: var(--lab-body-font);
        visibility: visible;
    }
    html.lab-gated:not(.lab-open-anyway) body > :not(.lab-desk-only):not(script) {
        visibility: hidden;
    }
}

/* The screen carries its own copy of the lab app bar (back · app name) */
.lab-desk-only__bar {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.lab-desk-only__bar .lab-app-bar__title { margin: 0; }

.lab-desk-only__inner {
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 2rem calc(1.25rem + var(--lab-safe-right)) calc(2rem + var(--lab-safe-bottom)) calc(1.25rem + var(--lab-safe-left));
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    /* vertically centred in the space under the bar; still scrolls when taller */
    margin: auto;
    flex: none;
}
.lab-desk-only__eyebrow {
    margin: 0;
    font-family: var(--lab-mono-font);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lab-bar-muted);
}
.lab-desk-only__title {
    margin: -0.6rem 0 0;
    font-family: var(--lab-title-font);
    font-size: clamp(2rem, 9vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--lab-bar-fg);
}
.lab-desk-only__desc {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--lab-bar-muted);
    max-width: 44ch;
}
.lab-desk-only__media {
    margin: 0;
    border: 1px solid var(--lab-bar-border);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    background: #0d0d13;
}
.lab-desk-only__media img,
.lab-desk-only__media video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left top;
}
.lab-desk-only__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.5rem;
    font-size: 14.5px;
    color: var(--lab-bar-fg);
}
.lab-desk-only__list li {
    position: relative;
    padding-left: 1.1rem;
    line-height: 21px;
}
/* Whole-pixel dash so every bullet renders in the same accent colour */
.lab-desk-only__list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    width: 8px;
    height: 2px;
    background: var(--lab-accent);
}
.lab-desk-only__actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.25rem;
}
.lab-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0 1.25rem;
    font-family: var(--lab-title-font);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--lab-bar-fg);
    background: transparent;
    border: 1px solid var(--lab-bar-border-strong);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.lab-btn .icon { width: 16px; height: 16px; }
.lab-btn--primary {
    color: #0b0b10;
    background: var(--lab-bar-fg);
    border-color: var(--lab-bar-fg);
}
.lab-btn--text {
    border-color: transparent;
    color: var(--lab-bar-muted);
    font-family: var(--lab-mono-font);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: underline;
    text-underline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
    .lab-btn:hover { border-color: var(--lab-bar-fg); background: var(--lab-bar-hover-bg); }
    .lab-btn--primary:hover { background: #ffffff; }
    .lab-btn--text:hover { color: var(--lab-bar-fg); background: transparent; border-color: transparent; }
}
.lab-desk-only__copied {
    margin: 0;
    min-height: 1.3em;
    font-family: var(--lab-mono-font);
    font-size: 0.75rem;
    color: var(--lab-bar-muted);
    text-align: center;
}
.lab-desk-only__url {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 0 0.75rem;
    font-family: var(--lab-mono-font);
    font-size: 16px;
    color: var(--lab-bar-fg);
    background: #0d0d13;
    border: 1px solid var(--lab-bar-border-strong);
    border-radius: 8px;
}
.lab-desk-only__url[hidden] { display: none; }

@media (min-width: 480px) {
    .lab-desk-only__actions { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .lab-desk-only__actions .lab-btn--primary { flex: 1 1 100%; }
    .lab-desk-only__actions .lab-btn:not(.lab-btn--primary):not(.lab-btn--text) { flex: 1 1 auto; }
}
/* Landscape phones: two columns so the actions stay on screen */
@media (max-height: 500px) and (orientation: landscape) {
    .lab-desk-only__inner {
        max-width: 900px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "eyebrow media"
            "title   media"
            "desc    media"
            "actions list"
            "url     list"
            "copied  list";
        /* the media spans eyebrow/title/desc: its extra height goes to the desc row */
        grid-template-rows: auto auto 1fr auto auto 1fr;
        column-gap: 1.75rem;
        row-gap: 0.9rem;
        align-content: start;
    }
    .lab-desk-only__eyebrow { grid-area: eyebrow; }
    .lab-desk-only__title { grid-area: title; }
    .lab-desk-only__desc { grid-area: desc; align-self: start; }
    .lab-desk-only__media { grid-area: media; align-self: start; }
    .lab-desk-only__list { grid-area: list; align-self: start; }
    .lab-desk-only__actions { grid-area: actions; }
    .lab-desk-only__url { grid-area: url; }
    .lab-desk-only__copied { grid-area: copied; }
}

@media (prefers-reduced-motion: reduce) {
    .lab-app-bar *, .lab-desk-only * { transition: none !important; }
}
