/* =========================================================
   Virtual-lab context bar
   The 56px bar under the site nav on every lab page. Markup is
   stamped by scripts/sync-lab-bar.js (hand-written labs), built by
   the phase*-runtime.js templates, or written in virtual lab/index.html.
   The look follows the Penpot page B9_Navigation, boards
   "nav / lab experiment 1280", "nav / lab index 1280" and
   "nav / lab experiment 375".
   ========================================================= */

.lab-bar {
    --lb-text: #cbd5e1;
    --lb-text-strong: #f1f5f9;
    --lb-text-muted: #94a3b8;
    --lb-emerald: 16, 185, 129;
    --lb-cobalt: 59, 130, 246;
    --lb-violet: 139, 92, 246;
    position: sticky;
    top: 0;
    z-index: 50;
    display: block;
    margin: 0;
    padding: 0;
    background: rgba(12, 27, 48, 0.72);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    color: var(--lb-text);
    font-family: "Inter Tight", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    text-align: left;
}

/* Lab card layouts pad the body (Tailwind p-4 md:p-8): the bar still runs edge to edge */
body.p-4 > .lab-bar {
    margin: -1rem -1rem 1rem;
}

@media (min-width: 768px) {
    body.md\:p-8 > .lab-bar {
        margin: -2rem -2rem 2rem;
    }
}

.lab-bar *,
.lab-bar *::before,
.lab-bar *::after {
    box-sizing: border-box;
}

.lab-bar__inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 56px;
    margin: 0;
    padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}

.lab-bar__icon {
    display: block;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
}

/* ---------- Back to the catalog ---------- */

