/*
 * Phone action bar (partials/app-bar.blade.php, behaviour in /js/app-bar.js).
 * Static file: production has no asset build. Bump ?v= in the two layouts on change.
 * Phones only: everything below applies under 1024px; wider screens see nothing.
 */

:root {
    --swab-h: 64px;
    --swab-row-h: 64px;
    --swab-accent: #facc15;
    --swab-bg: rgba(10, 10, 10, 0.96);
    --swab-line: #292524;
    --swab-muted: #a8a29e;
}

/* Hidden everywhere by default; the phone media query turns it on. */
.sw-appbar,
.sw-appbar-row {
    display: none;
}

.sw-appbar [hidden],
.sw-appbar-row [hidden] {
    display: none !important;
}

@media (max-width: 1023.98px) {
    /* ---------- Bar ---------- */
    .sw-appbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        display: grid;
        grid-auto-flow: column;
        /* A column is never narrower than its content (the Join free label stays on one line). */
        grid-auto-columns: minmax(max-content, 1fr);
        align-items: stretch;
        height: calc(var(--swab-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--swab-bg);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--swab-line);
    }

    .sw-appbar__slot {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        border: 0;
        background: none;
        color: var(--swab-muted);
        font: inherit;
        font-size: 11px;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .sw-appbar__slot i {
        font-size: 19px;
        line-height: 1;
    }

    .sw-appbar__slot:hover {
        color: #f5f5f4;
    }

    .sw-appbar__slot.is-active {
        color: var(--swab-accent);
    }

    /* Wingman: centre and larger. */
    .sw-appbar__slot.is-centre {
        color: var(--swab-accent);
    }

    .sw-appbar__slot.is-centre i {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-top: -14px;
        border-radius: 50%;
        background: #0a0a0a;
        border: 2px solid var(--swab-accent);
        font-size: 22px;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
    }

    /* Join free: the one yellow filled primary. */
    .sw-appbar__slot.is-primary {
        margin: 10px 6px;
        padding: 0 10px;
        min-height: 44px;
        flex-direction: row;
        gap: 6px;
        border-radius: 12px;
        background: var(--swab-accent);
        color: #0a0a0a;
        font-size: 13px;
        font-weight: 800;
        white-space: nowrap;
    }

    .sw-appbar__slot.is-primary i {
        font-size: 15px;
    }

    .sw-appbar__badge {
        position: absolute;
        top: 6px;
        left: calc(50% + 4px);
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 9px;
        background: #ef4444;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        line-height: 18px;
        text-align: center;
    }

    .sw-appbar__dot {
        position: absolute;
        top: 10px;
        left: calc(50% + 6px);
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: var(--swab-accent);
        border: 2px solid #0a0a0a;
    }

    /* ---------- Club page row ---------- */
    .sw-appbar-row {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--swab-h) + env(safe-area-inset-bottom, 0px));
        z-index: 900;
        display: block;
        height: var(--swab-row-h);
        background: var(--swab-bg);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--swab-line);
    }

    .sw-appbar-row__inner {
        display: flex;
        gap: 8px;
        height: 100%;
        padding: 10px 12px;
    }

    .sw-appbar-row__action {
        flex: 1 1 0;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-width: 44px;
        min-height: 44px;
        padding: 0 8px;
        border: 1px solid var(--swab-line);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.06);
        color: #f5f5f4;
        font: inherit;
        font-size: 12px;
        font-weight: 700;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .sw-appbar-row__action.is-primary {
        background: var(--swab-accent);
        border-color: var(--swab-accent);
        color: #0a0a0a;
    }

    .sw-appbar-row__action.is-on {
        color: var(--swab-accent);
        border-color: var(--swab-accent);
    }

    .sw-appbar-row__action:disabled {
        opacity: 0.6;
        cursor: default;
    }

    /* ---------- Page spacing: the footer and last content clear the bar ---------- */
    body.sw-has-appbar:not(.sw-dash-body) {
        padding-bottom: calc(var(--swab-h) + env(safe-area-inset-bottom, 0px));
    }

    body.sw-has-appbar.sw-has-club-row:not(.sw-dash-body) {
        padding-bottom: calc(var(--swab-h) + var(--swab-row-h) + env(safe-area-inset-bottom, 0px));
    }

    /* Same thing without waiting for the script (kept as its own rule: an old browser drops a whole rule it cannot parse). */
    body.sw-has-appbar:has(.sw-appbar-row__inner):not(.sw-dash-body) {
        padding-bottom: calc(var(--swab-h) + var(--swab-row-h) + env(safe-area-inset-bottom, 0px));
    }

    /* ---------- Header: Wingman and the bell move to the bar ---------- */
    body.sw-has-appbar #wm-launch,
    body.sw-has-appbar #sw-notif-root,
    body.sw-has-appbar #sw-guest-bell {
        display: none;
    }

    /* ---------- Hidden while something else needs the bottom of the screen ---------- */
    html.sw-appbar-off .sw-appbar,
    html.sw-appbar-off .sw-appbar-row {
        display: none;
    }
}

