/* Big Picture (/big-picture): Studio Umbra over the whole screen, read from across a room and steered with a controller.
   Shelves of tiles that scroll sideways, the taskbar's programs in a pane on the right, and a focus ring big enough to
   follow from the sofa. In a browser only the "in the desktop app" note is drawn: html[data-shell] is the client's. */

.bp {
    --bp-gap: clamp(1rem, 1.6vw, 2rem);
    /* Inside the edge, not outside it: a shelf scrolls sideways, and a scroller clips whatever sticks out of it - a lifted
       card or an outer glow had its top cut off. Focus changes the card's light, never its size or place. */
    --bp-ring: inset 0 0 0 3px var(--rl-accent), inset 0 0 0 5px color-mix(in srgb, var(--rl-accent) 30%, transparent);
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(120% 80% at 10% -10%, color-mix(in srgb, var(--rl-accent) 16%, transparent), transparent 60%),
        radial-gradient(90% 70% at 110% 110%, color-mix(in srgb, hsl(275 70% 55%) 14%, transparent), transparent 60%),
        var(--rl-bg);
    color: var(--rl-text);
    font-size: clamp(16px, 1.1vw, 22px);
}

.bp__desk { display: none; }
html[data-shell="desktop"] .bp__desk { display: grid; }
html[data-shell="desktop"] .bp__browser { display: none; }

/* ---- in a browser ------------------------------------------------------------------------------------------- */

.bp__browser {
    display: grid;
    justify-items: center;
    gap: 1rem;
    max-width: 36rem;
    margin: 0 auto;
    padding: 18vh 1.5rem 3rem;
    text-align: center;
}
.bp__browser h1 { margin: 0; font-size: 1.75rem; }
.bp__browser p { margin: 0; color: var(--rl-text-muted); line-height: 1.55; }
.bp__browserActions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 0.5rem; }

/* ---- the screen ----------------------------------------------------------------------------------------------- */

.bp__desk {
    grid-template-columns: minmax(0, 1fr) clamp(15rem, 20vw, 22rem);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "bar bar" "main pins" "hints hints";
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.bp__bar {
    grid-area: bar;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: var(--bp-gap) calc(var(--bp-gap) * 1.5) calc(var(--bp-gap) * 0.5);
}
.bp__mark { width: 2.5rem; height: 2.5rem; }
.bp__title { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.bp__spacer { flex: 1; }
.bp__clock { font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--rl-text-muted); }

.bp__exit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--rl-border);
    border-radius: 999px;
    background: var(--rl-surface);
    color: var(--rl-text);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: box-shadow var(--rl-dur) var(--rl-ease), background var(--rl-dur) var(--rl-ease);
}
.bp__exit svg { width: 1.1rem; height: 1.1rem; }
.bp__exit:hover { background: var(--rl-surface-raised); }
.bp__exit:focus-visible, .bp__exit:focus { outline: none; box-shadow: var(--bp-ring); }

.bp__main {
    grid-area: main;
    overflow-y: auto;
    padding: calc(var(--bp-gap) * 0.5) 0 var(--bp-gap) calc(var(--bp-gap) * 1.5);
    scroll-padding: 2rem;
    scrollbar-width: none;
}
.bp__main::-webkit-scrollbar { display: none; }

.bp__shelf { margin-bottom: calc(var(--bp-gap) * 1.2); }
.bp__shelfTitle {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--rl-text-muted);
}

/* A shelf scrolls sideways, as on a television; the padding is room for the focus ring and the lift. */
.bp__row {
    display: flex;
    gap: var(--bp-gap);
    margin: 0;
    padding: 0.25rem calc(var(--bp-gap) * 1.5) 0.5rem 0;
    list-style: none;
    overflow-x: auto;
    scroll-padding-inline: 2rem;
    scrollbar-width: none;
}
.bp__row::-webkit-scrollbar { display: none; }
.bp__row > li { flex: none; }

/* ---- tiles ------------------------------------------------------------------------------------------------------ */