.lab-bar__back {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--lb-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.lab-bar__back .lab-bar__icon {
    width: 32px;
    height: 32px;
    padding: 6px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.lab-bar__back:hover,
.lab-bar__back:focus-visible {
    color: var(--lb-text-strong);
}

.lab-bar__back:hover .lab-bar__icon,
.lab-bar__back:focus-visible .lab-bar__icon {
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.lab-bar__divider {
    flex: 0 0 auto;
    width: 1px;
    height: 24px;
    margin: 0 2px;
    background: rgba(255, 255, 255, 0.12);
}

/* ---------- Lab identity ---------- */

.lab-bar__chip {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 2px;
    border-radius: 10px;
    background: rgba(var(--lb-cobalt), 0.14);
    color: rgb(var(--lb-cobalt));
}

.lab-bar__chip:first-child {
    margin-left: 0;
}

.lab-bar__heading {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
}

.lab-bar .lab-bar__title,
.lab-bar .lab-bar__subtitle {
    display: block;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: inherit;
    letter-spacing: 0;
    line-height: 1.2;
    text-overflow: ellipsis;
    text-transform: none;
    white-space: nowrap;
}

.lab-bar .lab-bar__title {
    color: var(--lb-text-strong);
    font-size: 15px;
    font-weight: 700;
}

.lab-bar .lab-bar__subtitle {
    color: var(--lb-text-muted);
    font-size: 12px;
    font-weight: 400;
}

/* ---------- Right side: status, buttons, Tools ---------- */

.lab-bar__actions {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.lab-bar .lab-bar__status {
    display: none;
    align-items: center;
    gap: 7px;
    height: 28px;
    margin: 0 4px 0 0;
    padding: 0 16px 0 14px;
    border: 1px solid rgba(var(--lb-emerald), 0.35);
    border-radius: 14px;
    background: rgba(var(--lb-emerald), 0.12);
    color: rgb(var(--lb-emerald));
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: none;
    white-space: nowrap;
}

/* The dot: its colour class is driven by the lab script, so it is only sized here */
.lab-bar .lab-bar__status > :first-child {
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.lab-bar .lab-bar__status > .bg-muted:first-child {
    background-color: rgb(var(--lb-emerald));
}

.lab-bar .lab-bar__status > :not(:first-child) {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: 0;
    text-transform: none;
}

.lab-bar .lab-bar__btn {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 36px;
    width: 36px;
    height: 36px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--lb-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.lab-bar .lab-bar__btn:hover,
.lab-bar .lab-bar__btn:focus-visible {
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(255, 255, 255, 0.1);
    color: var(--lb-text-strong);
}

.lab-bar .lab-bar__btn--text {
    width: auto;
    padding: 0 14px;
}

.lab-bar__btn-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgb(var(--lb-emerald));
}

/* Tools: the violet pill, icon-only below 768px */
.lab-bar__tools {
    position: relative;
    flex: 0 0 auto;
}

.lab-bar .lab-bar__btn--tools {
    width: 36px;
    border-color: rgba(var(--lb-violet), 0.35);
    background: rgba(var(--lb-violet), 0.14);
    color: #c4b5fd;
}

.lab-bar .lab-bar__btn--tools:hover,
.lab-bar .lab-bar__btn--tools:focus-visible,
.lab-bar .lab-bar__btn--tools[aria-expanded="true"] {
    border-color: rgba(var(--lb-violet), 0.6);
    background: rgba(var(--lb-violet), 0.24);
    color: #ddd6fe;
}

.lab-bar__btn--tools .lab-bar__tools-label,
.lab-bar__btn--tools .lab-bar__icon--chevron {
    display: none;
}

.lab-bar__icon--chevron {
    width: 16px;
    height: 16px;
}

.lab-bar__tools-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 60;
    width: 260px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(12, 27, 48, 0.97);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.lab-bar__tools-panel[hidden] {
    display: none;
}

.lab-bar__tools-head {
    margin: 0 0 4px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: #c4b5fd;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.lab-bar .lab-bar__tools-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 400;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lab-bar .lab-bar__tools-link:hover,
.lab-bar .lab-bar__tools-link:focus-visible {
    background: rgba(var(--lb-violet), 0.15);
    color: #c4b5fd;
}

.lab-bar__tools-chip {
    --icon-accent: #34d399;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(var(--lb-violet), 0.14);
    color: #c4b5fd;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lab-bar__tools-link:hover .lab-bar__tools-chip,
.lab-bar__tools-link:focus-visible .lab-bar__tools-chip {
    background: rgba(var(--lb-violet), 0.28);
    color: #ddd6fe;
}

.lab-bar__tools-icon {
    width: 18px;
    height: 18px;
}

/* The product icons are drawn for 48px; thicken the strokes at 18px */
.lab-bar__tools-icon path[stroke] {
    stroke-width: 3.25;
}

.lab-bar__tools-name {
    flex: 1 1 auto;
}

.lab-bar__tools-open {
    color: #64748b;
    font-size: 10px;
}

.lab-bar .lab-bar__tools-all {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    background: rgba(var(--lb-violet), 0.1);
    color: #c4b5fd;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.lab-bar .lab-bar__tools-all:hover,
.lab-bar .lab-bar__tools-all:focus-visible {
    background: rgba(var(--lb-violet), 0.25);
}

/* ---------- Catalog (lab index) ---------- */

.lab-bar .lab-bar__login {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    height: 36px;
    margin: 0 0 0 4px;
    padding: 0 22px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 16px rgba(var(--lb-emerald), 0.4);
    color: #04121f;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.lab-bar .lab-bar__login:hover,
.lab-bar .lab-bar__login:focus-visible {
    box-shadow: 0 6px 20px rgba(var(--lb-emerald), 0.55);
    color: #04121f;
    transform: translateY(-1px);
}

/* .hidden / .flex are toggled by the catalog's account script */
.lab-bar .lab-bar__account {
    align-items: center;
    gap: 10px;
    height: 36px;
    margin: 0 0 0 4px;
    padding: 0 6px 0 4px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
}

.lab-bar .lab-bar__account.hidden,
.lab-bar .lab-bar__login.hidden {
    display: none;
}

.lab-bar__account-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(var(--lb-emerald), 0.18);
    color: rgb(var(--lb-emerald));
    font-size: 12px;
    font-weight: 700;
}

.lab-bar__account-name {
    max-width: 10rem;
    overflow: hidden;
    color: var(--lb-text-strong);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lab-bar .lab-bar__logout {
    height: 26px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid rgba(244, 63, 94, 0.35);
    border-radius: 13px;
    background: none;
    color: #fb7185;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.lab-bar .lab-bar__logout:hover,
.lab-bar .lab-bar__logout:focus-visible {
    background: rgba(244, 63, 94, 0.12);
}

.lab-bar a:focus-visible,
.lab-bar button:focus-visible {
    outline: 2px solid rgb(var(--lb-emerald));
    outline-offset: 2px;
}

/* ---------- Below 768px: icon-only back and Tools, 14px title ---------- */

@media (max-width: 767.98px) {
    .lab-bar__inner {
        gap: 8px;
    }

    .lab-bar__back-label,
    .lab-bar__divider {
        display: none;
    }

    .lab-bar__chip {
        margin-left: 0;
    }

    .lab-bar__heading {
        margin-left: 4px;
    }

    .lab-bar .lab-bar__title {
        font-size: 14px;
    }

    .lab-bar__account-name {
        display: none;
    }
}

@media (min-width: 640px) {
    .lab-bar .lab-bar__login {
        display: inline-flex;
    }
}

@media (min-width: 768px) {
    .lab-bar .lab-bar__status {
        display: inline-flex;
    }

    .lab-bar .lab-bar__btn--tools {
        width: auto;
        padding: 0 12px 0 16px;
        border-radius: 18px;
    }

    .lab-bar__btn--tools .lab-bar__tools-label,
    .lab-bar__btn--tools .lab-bar__icon--chevron {
        display: block;
    }

    .lab-bar__btn--tools .lab-bar__icon--settings {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lab-bar *,
    .lab-bar *::before,
    .lab-bar *::after {
        transition: none !important;
    }
}