/* ---------- Phone landscape: the bar becomes a rail on the right edge ----------
   Same markup, links, badges and data attributes as the bottom bar; only the layout changes.
   The page body gives up the rail's width (padding), so the site header, the deck and the footer
   all end where the rail starts. Portrait, tablets (taller than 500px) and desktop are untouched. */
@media (max-width: 1023.98px) and (max-height: 500px) and (orientation: landscape) {
    :root {
        --swab-rail-w: 60px;
    }

    .sw-appbar {
        top: 0;
        left: auto;
        right: 0;
        bottom: 0;
        width: calc(var(--swab-rail-w) + env(safe-area-inset-right, 0px));
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        align-items: stretch;
        box-sizing: border-box;
        padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) 0;
        background: #000;
        border-top: 0;
        border-left: 1px solid var(--swab-line);
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
    }

    .sw-appbar::-webkit-scrollbar {
        display: none;
    }

    .sw-appbar__slot {
        flex: 1 1 0;
        min-height: 44px;
        max-height: 76px;
        gap: 2px;
        font-size: 9px;
        line-height: 1.1;
        letter-spacing: 0.02em;
    }

    .sw-appbar__slot i {
        font-size: 17px;
    }

    .sw-appbar__label {
        max-width: 100%;
        white-space: nowrap;
    }

    /* The active item: gold, with a gold tick on the rail's inner edge. */
    .sw-appbar__slot.is-active::before {
        content: "";
        position: absolute;
        left: 0;
        top: 22%;
        bottom: 22%;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background: var(--swab-accent);
    }

    /* Wingman: the same gold ring, smaller, in the middle of the rail. */
    .sw-appbar__slot.is-centre i {
        width: 34px;
        height: 34px;
        margin-top: 0;
        border-width: 2px;
        font-size: 16px;
        box-shadow: none;
    }

    /* Join free: the gold button, icon over label. */
    .sw-appbar__slot.is-primary {
        flex: 0 1 52px;
        min-height: 44px;
        margin: 0 6px;
        padding: 4px 0;
        flex-direction: column;
        gap: 2px;
        border-radius: 10px;
        font-size: 9px;
        font-weight: 800;
    }

    .sw-appbar__slot.is-primary i {
        font-size: 15px;
    }

    .sw-appbar__badge {
        top: 3px;
        left: calc(50% + 2px);
    }

    .sw-appbar__dot {
        top: 6px;
        left: calc(50% + 4px);
    }

    /* The page gives up the rail's width; nothing sits under it. The rail keeps its place while the bar is hidden for the keyboard, so the page does not jump. */
    html body.sw-has-appbar {
        padding-right: calc(var(--swab-rail-w) + env(safe-area-inset-right, 0px));
        padding-left: env(safe-area-inset-left, 0px);
    }

    html body.sw-has-appbar:not(.sw-dash-body),
    html body.sw-has-appbar.sw-has-club-row:not(.sw-dash-body),
    html body.sw-has-appbar:has(.sw-appbar-row__inner):not(.sw-dash-body) {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* The club row is not pinned (the club page also sets this): it is the last block of the page. */
    .sw-appbar-row {
        position: static;
        bottom: auto;
    }

    /* Slimmer site header: every control stays, 44px targets. */
    html body.sw-has-appbar > header > div:first-of-type {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    html body.sw-has-appbar > header .w-10.h-10 {
        width: 32px;
        height: 32px;
    }

    html body.sw-has-appbar > header #menu-button {
        width: 44px;
        height: 44px;
    }
}