.bp-tile {
    --tile-hue: 225;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.35rem;
    width: clamp(11rem, 13vw, 16rem);
    height: clamp(8rem, 9.5vw, 11.5rem);
    padding: 1.1rem 1.2rem;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, hsl(var(--tile-hue) 70% 55%) 35%, var(--rl-border));
    border-radius: 18px;
    background:
        linear-gradient(160deg, color-mix(in srgb, hsl(var(--tile-hue) 70% 55%) 30%, transparent), transparent 70%),
        var(--rl-surface);
    color: var(--rl-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow 0.18s var(--rl-ease), border-color 0.18s var(--rl-ease), background-color 0.18s var(--rl-ease);
}
.bp-tile--big { width: clamp(17rem, 21vw, 26rem); height: clamp(11rem, 13vw, 16rem); }
.bp-tile:hover { border-color: color-mix(in srgb, hsl(var(--tile-hue) 70% 55%) 70%, var(--rl-border)); }
.bp-tile:focus-visible, .bp-tile:focus {
    outline: none;
    border-color: var(--rl-accent);
    background-color: color-mix(in srgb, var(--rl-surface) 85%, var(--rl-accent));
    box-shadow: var(--bp-ring);
}

.bp-tile__icon {
    position: absolute;
    top: 1rem;
    left: 1.1rem;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 14px;
    background: hsl(var(--tile-hue) 70% 55%);
    color: #fff;
}
.bp-tile__icon svg { width: 1.6rem; height: 1.6rem; }
.bp-tile--big .bp-tile__icon { width: 3.6rem; height: 3.6rem; }
.bp-tile--big .bp-tile__icon svg { width: 2rem; height: 2rem; }
.bp-tile__title { font-size: 1.15rem; font-weight: 650; line-height: 1.2; }
.bp-tile--big .bp-tile__title { font-size: 1.45rem; }
.bp-tile__desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--rl-text-muted);
    font-size: 0.9rem;
    line-height: 1.35;
}
.bp-tile__meta { color: var(--rl-text-muted); font-size: 0.85rem; }
.bp-tile--game { --tile-hue: 300; }
.bp-tile:disabled { opacity: 0.6; cursor: progress; }

/* ---- the taskbar pane --------------------------------------------------------------------------------------------- */

.bp__taskbar {
    grid-area: pins;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: calc(var(--bp-gap) * 0.5) calc(var(--bp-gap) * 1.5) var(--bp-gap) 0;
    padding: 1.1rem;
    border: 1px solid var(--rl-border);
    border-radius: 20px;
    background: color-mix(in srgb, var(--rl-surface) 82%, transparent);
    backdrop-filter: blur(12px);
}

.bp__pins {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    overflow-y: auto;
    scrollbar-width: thin;
}

.bp-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.75rem 0.4rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--rl-text);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--rl-dur) var(--rl-ease), box-shadow var(--rl-dur) var(--rl-ease);
}
.bp-pin img, .bp-pin svg { width: 3rem; height: 3rem; }
.bp-pin span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
    text-align: center;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.bp-pin:hover { background: var(--rl-surface-sunken); }
.bp-pin:focus-visible, .bp-pin:focus { outline: none; background: var(--rl-surface-sunken); box-shadow: var(--bp-ring); }

.bp__pinsNote { margin: 0.5rem 0 0; color: var(--rl-text-muted); font-size: 0.9rem; line-height: 1.45; }
.bp__pinsNote:empty { display: none; }

/* ---- what the buttons do ---------------------------------------------------------------------------------------- */

.bp__hints {
    grid-area: hints;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 1.5rem;
    padding: 0.75rem calc(var(--bp-gap) * 1.5) 1rem;
    color: var(--rl-text-muted);
    font-size: 0.9rem;
}
.bp__hints span { display: inline-flex; align-items: center; gap: 0.35rem; }
.bp__hints kbd {
    display: inline-grid;
    place-items: center;
    min-width: 1.7rem;
    height: 1.7rem;
    padding: 0 0.4rem;
    border: 1px solid var(--rl-border);
    border-radius: 999px;
    background: var(--rl-surface);
    color: var(--rl-text);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ---- the dock, on every other page while Big Picture is on ----------------------------------------------------- */

.bp-dock {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.6rem;
}
.bp-dock[hidden] { display: none; }

.bp-dock__bar {
    display: flex;
    gap: 0.25rem;
    padding: 0.3rem;
    border: 1px solid var(--rl-menu-edge, var(--rl-border));
    border-radius: 999px;
    background: var(--rl-surface);
    box-shadow: var(--rl-menu-shadow, 0 12px 32px -8px rgba(0, 0, 0, 0.4));
}

.bp-dock__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--rl-text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}
.bp-dock__btn svg { width: 1.1rem; height: 1.1rem; }
.bp-dock__btn:hover, .bp-dock__btn:focus-visible { background: var(--rl-surface-sunken); outline: none; }

.bp-dock__drawer {
    width: min(26rem, calc(100vw - 2.5rem));
    max-height: min(32rem, 70vh);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid var(--rl-menu-edge, var(--rl-border));
    border-radius: 20px;
    background: var(--rl-surface);
    box-shadow: var(--rl-menu-shadow, 0 12px 32px -8px rgba(0, 0, 0, 0.4));
}
.bp-dock__drawer[hidden] { display: none; }

/* ---- a line about what just happened ----------------------------------------------------------------------------- */

.bp-say {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    z-index: 2147483001;
    max-width: min(36rem, calc(100vw - 2rem));
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    background: var(--rl-text);
    color: var(--rl-bg);
    font-size: 1rem;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 1rem);
    transition: opacity 0.2s var(--rl-ease), transform 0.2s var(--rl-ease);
}
.bp-say.is-shown { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
    .bp__desk { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "main" "pins" "hints"; grid-template-rows: auto minmax(0, 1fr) auto auto; }
    .bp__taskbar { margin: 0 var(--bp-gap) var(--bp-gap); max-height: 30vh; }
}

@media (prefers-reduced-motion: reduce) {
    .bp-tile, .bp-say { transition: none; }
}

/* ---- the system tray: the apps' icons, then the sound, connection and battery ------------------------------------ */

.bp-tray { position: relative; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.bp-tray:empty { display: none; }
.bp-tray__icons { display: flex; flex-wrap: wrap; gap: 0.15rem; margin: 0; padding: 0; list-style: none; max-width: min(36rem, 40vw); }

.bp-tray__icon, .bp-tray__status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--rl-text);
    font: inherit;
    cursor: pointer;
    transition: background var(--rl-dur) var(--rl-ease), box-shadow var(--rl-dur) var(--rl-ease);
}
.bp-tray__icon { width: 2.4rem; height: 2.4rem; border-radius: 10px; }
.bp-tray__icon img, .bp-tray__icon svg { width: 1.5rem; height: 1.5rem; }
/* The hidden ones (Windows' "Show hidden icons") come after the rest, a little quieter, once the "^" is pressed. */
.bp-tray__icon.is-hidden { opacity: 0.75; }
.bp-tray__more svg { width: 1.1rem; height: 1.1rem; transform: rotate(-90deg); transition: transform var(--rl-dur) var(--rl-ease); }
.bp-tray__more.is-open svg { transform: rotate(90deg); }
.bp-tray__status { height: 2.4rem; padding: 0 0.8rem; border-color: var(--rl-border); border-radius: 999px; background: var(--rl-surface); font-size: 0.9rem; }
.bp-tray__status svg { width: 1.2rem; height: 1.2rem; }
.bp-tray__battery { display: inline-flex; align-items: center; gap: 0.2rem; font-variant-numeric: tabular-nums; }
.bp-tray__battery.is-charging svg { color: var(--rl-ok); }
.bp-tray__icon:hover, .bp-tray__status:hover { background: var(--rl-surface-sunken); }
.bp-tray__icon:focus-visible, .bp-tray__icon:focus, .bp-tray__status:focus-visible, .bp-tray__status:focus {
    outline: none;
    background: var(--rl-surface-sunken);
    box-shadow: var(--bp-ring, inset 0 0 0 2px var(--rl-accent));
}

/* The sound, opened from the status button. */
.bp-volume {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 18rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--rl-menu-edge, var(--rl-border));
    border-radius: 16px;
    background: var(--rl-surface);
    box-shadow: var(--rl-menu-shadow, 0 12px 32px -8px rgba(0, 0, 0, 0.4));
}
.bp-volume input { flex: 1; accent-color: var(--rl-accent); }
.bp-volume__mute { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 0; border-radius: 10px; background: var(--rl-surface-sunken); color: var(--rl-text); cursor: pointer; }
.bp-volume__mute svg { width: 1.3rem; height: 1.3rem; }
.bp-volume__mute:focus-visible, .bp-volume__mute:focus { outline: none; box-shadow: inset 0 0 0 2px var(--rl-accent); }
.bp-volume__level { min-width: 3.5rem; text-align: right; color: var(--rl-text-muted); font-variant-numeric: tabular-nums; }
.bp-dock__drawer .bp-tray { flex-wrap: wrap; margin-bottom: 0.75rem; }
.bp-dock__drawer .bp-tray__icons { max-width: none; }