/* ---------- Questions sheet ---------- */
.sw-qsheet {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: flex;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.6);
}

.sw-qsheet[hidden] {
    display: none;
}

.sw-qsheet__panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-radius: 18px 18px 0 0;
    background: #0a0a0a;
    border-top: 1px solid var(--swab-line);
    color: #f5f5f4;
    animation: sw-qsheet-up 220ms ease;
}

@keyframes sw-qsheet-up {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .sw-qsheet__panel { animation: none; }
}

.sw-qsheet__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 8px;
}

.sw-qsheet__title {
    flex: 1;
    font-size: 16px;
    font-weight: 800;
}

.sw-qsheet__points {
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(234, 179, 8, 0.35);
    color: #eab308;
    font-size: 13px;
    font-weight: 700;
}

.sw-qsheet__close {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    background: none;
    color: var(--swab-muted);
    font-size: 20px;
    cursor: pointer;
}

.sw-qsheet__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 12px;
}

.sw-qsheet__card {
    opacity: 1;
    transform: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.sw-qsheet__card.out { opacity: 0; transform: translateY(-10px); }
.sw-qsheet__card.in { opacity: 0; transform: translateY(14px); transition: none; }

.sw-qsheet__foot {
    padding: 8px 16px 14px;
    text-align: center;
}

.sw-qsheet__foot a {
    color: var(--swab-muted);
    font-size: 13px;
}

/* Question card pieces (rendered by /js/night-questions.js), scoped to the sheet. */
.sw-qsheet .cat { display: inline-block; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: #eab308; border: 1px solid rgba(234, 179, 8, 0.35); border-radius: 999px; padding: 4px 12px; margin-bottom: 14px; }
.sw-qsheet .q { font-size: 20px; font-weight: 800; line-height: 1.25; margin-bottom: 18px; }
.sw-qsheet .opts { display: grid; gap: 8px; margin-bottom: 14px; }
.sw-qsheet .opt { text-align: left; min-height: 44px; font: inherit; font-size: 15px; font-weight: 600; color: #f5f5f4; background: rgba(255, 255, 255, 0.05); border: 1px solid #292524; border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.sw-qsheet .opt.picked { border-color: #eab308; background: rgba(234, 179, 8, 0.15); }
.sw-qsheet .row { display: flex; gap: 8px; }
.sw-qsheet input[type=text],
.sw-qsheet input[type=number] { flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; color: #f5f5f4; background: rgba(255, 255, 255, 0.05); border: 1px solid #292524; border-radius: 12px; padding: 10px 12px; outline: none; }
.sw-qsheet .btn { min-height: 44px; font: inherit; font-size: 14px; font-weight: 800; color: #0a0a0a; background: #eab308; border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.sw-qsheet .btn.ghost { background: rgba(255, 255, 255, 0.08); color: #f5f5f4; }
.sw-qsheet .other { border-top: 1px solid #1c1917; padding-top: 12px; margin-top: 4px; }
.sw-qsheet .other label { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #78716c; margin-bottom: 6px; }
.sw-qsheet .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.sw-qsheet .skip { min-height: 44px; font: inherit; background: none; border: 0; color: #78716c; font-size: 14px; cursor: pointer; }
.sw-qsheet .hint { display: none; }
.sw-qsheet .done { text-align: center; }
.sw-qsheet .done .big { font-size: 44px; margin-bottom: 10px; }
.sw-qsheet .done h2 { font-size: 20px; margin-bottom: 8px; }
.sw-qsheet .done p { color: var(--swab-muted); margin-bottom: 16px; line-height: 1.5; }
.sw-qsheet .done .row { justify-content: center; flex-wrap: wrap; }