/* ---- the overlay (/desktop/overlay) over other programs ------------------------------------------------------------ */

/* The page's own background is left off: the client keys it out, and a dimmed window under it (OverlayWindow) is what makes
   the game behind read as behind. The panels are solid, so their text never sits on the keyed colour. */
html:has([data-desktop-overlay]), html:has([data-desktop-overlay]) body { background: transparent !important; }
html:has([data-desktop-overlay]) .desk { background: transparent; }

.ov {
    --bp-gap: clamp(1rem, 1.6vw, 2rem);
    --bp-ring: inset 0 0 0 3px var(--rl-accent), inset 0 0 0 5px color-mix(in srgb, var(--rl-accent) 30%, transparent);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100vh;
    height: 100dvh;
    color: var(--rl-text);
    font-size: clamp(16px, 1.05vw, 20px);
    animation: ov-in 0.16s var(--rl-ease) both;
}
@keyframes ov-in { from { opacity: 0; } to { opacity: 1; } }

.ov__browser { display: none; }
html:not([data-shell]) .ov__browser { display: block; margin: 20vh auto 0; max-width: 32rem; text-align: center; color: var(--rl-text-muted); }
html:not([data-shell]) .ov__bar, html:not([data-shell]) .ov__grid, html:not([data-shell]) .ov .bp__hints { display: none; }

/* Big Picture's hint row names a grid area of its own; in the overlay's three plain rows that name made extra columns. */
.ov > .bp__hints { grid-area: auto; }
/* The bar sits on the dimmed program too, so it gets a panel of its own. */
.ov__bar { margin: var(--bp-gap) calc(var(--bp-gap) * 1.5) 0; border: 1px solid color-mix(in srgb, var(--rl-border) 70%, transparent); border-radius: 20px; background: var(--rl-surface); }
.ov > .bp__hints { margin: 0 calc(var(--bp-gap) * 1.5) var(--bp-gap) auto; padding: 0.5rem 1rem; border-radius: 999px; background: var(--rl-surface); }
.ov__bar { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; }
.ov__mark { width: 2.25rem; height: 2.25rem; }
.ov__title { font-size: 1.35rem; font-weight: 700; }

.ov__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: var(--bp-gap);
    align-content: start;
    min-height: 0;
    padding: calc(var(--bp-gap) * 0.5) calc(var(--bp-gap) * 1.5);
    overflow-y: auto;
}

.ov__panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 1.1rem 1.2rem;
    border: 1px solid color-mix(in srgb, var(--rl-border) 70%, transparent);
    border-radius: 20px;
    background: var(--rl-surface);
}

.ov__ask { display: grid; gap: 0.6rem; margin-bottom: 1.1rem; }
.ov__ask textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--rl-border);
    border-radius: 14px;
    background: var(--rl-surface-sunken);
    color: var(--rl-text);
    font: inherit;
    resize: none;
}
.ov__ask textarea:focus { outline: none; border-color: var(--rl-accent); box-shadow: var(--rl-ring); }
.ov__ask .btn { justify-self: end; }
.ov__ask .btn:focus { box-shadow: var(--bp-ring); }

.ov__links { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.ov__link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--rl-border);
    border-radius: 14px;
    background: var(--rl-surface);
    color: var(--rl-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.ov__link svg { width: 1.25rem; height: 1.25rem; flex: none; color: var(--rl-text-muted); }
.ov__link:hover { background: var(--rl-surface-sunken); }
.ov__link:focus-visible, .ov__link:focus { outline: none; border-color: var(--rl-accent); box-shadow: var(--bp-ring); }

.ov .bp__pins { grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); }

@media (max-width: 900px) {
    .ov__grid { grid-template-columns: minmax(0, 1fr); }
}
