/*
 * Miguel Rodríguez Gallego: personal site.
 * Look: soft sky-blue pastel base, white surfaces, navy text and a few pastel accents.
 */

@font-face {
    font-family: "Nunito";
    src: url("../assets/fonts/nunito.woff2") format("woff2-variations");
    font-weight: 200 1000;
    font-display: swap;
}

:root {
    --bg: #d6ebff;          /* page: brighter pastel sky blue */
    --surface: #ffffff;     /* cards, panels, inputs */
    --line: #bcdcf5;        /* borders and dividers */
    --text: #17304f;        /* main text: deep navy */
    --muted: #405b7d;       /* secondary text, darkened for small sizes */
    --link: #1267b8;        /* links */
    --sky: #7cc4ff;         /* primary buttons, current page */
    --sky-soft: #cfe9ff;    /* hovers, tag fills */
    --header: #17304f;      /* sticky bar: deep navy, a clear layer over the pastel page */
    --sky-deep: #64b2f2;    /* slightly deeper blue: button hovers */
    --butter: #fff0b3;      /* pastel yellow: link-list highlight */
    --card-gap: 0.9rem;     /* one rhythm for media, title, text and links */

    --zone-game: #008577;   /* vivid teal: games */
    --zone-code: #4153c8;   /* richer indigo: code */
    --zone-art: #ad6200;    /* vivid amber: art */
    --zone-audio: #0070cc;  /* vivid blue: audio */
}

/* Each section owns one colour; Home stays neutral and colours cards individually. */
body[data-zone="game"]  { --page-accent: var(--zone-game); }
body[data-zone="code"]  { --page-accent: var(--zone-code); }
body[data-zone="art"]   { --page-accent: var(--zone-art); }
body[data-zone="audio"] { --page-accent: var(--zone-audio); }
body[data-zone] { --page-accent-soft: color-mix(in srgb, var(--page-accent) 14%, var(--surface)); }

/* Each zone keeps its own hue at Home's lightness; a small share of Home's sky
   keeps the set harmonious. --zone-tray-tint stays stronger for the filter panel. */
html:has(body[data-zone]) { --zone-bg-pastel: 85%; }
html:has(body[data-zone="game"])  { --zone-tray-tint: 34%; --scroll-thumb: var(--zone-game); --page-bg: color-mix(in srgb, #dcfaf3 var(--zone-bg-pastel), var(--bg)); }
html:has(body[data-zone="code"])  { --zone-tray-tint: 34%; --scroll-thumb: var(--zone-code); --page-bg: color-mix(in srgb, #d7d9ff var(--zone-bg-pastel), var(--bg)); }
html:has(body[data-zone="art"])   { --zone-tray-tint: 34%; --scroll-thumb: var(--zone-art); --page-bg: color-mix(in srgb, #fff0d7 var(--zone-bg-pastel), var(--bg)); }
html:has(body[data-zone="audio"]) { --zone-tray-tint: 34%; --scroll-thumb: var(--zone-audio); --page-bg: color-mix(in srgb, #d6ebff var(--zone-bg-pastel), var(--bg)); }

:root {
    --font: "Nunito", system-ui, sans-serif;
    --step--1: 0.8125rem;
    --step-0: 1rem;
    --step-1: 1.1875rem;
    --step-2: clamp(1.4rem, 1.2rem + 0.8vw, 1.85rem);
    --step-3: clamp(1.9rem, 1.4rem + 2vw, 2.75rem);

    --wrap: 72rem;
    --card: 17rem;          /* one fixed card size across every library grid */
    --audio-card: 16rem;    /* square covers stay a touch smaller */
    --gutter: clamp(1.25rem, 3vw, 2rem);
    --bar: 3.75rem;
    --shadow: 0 1px 2px rgb(23 48 79 / 0.06), 0 8px 24px rgb(23 48 79 / 0.1);
    --radius: 14px;
}

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

/* `display` on components must not override the HTML hidden attribute. */
[hidden] {
    display: none !important;
}

html {
    --scroll-thumb: var(--link);
    background: var(--page-bg, var(--bg));
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--bar) + 1rem);
    color-scheme: light;
    scrollbar-color: var(--scroll-thumb) var(--page-bg, var(--bg));
    scrollbar-width: thin;
    scrollbar-gutter: stable;
}

/* A modal sheet owns the scroll: the page behind it must stay put. Reserving
   the gutter above keeps this from shifting the layout when it opens. */
html:has(dialog[open]) {
    overflow: hidden;
}

/* Chromium/WebKit: a soft pastel rail with a rounded sky thumb. */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--scroll-thumb) 8%, var(--page-bg, var(--bg)));
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--scroll-thumb);
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--scroll-thumb) 75%, black);
    background-clip: padding-box;
}

body {
    /* Every page derives its accents from one hue: its own zone colour. */
    --zone-accent: var(--page-accent, var(--link));
    --zone-accent-mid: color-mix(in srgb, var(--zone-accent) 85%, black);
    --zone-accent-deep: color-mix(in srgb, var(--zone-accent) 70%, black);
    --zone-accent-soft: color-mix(in srgb, var(--zone-accent) 14%, var(--surface));
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--page-bg, var(--bg));
    color: var(--text);
    font-family: var(--font);
    font-size: var(--step-0);
    line-height: 1.55;
}

img,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

[data-icon-sprite] {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

a {
    color: var(--link);
    text-underline-offset: 0.18em;
}

a:hover {
    text-decoration-thickness: 2px;
}

:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 3px;
}

:is(a, button, input, summary, [tabindex]):focus-visible:not(.focus-quiet) {
    box-shadow: 0 0 0 5px rgb(18 103 184 / 0.14);
}

h1,
h2,
h3 {
    margin: 0 0 0.45em;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

h1 {
    font-size: var(--step-3);
}

h2 {
    font-size: var(--step-2);
}

h3 {
    font-size: var(--step-1);
}

p {
    margin: 0 0 1em;
    max-width: 68ch;
}

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    color: var(--text);
    z-index: 200;
}

.skip:focus {
    top: 1rem;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    fill: currentColor;
    flex: none;
}

/* ---------- Header and footer ---------- */

/* The bar stays at the top while scrolling. */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid rgb(255 255 255 / 0.16);
    background: var(--header);
    box-shadow: 0 4px 18px rgb(23 48 79 / 0);
    transition: box-shadow 0.2s ease-out;
}

.site-header.is-scrolled {
    box-shadow: 0 4px 18px rgb(23 48 79 / 0.22);
}

/* A 2px reading-progress line, drawn in the colour of the current zone. */
.site-header::after {
    content: "";
    position: absolute;
    inset: auto 0 -1px;
    height: 2px;
    background: var(--page-accent, var(--sky));
    transform: scaleX(var(--scroll-progress, 0));
    transform-origin: left center;
    pointer-events: none;
}

/* Router: only the current page is visible; the others stay in the same document. */
.route-page[hidden] {
    display: none !important;
}

/* The served page is hidden while the router swaps in the requested one. */
.route-page.route-pending {
    visibility: hidden;
}

/* Added in <head>, before the browser can paint the file it happened to open. */
html.route-booting main {
    visibility: hidden;
}

.bar,
main,
.site-footer {
    width: min(100% - 2 * var(--gutter), var(--wrap));
    margin-inline: auto;
}

.bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem 2rem;
    min-height: var(--bar);
}

.brand {
    justify-self: start;
    color: #fff;
    font-weight: 900;
    font-size: 1.25rem;
    text-decoration: none;
}

.brand span {
    color: var(--sky);
}

.site-nav {
    justify-self: center;
}

/* Share icon and Contact button stay together on the right. */
.bar-actions {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 0.75rem;
}

/* A soft sky pill sets Share apart from the plain white nav without bringing
   back the white outline the header did not need. */
.header-share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--sky) 28%, transparent);
    color: var(--sky);
    opacity: 1;
    text-decoration: none;
}

.header-share:hover,
.header-share:focus-visible {
    background: color-mix(in srgb, var(--sky) 44%, transparent);
    color: #fff;
}

.header-share .icon {
    width: 1.15rem;
    height: 1.15rem;
}

/* The header Contact button should match the size of the nav links. */
.bar-actions .button.small {
    font-size: 1.05rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 1.15rem;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.nav-toggle:hover {
    background: rgb(255 255 255 / 0.12);
}

.site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav a {
    --nav-accent: var(--sky);
    position: relative;
    color: rgb(255 255 255 / 0.82);
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
}

/* Each destination keeps its own zone colour, even from another page. */
.site-nav a[href*="games/index.html"] { --nav-accent: var(--zone-game); }
.site-nav a[href*="code/index.html"]  { --nav-accent: var(--zone-code); }
.site-nav a[href*="art/index.html"]   { --nav-accent: var(--zone-art); }
.site-nav a[href*="music/index.html"] { --nav-accent: var(--zone-audio); }

.site-nav a:hover {
    color: #fff;
}

.site-nav a[aria-current="page"] {
    color: #fff;
}

/* The underline is drawn on hover/focus and stays drawn on the current page. */
.site-nav a::after {
    content: "";
    position: absolute;
    inset: auto 0 -0.3rem;
    height: 2px;
    border-radius: 2px;
    background-image: linear-gradient(var(--nav-accent), var(--nav-accent));
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0 100%;
    transition: background-size 0.1s ease-out;
}

/* Hover is only a hint; the full underline belongs to the current page. */
.site-nav a:hover::after {
    background-size: 45% 100%;
    opacity: 0.65;
}

.site-nav a:focus-visible::after,
.site-nav a[aria-current="page"]::after {
    background-size: 100% 100%;
    opacity: 1;
}

main {
    flex: 1;
    padding-block: 1.25rem 2.5rem;
}

/* Home has a taller hero, so it keeps a slightly wider gap under the bar. */
body.home main {
    padding-top: 2.5rem;
}

.site-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 0.75rem 1rem;
    padding-block: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--step--1);
}

.site-footer p,
.site-footer a {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
}

.site-footer a {
    color: inherit;
}

.site-footer .icon {
    flex: none;
    width: 0.9rem;
    height: 0.9rem;
}

.site-footer a:has(use[href="#github"]) .icon { color: var(--zone-code); }
.site-footer a:has(use[href="#mail"]) .icon { color: var(--sky-deep); }

.site-footer .footer-center {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
}

.site-footer .footer-source {
    justify-content: flex-end;
}

.site-footer a {
    position: relative;
}

/* Same centre-out draw as the navigation, starting after the small icon. */
.site-footer a::after {
    content: "";
    position: absolute;
    inset: auto 0 0 1.2rem;
    height: 1px;
    background-image: linear-gradient(currentColor, currentColor);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 0 100%;
    transition: background-size 0.1s ease-out;
    pointer-events: none;
}

.site-footer a:hover::after,
.site-footer a:focus-visible::after {
    background-size: 100% 100%;
}

.site-footer .footer-share {
    color: var(--link);
    font-weight: 600;
    text-decoration: none;
}

/* Back to top: appears quietly once the page has been scrolled. */
.to-top {
    position: fixed;
    right: var(--gutter);
    bottom: calc(0.75rem + var(--soundbar-space, 0px));
    z-index: 60;
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--page-accent, var(--zone-accent));
    box-shadow: 0 6px 18px rgb(23 48 79 / 0.16);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease-out;
}

.to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.to-top .icon {
    width: 1.1rem;
    height: 1.1rem;
}

@media (max-width: 52rem) {
    .site-footer {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .site-footer .footer-copy,
    .site-footer .footer-center,
    .site-footer .footer-source {
        justify-content: center;
        text-align: center;
    }
}

/* ---------- Buttons, tags ---------- */

.button {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.6em 1.1em;
    border: 2px solid var(--sky);
    border-radius: 999px;
    background: var(--sky);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    background: var(--sky-deep);
    border-color: var(--sky-deep);
}

.button.ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
}

.button.ghost:hover {
    border-color: var(--zone-accent);
    background: var(--zone-accent-soft);
}

.button.small {
    font-size: var(--step--1);
    padding: 0.4em 0.9em;
}

.button[aria-current="page"] {
    background: var(--page-accent, var(--sky));
    border-color: var(--page-accent, var(--sky));
}

body[data-zone] .button[aria-current="page"] {
    color: #fff;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.button .icon {
    flex: none;
    width: 1rem;
    height: 1rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.tags li {
    padding: 0.1em 0.6em;
    border-radius: 999px;
    background: color-mix(in srgb, var(--card-accent, var(--zone-accent)) 14%, var(--surface));
    color: var(--text);
    font-size: var(--step--1);
}

.meta {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: var(--step--1);
}

.lead {
    font-size: 1.15rem;
    line-height: 1.45;
    max-width: 46ch;
    color: var(--muted);
}

/* ---------- Home: round photo, greeting and social icons ---------- */

.intro {
    display: grid;
    grid-template-columns: minmax(0, 13.5rem) minmax(0, 1fr);
    align-items: center;
    gap: 1.75rem;
}

.intro .lead {
    max-width: none;
    font-size: 1.1rem;
}

.portrait {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border: 6px solid var(--surface);
    border-radius: 50%;
    box-shadow: var(--shadow);
}

.intro h1 {
    font-size: var(--step-3);
}

.intro .actions {
    align-items: center;
    margin-bottom: 1.25rem;
}

/* Social links get their own quiet row under the buttons. */
.intro .social {
    margin: 1.15rem 0 0;
}

.social {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.social a {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s, color 0.15s;
}

.social a:hover {
    border-color: var(--sky);
    transform: translateY(-2px);
}

.social .icon {
    width: 1.15rem;
    height: 1.15rem;
}

/* Every network keeps its zone colour on Home, Share and Contact. */
.social a:has(use[href="#linkedin"])  { color: var(--sky-deep); }
.social a:has(use[href="#github"])    { color: var(--zone-code); }
.social a:has(use[href="#itch"])      { color: var(--zone-game); }
.social a:has(use[href="#artstation"]){ color: var(--zone-art); }
.social a:has(use[href="#soundcloud"]){ color: var(--zone-audio); }

/* Some symbols have a lot of empty space in their 24×24 viewBox. */
.social .icon:has(use[href="#soundcloud"]) {
    width: 1.45rem;
    height: 1.45rem;
}

.social .icon:has(use[href="#linkedin"]),
.social .icon:has(use[href="#itch"]),
.social .icon:has(use[href="#artstation"]) {
    width: 1.28rem;
    height: 1.28rem;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem 2rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

/* Section titles read as eyebrows; category titles are the new library labels. */
.section-head h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.group-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.25;
}

.section-head h2::after,
.group-head h2::after {
    content: "";
    display: block;
    width: 2.25rem;
    height: 2px;
    margin: 0.45rem auto 0;
    border-radius: 999px;
    background: var(--zone-accent, var(--header));
}

.section-head p {
    margin: 0;
}

/* Toolbox closes the shelf with the same head as a category, then plain tags. */
.knowledge {
    margin: 2.5rem 0 0;
}

.knowledge .group-head {
    margin-bottom: 0.85rem;
}

.knowledge-groups {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem 1.1rem;
}

.knowledge-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem 0.45rem;
}

.knowledge-group > svg {
    flex: none;
    width: 1rem;
    height: 1rem;
    color: var(--zone-accent);
}

.knowledge-group h3 {
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.knowledge-group ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.knowledge-group li {
    padding: 0.2em 0.6em;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.3;
}

section + section {
    margin-top: 3rem;
}

@media (max-width: 36rem) {
    .knowledge-group {
        width: 100%;
    }
}

/* ---------- Project cards (home, Code page) ---------- */

/* Flex keeps the fixed card size and centers every row, including the last one. */
.cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cards > *,
.group .games > *,
.gallery > * {
    flex: 0 1 var(--card);
    min-width: 0;
}

.audio-grid > * {
    flex: 0 1 var(--audio-card);
    min-width: 0;
}

.card {
    display: flex;
    flex-direction: column;
}

.media {
    position: relative;
    aspect-ratio: 16 / 9;
    margin-bottom: 0.75rem;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
}

.media-backdrop {
    display: block;
    position: absolute;
    inset: -12%;
    z-index: 0;
    background-image: var(--cover, none);
    background-position: center;
    background-size: cover;
    filter: blur(16px) brightness(0.82) saturate(1.1);
    transform: scale(1.06);
}

.media [data-media-slide] {
    z-index: 1;
}

.media img,
.media video,
.media .card-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Cards use one fixed 16:9 cover; the blurred copy is only a load fallback. */
.media:not(.dialog-media) .card-cover {
    object-fit: cover;
    object-position: var(--cover-position, center);
    border-radius: 0;
}

/* Tall artwork (for example Rope Monster) keeps its full frame over a blurred copy. */
.media.contain:not(.dialog-media) .card-cover {
    object-fit: contain;
}

/* Artwork covers keep the subject in frame while the zoom shows the whole piece. */
.card[data-project="home-art"] .card-cover { --cover-position: 50% 42%; }
.card[data-project="cowboy-digital"] .card-cover { --cover-position: 50% 42%; }
.card[data-project="explorer"] .card-cover { --cover-position: 50% 32%; }
.card[data-project="cowboy-drawing"] .card-cover { --cover-position: 50% 45%; }

.media video {
    object-fit: cover;
}

/* Dialog stills keep the whole frame; only the card cover is cropped. */
.dialog-media img,
.dialog-media video {
    object-fit: contain;
}

.media video {
    opacity: 0;
    transition: opacity 0.2s;
}

.media.playing video {
    opacity: 1;
}

.media video[data-media-slide]:not([hidden]),
.dialog-media video[data-media-slide]:not([hidden]) {
    opacity: 1;
}

.media [hidden],
.dialog-media [hidden] {
    display: none !important;
}

.media-arrow {
    position: absolute;
    top: 50%;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(23 48 79 / 0.62);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 0.15s, background 0.15s;
}

.media-prev { left: 0.5rem; }
.media-next { right: 0.5rem; }

.media-arrow:hover,
.media-arrow:focus-visible,
.media:hover .media-arrow,
.dialog-media:hover .media-arrow,
.dialog-media:focus-within .media-arrow {
    opacity: 1;
}

.media-arrow:hover {
    background: rgb(23 48 79 / 0.85);
}

/* A quiet hint that the sheet starts with a trailer; the card itself stays still. */
.trailer-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgb(23 48 79 / 0.68);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
}

.trailer-badge svg {
    width: 0.7rem;
    height: 0.7rem;
    fill: currentColor;
}

/* Detail hero: a hairline progress bar and a pause control sharing the zone colour. */
.media-progress {
    position: absolute;
    inset: auto 0 0;
    z-index: 6;
    height: 3px;
    background: color-mix(in srgb, var(--card-accent, var(--zone-accent)) 20%, var(--surface));
    pointer-events: none;
}

.media-progress::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background: var(--card-accent, var(--zone-accent));
    transform: scaleX(var(--progress, 0));
    transform-origin: left;
}

.media-autoplay {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(23 48 79 / 0.68);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.media-autoplay:hover,
.media-autoplay:focus-visible {
    background: rgb(23 48 79 / 0.85);
}

.media-autoplay svg {
    width: 0.8rem;
    height: 0.8rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.media-autoplay .auto-icon-play {
    display: none;
    fill: currentColor;
    stroke: none;
}

.media-autoplay.is-paused .auto-icon-pause { display: none; }
.media-autoplay.is-paused .auto-icon-play { display: block; }

/* A video already owns play/pause and fills the frame, so none of the tour
   badges belong on top of it. */
.dialog-media.auto-video .media-autoplay,
.dialog-media.auto-video .media-count {
    display: none;
}

img[data-media-open]:not([hidden]) {
    cursor: zoom-in;
}

img[data-media-open]:focus-visible,
.image-lightbox > img:focus-visible {
    outline: 3px solid var(--sky);
    outline-offset: -3px;
}

.media-chevron {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.media-count {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: rgb(23 48 79 / 0.68);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.3;
}

/* The artwork itself is the single way into the details. */
.media-open {
    position: absolute;
    inset: 0;
    z-index: 2;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
    cursor: pointer;
}

.media-open:focus-visible {
    outline: 3px solid var(--sky);
    outline-offset: -3px;
}

/* The small Details pill makes the whole card's purpose obvious. */
.card-links {
    align-items: center;
    gap: 0.35rem;
    margin-top: 0;
}

.card-details {
    height: 1.55rem;
    padding: 0 0.6rem;
    border-width: 1px;
    border-color: color-mix(in srgb, var(--card-accent) 55%, var(--line));
    background: color-mix(in srgb, var(--card-accent) 10%, var(--surface));
    font-size: 0.72rem;
}

.card-links > li {
    display: flex;
    align-items: center;
}

.card-details .icon {
    width: 0.8rem;
    height: 0.8rem;
}

:is(.card, .games .game):hover .card-details,
.card-details:focus-visible {
    border-color: var(--card-accent);
    background: color-mix(in srgb, var(--card-accent) 22%, var(--surface));
}

.icon-link {
    display: grid;
    place-items: center;
    width: 1.55rem;
    height: 1.55rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
}

.icon-link:hover,
.icon-link:focus-visible {
    border-color: var(--card-accent, var(--zone-accent));
    background: color-mix(in srgb, var(--card-accent, var(--zone-accent)) 14%, var(--surface));
    color: var(--card-accent, var(--zone-accent));
    transform: translateY(-2px);
}

.icon-link .icon {
    width: 0.8rem;
    height: 0.8rem;
    fill: currentColor;
}

/* Small, quiet motion on carousel arrows only; button icons stay put. */
.media-arrow svg,
.lightbox-arrow svg,
.dialog-step svg,
.dialog-arrow svg {
    transition: transform 0.15s ease-out;
}

[data-media-step="1"]:hover svg,
[data-media-step="1"]:focus-visible svg,
[data-dialog-step="1"]:hover svg,
[data-dialog-step="1"]:focus-visible svg,
[data-image-step="1"]:hover svg,
[data-image-step="1"]:focus-visible svg {
    transform: translateX(2px);
}

[data-media-step="-1"]:hover svg,
[data-media-step="-1"]:focus-visible svg,
[data-dialog-step="-1"]:hover svg,
[data-dialog-step="-1"]:focus-visible svg,
[data-image-step="-1"]:hover svg,
[data-image-step="-1"]:focus-visible svg {
    transform: translateX(-2px);
}

@media (hover: none) {
    .media-arrow { opacity: 0.95; }
}

.card:hover .media,
.card:has(:focus-visible:not(.focus-quiet)) .media {
    box-shadow: 0 0 0 1px var(--card-ring), 0 8px 18px var(--card-shadow);
}

.media {
    transition: box-shadow 0.18s;
}

/* Let the browser keep vertical scrolling while horizontal gestures reach the carousel. */
.media,
.image-lightbox .lightbox-stage {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

/* The whole card lifts and grows on hover or focus; the media is never cropped. */
:is(.card, .games .game, .audio-card, .gallery li):hover,
:is(.card, .games .game, .audio-card, .gallery li):has(:focus-visible:not(.focus-quiet)) {
    transform: translateY(-3px) scale(1.02);
}

@keyframes gridEnter {
    from { opacity: 0; }
    to { opacity: 1; }
}

:is([data-featured], [data-code], [data-games], [data-audio], [data-group-filter]).is-entering {
    animation: gridEnter 180ms ease-out both;
}

.card h3,
.games .game h2 {
    display: -webkit-box;
    overflow: hidden;
    margin-bottom: 0.2rem;
    font-size: 1.1rem;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.card p {
    font-size: 0.92rem;
    margin-bottom: 0;
}

.card .context,
.games .game .context {
    display: block;
    overflow: hidden;
    margin: 0 0 var(--card-gap);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.card .tags,
.games .game .tags {
    margin-bottom: 0.55rem;
}

.card .actions,
.games .game .actions {
    margin-top: 0;
}

/* ---------- Games page: compact itch.io-style cards ---------- */

.games .game {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.18s, box-shadow 0.18s;
}

.games .game:hover,
.games .game:has(:focus-visible:not(.focus-quiet)) {
    box-shadow: 0 0 0 1px var(--card-ring), 0 10px 22px var(--card-shadow);
}

.games .game .media {
    margin: 0;
    border-radius: 0;
    aspect-ratio: 16 / 9;
}

.game-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 0.9rem 1rem 1rem;
}

.games .game h2 {
    margin: 0 0 0.2rem;
    font-size: 1.05rem;
    line-height: 1.3;
}

.games .game .meta {
    margin-bottom: var(--card-gap);
    font-size: 0.78rem;
}

.games .game .role {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin: 0 0 var(--card-gap);
    padding-left: 0.6rem;
    border-left: 3px solid var(--sky);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.45;
}

.games .game .summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin: 0 0 var(--card-gap);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.games .game .tags {
    gap: 0.25rem;
    margin-bottom: 0.55rem;
}

.games .game .tags li {
    font-size: 0.72rem;
}

.games .game .actions {
    gap: 0.3rem 0.4rem;
}

.games .game .actions .button {
    padding: 0.22em 0.55em;
    font-size: 0.72rem;
}

/* ---------- Home: editorial highlights ---------- */

:is([data-featured], [data-code]) .card {
    position: relative;
    --card-accent: var(--sky);
    width: 100%;
    max-width: 24rem;
    min-width: 0;
    overflow: hidden;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.18s, box-shadow 0.18s;
}

/* A thin colour strip ties each card to its zone without adding a gradient. */
:is([data-featured], [data-code]) .card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    z-index: 2;
    height: 3px;
    background: var(--card-accent);
}

:is([data-featured], [data-code]) .card[data-zone="game"] { --card-accent: var(--zone-game); }
:is([data-featured], [data-code]) .card[data-zone="code"] { --card-accent: var(--zone-code); }
:is([data-featured], [data-code]) .card[data-zone="art"] { --card-accent: var(--zone-art); }
:is([data-featured], [data-code]) .card[data-zone="music"],
:is([data-featured], [data-code]) .card[data-zone="audio"] { --card-accent: var(--zone-audio); }

/* Games, Art and Music get the same strip so every page carries its zone colour. */
.games .game {
    position: relative;
    --card-accent: var(--zone-game);
}

.audio-card,
.audio-art { --card-accent: var(--zone-audio); }
.gallery li,
.gallery button { --card-accent: var(--zone-art); }

.games .game::before,
.audio-art::after,
.gallery button::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    z-index: 3;
    height: 3px;
    background: var(--card-accent);
}

/* The ring, glow and action icons reuse the zone colour instead of navy. */
:is([data-featured], [data-code]) .card,
.games .game,
.audio-card,
.gallery li {
    --card-ring: color-mix(in srgb, var(--card-accent) 38%, transparent);
    --card-shadow: color-mix(in srgb, var(--card-accent) 26%, transparent);
}

:is(.card, .games .game) .card-details .icon,
:is(.card, .games .game) .icon-link .icon,
[data-featured] .zone-link .icon {
    color: var(--card-accent);
}

:is([data-featured], [data-code]) .card:hover,
:is([data-featured], [data-code]) .card:has(:focus-visible:not(.focus-quiet)) {
    box-shadow: 0 0 0 1px var(--card-ring), 0 10px 22px var(--card-shadow);
}

:is([data-featured], [data-code]) .card:hover .media,
:is([data-featured], [data-code]) .card:has(:focus-visible:not(.focus-quiet)) .media {
    box-shadow: none;
}

:is([data-featured], [data-code]) .media {
    margin: -0.9rem -1rem var(--card-gap);
    border-radius: 0;
    aspect-ratio: 16 / 9;
}

:is([data-featured], [data-code]) .card h3 {
    margin: 0 0 0.2rem;
    font-size: 1.05rem;
    line-height: 1.25;
}

:is([data-featured], [data-code]) .card .meta,
:is([data-featured], [data-code]) .card .summary {
    margin-bottom: var(--card-gap);
}

:is([data-featured], [data-code]) .card .meta {
    font-size: 0.78rem;
}

:is([data-featured], [data-code]) .card .summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

:is([data-featured], [data-code]) .card .tags {
    gap: 0.25rem;
    margin-bottom: 0.55rem;
}

:is([data-featured], [data-code]) .card .tags li {
    font-size: 0.72rem;
}

:is([data-featured], [data-code]) .card .actions {
    gap: 0.3rem 0.4rem;
}

:is([data-featured], [data-code]) .card .actions .button {
    padding: 0.22em 0.55em;
    font-size: 0.72rem;
}

/* A single compact row of technologies keeps the card informative but short. */
:is([data-featured], [data-code]) .card .card-tags,
[data-games] .games .game .card-tags {
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 0.25rem;
    margin: 0 0 0.5rem;
}

.card .card-tags li,
.games .game .card-tags li {
    flex: 0 1 auto;
    max-width: 5.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-tags .tag-more {
    font-weight: 800;
}

/* Home zone cards: the zone name sits just above the card, outside its frame. */
[data-featured] .zone-item {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

[data-featured] .zone-label {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 0.35rem;
    margin: 0;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
}

[data-featured] .zone-label .icon {
    width: 1.1em;
    height: 1.1em;
    stroke: currentColor;
}

/* Each zone keeps the same label ink; only the icon carries its colour. */
[data-featured] .zone-label.zone-game .icon { color: var(--zone-game); }
[data-featured] .zone-label.zone-code .icon { color: var(--zone-code); }
[data-featured] .zone-label.zone-art .icon { color: var(--zone-art); }
[data-featured] .zone-label.zone-music .icon { color: var(--zone-audio); }

[data-featured] .zone-card .context {
    margin-bottom: 0;
}

[data-featured] .zone-card .zone-link {
    align-self: flex-start;
    margin-top: 0;
}

/* ---------- Code page ---------- */

/* The filters stay within reach while the cards scroll, just under the header. */
.filter-bar {
    position: sticky;
    top: var(--bar);
    z-index: 40;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
}

html:has(main:not([hidden]) .filter-bar) {
    scroll-padding-top: calc(var(--bar) + 4.75rem);
}

/* Keep the external icon on the first filter row while controls wrap inside. */
.filter-controls {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.filter-bar .filter-menu {
    flex: 0 0 auto;
    margin: 0;
}

.filter-bar .filter-external {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-left: 0;
    padding: 0.4em;
    color: var(--page-accent, var(--sky));
    transition: transform 0.15s;
}

/* Keep the filter-zone link buttons outlined: only the small lift remains. */
.filter-bar .filter-external:hover,
.filter-bar .filter-external:focus-visible {
    border-color: var(--line);
    background: var(--surface);
    transform: translateY(-2px);
}


/* A soft zone-coloured tray: enough contrast without drifting far from the sky base. */
.filter-bar {
    margin: 0 0 2rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid color-mix(in srgb, var(--zone-accent) 55%, var(--line));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--zone-accent) var(--zone-tray-tint, 24%), var(--surface));
}

.filter-menu {
    position: relative;
    margin: 0 0 1.5rem;
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

/* Inline layout keeps every word visible in browsers that hide flex <summary> children. */
.filter-menu > summary {
    display: block;
    width: fit-content;
    padding: 0.45em 0.9em;
    border: 2px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    list-style: none;
    /* No background transition: opening must never show white text on white. */
    transition: border-color 0.15s, transform 0.15s;
}

.filter-menu > summary > * {
    vertical-align: middle;
}

.filter-menu > summary .menu-label {
    margin-inline-end: 0.25rem;
}

.filter-menu > summary:hover {
    border-color: var(--zone-accent);
    background: var(--zone-accent-soft);
    transform: translateY(-1px);
}

.filter-menu[open] > summary {
    border-color: var(--zone-accent);
    background: var(--zone-accent);
    color: #fff;
}

/* Both menus share the same bare pill style. */
.filter-menu {
    padding: 0;
    border: 0;
    background: none;
}

.filter-menu > summary {
    border-width: 1px;
    background: transparent;
}

.filter-bar .filter-menu > summary {
    background: var(--surface);
}

/* Keep the label readable when a menu is open, not white on white. */
.filter-bar .filter-menu[open] > summary {
    border-color: var(--zone-accent);
    background: var(--zone-accent);
    color: #fff;
}

/* Category opens to the left; technology opens to the right. */
.group-filters[open] .filters {
    left: 0;
    right: auto;
}

.filter-menu .menu-label-short {
    display: none;
}

.filter-menu > summary::-webkit-details-marker {
    display: none;
}

.filter-menu > summary::after {
    content: "\25BE";
    display: inline-block;
    margin-inline-start: 0.35rem;
    font-size: 0.75rem;
    transition: transform 0.15s;
}

.filter-menu[open] {
    z-index: 5;
}

.filter-menu[open] > summary::after {
    transform: rotate(180deg);
}

.filter-menu[open] .filters {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 5;
    width: max-content;
    min-width: 18rem;
    max-width: min(90vw, 26rem);
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 24px rgb(23 48 79 / 0.18);
}

.filter-menu [data-category-status],
.filter-menu [data-filter-status] {
    display: inline-block;
    margin-inline-start: 0.25rem;
    padding: 0 0.5em;
    border-radius: 999px;
    background: var(--page-accent-soft, var(--sky-soft));
    color: var(--text);
    font-weight: 700;
}

.filter-menu[open] [data-category-status],
.filter-menu[open] [data-filter-status] {
    background: var(--surface);
}

.filter-menu .filters {
    margin: 0;
    gap: 0.3rem;
}

.filter-menu .filters legend {
    margin: 0;
}

.filter-menu .filters button {
    padding: 0.28em 0.7em;
    border-width: 1px;
    font-size: 0.8rem;
}

.filter-menu .count {
    margin-left: 0.25em;
    color: var(--muted);
    font-weight: 600;
}

.filter-menu button[aria-pressed="true"] .count {
    color: var(--text);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1.5rem;
    padding: 0;
    border: 0;
}

.filters legend {
    width: 100%;
    margin-bottom: 0.5rem;
    color: var(--muted);
}

.filters button {
    padding: 0.35em 0.9em;
    border: 2px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.filters button:hover {
    border-color: var(--page-accent, var(--sky));
}

.filters button[aria-pressed="true"] {
    background: var(--page-accent, var(--sky));
    border-color: var(--page-accent, var(--sky));
}

body[data-zone] .filters button[aria-pressed="true"],
.group-filters button[aria-pressed="true"] {
    color: #fff;
}

/* Category is the primary filter, so its active pill echoes the page colour. */
.group-filters button[aria-pressed="true"] {
    background: var(--page-accent, var(--header));
    border-color: var(--page-accent, var(--header));
}

.group-filters button[aria-pressed="true"] .count {
    color: rgb(255 255 255 / 0.8);
}

.group[hidden] {
    display: none;
}

.group-intro {
    color: var(--muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.empty {
    max-width: 28rem;
    margin: 1rem auto 0;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    text-align: center;
}

.empty .button {
    margin-top: 0.75rem;
}

/* ---------- Art page ---------- */

.gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gallery li {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.18s, box-shadow 0.18s;
}

.gallery li:hover,
.gallery li:has(:focus-visible:not(.focus-quiet)) {
    box-shadow: 0 0 0 1px var(--card-ring), 0 10px 22px var(--card-shadow);
}

.gallery button {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    cursor: pointer;
}

/* Blurred copy of the artwork fills the frame; nothing gets cropped. */
.gallery button::before {
    content: "";
    position: absolute;
    inset: -12%;
    background-image: var(--cover, none);
    background-position: center;
    background-size: cover;
    filter: blur(12px) brightness(0.75);
}

/* Blurred covers come from data attributes so the HTML has no inline styles. */
.gallery button[data-cover="cowboy-digital"]::before {
    background-image: url("../assets/art/cowboy-digital.thumb.webp");
}

.gallery button[data-cover="explorer"]::before {
    background-image: url("../assets/art/explorer.thumb.webp");
}

.gallery button[data-cover="cowboy-drawing"]::before {
    background-image: url("../assets/art/cowboy-drawing.thumb.webp");
}

.gallery button[data-cover="hospital-pixel-art"]::before {
    background-image: url("../assets/art/hospital-pixel-art.thumb.webp");
}

.gallery button[data-cover="zombie-game"]::before {
    background-image: url("../assets/art/zombie-game.thumb.webp");
}

.gallery button[data-cover="alcatraz-1"]::before {
    background-image: url("../assets/art/alcatraz-1.thumb.webp");
}

.gallery button[data-cover="alcatraz-2"]::before {
    background-image: url("../assets/art/alcatraz-2.thumb.webp");
}

.gallery img {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--cover-position, center);
}

/* Each artwork keeps its own focal point in the 16:9 card; zoom shows the full piece. */
.gallery button[data-cover="cowboy-digital"] { --cover-position: 50% 42%; }
.gallery button[data-cover="explorer"] { --cover-position: 50% 32%; }
.gallery button[data-cover="cowboy-drawing"] { --cover-position: 50% 45%; }
.gallery button[data-cover="hospital-pixel-art"] { --cover-position: 50% 50%; }
.gallery button[data-cover="zombie-game"] { --cover-position: 50% 38%; }
.gallery button[data-cover="alcatraz-1"] { --cover-position: 50% 50%; }
.gallery button[data-cover="alcatraz-2"] { --cover-position: 50% 50%; }

.pixel img {
    image-rendering: pixelated;
}

.gallery figcaption {
    padding: 0.75rem 1rem 1rem;
    font-size: 1rem;
}

.gallery figcaption strong {
    display: block;
    font-size: var(--step-1);
    line-height: 1.2;
}

.gallery figure {
    margin: 0;
}

.lightbox {
    max-width: min(94vw, 80rem);
    max-height: 94vh;
    max-height: 94dvh;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.lightbox::backdrop {
    background: rgb(23 48 79 / 0.75);
}

.lightbox img {
    width: auto;
    height: auto;
    max-height: calc(94vh - 4.5rem);
    max-height: calc(94dvh - 4.5rem);
    margin-inline: auto;
    object-fit: contain;
}

.lightbox-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
}

.lightbox-bar p {
    margin: 0;
}

.image-lightbox {
    position: fixed;
    display: flex;
    flex-direction: column;
    width: min(94vw, 80rem);
    height: min(calc(94vw * 9 / 16), 94vh, 46rem);
    height: min(calc(94vw * 9 / 16), 94dvh, 46rem);
    max-width: min(94vw, 80rem);
    max-height: 94vh;
    max-height: 94dvh;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.image-lightbox:not([open]) {
    display: none;
}

.image-lightbox::backdrop {
    background: rgb(23 48 79 / 0.75);
}

.image-lightbox .lightbox-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-position: center;
    background-size: cover;
    filter: blur(18px) brightness(0.7) saturate(1.1);
    transform: scale(1.06);
    pointer-events: none;
}

.image-lightbox .lightbox-stage {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.image-lightbox .lightbox-stage > img,
.image-lightbox .lightbox-stage > video {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-lightbox .lightbox-stage > img {
    cursor: zoom-out;
}

.image-lightbox .lightbox-stage > video {
    background: #0b1a2b;
}

/* Bottom-right slide count, matching the compact badge on the cards. */
.image-lightbox .lightbox-count {
    position: absolute;
    right: 0.4rem;
    bottom: 0.35rem;
    z-index: 4;
    margin: 0;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgb(23 48 79 / 0.68);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.3;
    pointer-events: none;
}

.image-lightbox .lightbox-count[hidden] {
    display: none;
}

/* Same navy disc and white chevron as the card carousel arrows. */
.image-lightbox .lightbox-arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 2.75rem;
    height: 2.75rem;
    transform: translateY(-50%);
    border: 0;
    background: rgb(23 48 79 / 0.55);
    color: #fff;
}

.image-lightbox .lightbox-arrow:hover,
.image-lightbox .lightbox-arrow:focus-visible {
    background: rgb(23 48 79 / 0.85);
}

/* A visible close affordance, since touch screens have no cursor hint. */
.image-lightbox .lightbox-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(23 48 79 / 0.55);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.image-lightbox .lightbox-close:hover,
.image-lightbox .lightbox-close:focus-visible {
    background: rgb(23 48 79 / 0.85);
}

.image-lightbox .lightbox-prev {
    left: 0.75rem;
}

.image-lightbox .lightbox-next {
    right: 0.75rem;
}

.image-lightbox .dialog-arrow[hidden] {
    display: none;
}

/* ---------- Project details dialog ---------- */

[data-project] {
    cursor: pointer;
}

.project-dialog {
    --card-accent: var(--zone-code);
    --card-ring: color-mix(in srgb, var(--card-accent) 38%, transparent);
    --card-shadow: color-mix(in srgb, var(--card-accent) 26%, transparent);
    width: min(94vw, 72rem);
    max-height: 92vh;
    max-height: 92dvh;
    padding: 0;
    border: 1px solid var(--card-ring);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 10px 22px var(--card-shadow);
    overflow: hidden;
    container-type: inline-size;
    container-name: project;
}

/* The sheet inherits the colour of the zone the project belongs to. */
.project-dialog[data-zone="game"]  { --card-accent: var(--zone-game); }
.project-dialog[data-zone="art"]   { --card-accent: var(--zone-art); }
.project-dialog[data-zone="audio"] { --card-accent: var(--zone-audio); }

/* The native bar is hidden inside the sheet; ours floats above the edge. */
.dialog-scroll {
    max-height: 92vh;
    max-height: 92dvh;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.dialog-scroll::-webkit-scrollbar {
    display: none;
}

.dialog-scrollbar {
    position: absolute;
    z-index: 9;
    top: 0.4rem;
    right: 0;
    bottom: 0.4rem;
    width: 6px;
    border-radius: 999px;
    cursor: pointer;
    touch-action: none;
}

.dialog-scrollbar[hidden] {
    display: none;
}

.dialog-scrollbar span {
    position: absolute;
    left: 1px;
    right: 1px;
    border-radius: 999px;
    background: rgb(23 48 79 / 0.22);
    transition: background 0.15s;
}

.dialog-scrollbar:hover span,
.dialog-scrollbar span:active {
    background: var(--card-accent);
}

.dialog-content {
    position: relative;
}

/* Only while the player is open: extra scroll room sits behind the bar, and
   the negative margin keeps the sheet at its natural height. */
.project-dialog:has(> .soundbar:not([hidden])) .dialog-content {
    padding-bottom: calc(var(--soundbar-space, 6rem) / 2);
    margin-bottom: calc(-1 * (var(--soundbar-space, 6rem) / 2));
}

.project-dialog::backdrop {
    background: rgb(23 48 79 / 0.75);
}

.dialog-pager {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 7rem;
    gap: 0.2rem;
    padding: 0.1rem 0.25rem;
    border: 1px solid color-mix(in srgb, var(--card-accent) 55%, var(--line));
    border-radius: 999px;
    background: color-mix(in srgb, var(--card-accent) 10%, var(--surface));
    color: var(--text);
}

.dialog-pager .dialog-chevron {
    color: var(--card-accent);
}

.dialog-step {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.dialog-step:hover,
.dialog-step:focus-visible {
    background: rgb(255 255 255 / 0.2);
}

.dialog-pager .dialog-chevron {
    width: 1rem;
    height: 1rem;
}

/* Outside the scrolling content: the X stays pinned to the sheet's corner. */
.dialog-close-form {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 90;
}

.dialog-arrow {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid rgb(23 48 79 / 0.35);
    border-radius: 50%;
    background: rgb(255 255 255 / 0.6);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.dialog-arrow:hover,
.dialog-arrow:focus-visible {
    border-color: var(--text);
    background: rgb(255 255 255 / 0.85);
}

.dialog-chevron {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dialog-counter {
    color: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dialog-close {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(23 48 79 / 0.62);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.dialog-close svg {
    display: block;
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
}

.dialog-close:hover,
.dialog-close:focus-visible {
    background: rgb(23 48 79 / 0.85);
}

/* The image leads; the title and its links sit right underneath. */
.dialog-hero {
    position: relative;
    background: var(--surface);
}



/* Reserve the tallest title block so the pager never shifts between projects. */
.dialog-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 1rem;
    min-height: 6.875rem;
    padding: 1.15rem 1.5rem 0.25rem;
}

.dialog-title {
    min-width: 0;
}

.dialog-heading .meta {
    margin: 0 0 0.3rem;
    color: var(--card-accent);
    font-size: 0.9rem;
    font-weight: 800;
}

.dialog-heading h2 {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1.15;
}

.dialog-heading .role {
    margin: 0.4rem 0 0;
    padding-left: 0.75rem;
    border-left: 3px solid var(--sky);
    font-size: 0.9rem;
    font-weight: 700;
}

/* Compact sky-tinted pills close the sheet after the project information. */
.dialog-links {
    margin: 0 1.5rem 1.5rem;
}

.dialog-links .actions {
    justify-content: flex-start;
}

.dialog-links .actions > li {
    flex: 0 0 6.25rem;
    min-width: 0;
}

.dialog-links .button {
    justify-content: center;
    width: 100%;
    min-height: 2rem;
    padding: 0.3rem 0.5rem;
    border-width: 1px;
    border-color: color-mix(in srgb, var(--card-accent) 55%, var(--line));
    background: color-mix(in srgb, var(--card-accent) 10%, var(--surface));
    font-size: 0.8rem;
}

.dialog-links .button:hover {
    border-color: var(--card-accent);
    background: color-mix(in srgb, var(--card-accent) 22%, var(--surface));
}

.dialog-links .button .icon {
    width: 0.9rem;
    height: 0.9rem;
    color: var(--card-accent);
}

/* A short overview on the left; technology and extras get their own column. */
.dialog-body {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    align-items: start;
    gap: 0.75rem 2rem;
    padding: 0.25rem 1.5rem 1.5rem;
}

.dialog-block {
    min-width: 0;
}

.dialog-block h3 {
    margin: 0 0 0.4rem;
    color: var(--link);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1.2;
    text-transform: uppercase;
}

.dialog-overview .summary {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

/* Even gaps between the right-hand blocks, whatever each one contains. */
.dialog-side {
    display: grid;
    align-content: start;
    gap: 0.9rem;
}

.dialog-side .tags,
.dialog-side .dialog-tracks,
.dialog-side .dialog-preview,
.dialog-side .track-note {
    margin: 0;
}

.dialog-side .track-name {
    max-width: none;
}

.dialog-media {
    position: relative;
    width: 100%;
    height: auto;
    max-height: min(52vh, 30rem);
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
    background: var(--surface);
}

.dialog-media img,
.dialog-media video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.dialog-preview {
    display: block;
    width: 100%;
    max-height: 15rem;
    margin-bottom: 1rem;
    border-radius: calc(var(--radius) - 2px);
}

.dialog-tracks {
    display: grid;
    gap: 0.2rem;
    overflow: hidden;
    margin-bottom: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.track-row {
    display: grid;
    grid-template-columns: 2rem 1.5rem minmax(0, 1fr);
    align-items: center;
    gap: 0.35rem 0.5rem;
    min-height: 3rem;
    padding: 0.25rem 0.75rem;
    background: var(--surface);
}

.track-row + .track-row {
    border-top: 1px solid var(--line);
}

.track-row:hover,
.track-row.is-current {
    background: color-mix(in srgb, var(--card-accent) 10%, var(--surface));
}

.track-num {
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.track-row.is-current .track-num {
    color: var(--card-accent);
    font-weight: 800;
}

.track-name {
    overflow: hidden;
    max-width: 12rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-trigger {
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--card-accent) 12%, var(--surface));
    color: var(--card-accent);
    cursor: pointer;
}

.track-row:hover .track-trigger,
.track-row.is-current .track-trigger {
    background: color-mix(in srgb, var(--card-accent) 22%, var(--surface));
}

.track-trigger .icon {
    width: 1rem;
    height: 1rem;
}

/* The active row stays intact: playback now lives in the bottom sound bar. */
.track-row.is-current .track-name {
    color: var(--card-accent);
    font-weight: 800;
}

/* Audio players live in their own full-width band under the project text. */
.dialog-player-block {
    margin: 0 1.5rem 1.25rem;
}

.dialog-player-block .dialog-tracks {
    margin-bottom: 0;
}

.dialog-player-block .track-name {
    max-width: none;
}

/* The two text columns stack before the dialog gets cramped. */
@container project (max-width: 48rem) {
    .dialog-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@container project (max-width: 44rem) {
    /* Long roles wrap here, so the pager gets its own fixed row above the title. */
    .dialog-heading {
        grid-template-columns: 1fr;
        min-height: 0;
        row-gap: 0.5rem;
        padding: 1rem 1.25rem 0.5rem;
    }

    .dialog-pager {
        grid-column: 1;
        grid-row: 1;
        justify-self: end;
    }

    .dialog-title {
        grid-row: 2;
    }

    .dialog-body {
        padding: 0.5rem 1.25rem 1.25rem;
    }

    .dialog-links,
    .dialog-player-block {
        margin-inline: 1.25rem;
    }

    .dialog-links .actions {
        justify-content: flex-start;
    }

    .dialog-media {
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

/* Narrow dialogs: let long track titles use the whole row. */
@container project (max-width: 34rem) {
    .track-name {
        max-width: none;
    }
}

.track-note {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Audio page: square covers with a preview button ---------- */

.audio-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.25rem 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.audio-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.18s, box-shadow 0.18s;
}

.audio-card:hover,
.audio-card:has(:focus-visible:not(.focus-quiet)) {
    box-shadow: 0 0 0 1px var(--card-ring), 0 10px 22px var(--card-shadow);
}

.audio-art {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--line);
    cursor: pointer;
}

/* Wide covers keep their real ratio inside the square; a blurred copy fills the letterbox. */
.audio-backdrop {
    position: absolute;
    inset: -12%;
    background-image: var(--cover);
    background-position: center;
    background-size: cover;
    filter: blur(12px) brightness(0.75);
}

.audio-cover img,
.audio-cover video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.audio-cover img {
    position: relative;
    z-index: 1;
}

.audio-cover video {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
}

.audio-cover.playing video {
    opacity: 1;
}

.audio-open {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 0.75rem 1rem 1rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.audio-title {
    display: block;
    font-weight: 800;
    line-height: 1.2;
}

.audio-meta {
    display: block;
    color: var(--muted);
    font-size: var(--step--1);
}

/* ---------- Sound bar ---------- */

.soundbar {
    position: fixed;
    inset: auto 0 1rem;
    z-index: 80;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto minmax(8rem, 34rem) auto auto;
    grid-template-areas: "cover info controls progress time close";
    align-items: center;
    gap: 0.9rem;
    width: min(calc(100% - 2 * var(--gutter)), var(--wrap));
    margin-inline: auto;
    padding: 0.7rem 1rem;
    border: 1px solid var(--card-accent, var(--zone-accent));
    border-radius: 1rem;
    background: var(--surface);
    box-shadow: 0 14px 38px rgb(23 48 79 / 0.3);
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.soundbar.is-open {
    opacity: 1;
    transform: translateY(0);
}

.soundbar[hidden] {
    display: none;
}

.soundbar-cover-link { grid-area: cover; }
.soundbar-info { grid-area: info; }
.soundbar-controls { grid-area: controls; }
.soundbar-seek { grid-area: progress; }
.soundbar-time { grid-area: time; justify-self: end; }
.soundbar-close { grid-area: close; }

/* The page scrolls under the floating player, so it reserves the measured
   height. The sheet always keeps the same clearance, with or without music. */
body:has(> .soundbar:not([hidden])) {
    padding-bottom: var(--soundbar-space, 5rem);
}

.soundbar-cover-link {
    display: block;
    line-height: 0;
    border-radius: 0.5rem;
}

.soundbar-cover-link[aria-disabled="true"] {
    cursor: default;
}

.soundbar-cover {
    width: 3rem;
    height: 3rem;
    border-radius: 0.5rem;
    object-fit: cover;
}

.soundbar-cover-link[hidden],
.soundbar-cover[hidden] {
    display: none;
}

.soundbar-info {
    min-width: 0;
    line-height: 1.25;
}

.soundbar-title,
.soundbar-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.soundbar-title {
    color: inherit;
    font-size: 1rem;
    font-weight: 800;
    text-decoration: none;
}

.soundbar-title[href]:hover {
    text-decoration: underline;
}

.soundbar-title[aria-disabled="true"] {
    cursor: default;
}

.soundbar-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.soundbar-eq {
    display: none;
    align-items: flex-end;
    flex: none;
    gap: 2px;
    width: 0.7rem;
    height: 0.7rem;
}

.soundbar.is-playing .soundbar-eq {
    display: inline-flex;
}

.soundbar-eq i {
    width: 2px;
    height: 100%;
    border-radius: 1px;
    background: var(--card-accent, var(--zone-accent));
    transform-origin: bottom;
    animation: soundbarEq 0.9s ease-in-out infinite alternate;
}

.soundbar-eq i:nth-child(2) { animation-duration: 0.7s; animation-delay: -0.25s; }
.soundbar-eq i:nth-child(3) { animation-duration: 1.1s; animation-delay: -0.5s; }

@keyframes soundbarEq {
    from { transform: scaleY(0.35); }
    to { transform: scaleY(1); }
}

.soundbar-count {
    color: var(--card-accent, var(--zone-accent));
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.soundbar-count[hidden] {
    display: none;
}

.soundbar-resume {
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--card-accent, var(--zone-accent));
    border-radius: 999px;
    background: none;
    color: var(--card-accent, var(--zone-accent));
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
}

.soundbar-resume[hidden] {
    display: none;
}

.soundbar-controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.soundbar-skip,
.soundbar-toggle {
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.soundbar-skip {
    width: 2rem;
    height: 2rem;
    background: transparent;
    color: var(--muted);
}

.soundbar-skip:hover {
    background: color-mix(in srgb, var(--card-accent, var(--zone-accent)) 12%, var(--surface));
    color: var(--card-accent, var(--zone-accent));
}

.soundbar:not(.has-queue) .soundbar-skip {
    display: none;
}

.soundbar-skip .icon {
    width: 1.05rem;
    height: 1.05rem;
}

.soundbar-toggle {
    width: 2.6rem;
    height: 2.6rem;
    background: var(--card-accent, var(--zone-accent));
    color: #fff;
}

.soundbar-toggle .icon {
    width: 1.15rem;
    height: 1.15rem;
}

.soundbar-toggle .soundbar-pause,
.soundbar.is-playing .soundbar-toggle .soundbar-play {
    display: none;
}

.soundbar.is-playing .soundbar-toggle .soundbar-pause {
    display: block;
}

.soundbar-seek {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.soundbar-scrub {
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 0;
    z-index: 2;
    padding: 0.15rem 0.45rem;
    border-radius: 0.4rem;
    background: var(--text);
    color: var(--surface);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: none;
}

.soundbar-scrub[hidden] {
    display: none;
}

.soundbar-progress {
    --track-accent: var(--card-accent, var(--zone-accent));
    width: 100%;
    min-width: 0;
    height: 1rem;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    accent-color: var(--track-accent);
    cursor: pointer;
}

.soundbar-progress::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--track-accent) 28%, var(--line));
}

.soundbar-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--track-accent);
    box-shadow: 0 0 0 1px var(--track-accent);
}

.soundbar-progress::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--track-accent) 28%, var(--line));
}

.soundbar-progress::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--track-accent);
    box-shadow: 0 0 0 1px var(--track-accent);
}

.soundbar-volume-control {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.soundbar-mute {
    display: grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.soundbar-mute:hover {
    background: color-mix(in srgb, var(--card-accent, var(--zone-accent)) 12%, var(--surface));
    color: var(--card-accent, var(--zone-accent));
}

.soundbar-mute .icon {
    width: 1rem;
    height: 1rem;
}

.soundbar-mute.is-muted .soundbar-wave {
    display: none;
}

.soundbar-volume-range {
    --track-accent: var(--card-accent, var(--zone-accent));
    width: 4.5rem;
    min-width: 0;
    height: 1rem;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    accent-color: var(--track-accent);
    cursor: pointer;
}

.soundbar-volume-range::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--track-accent) 28%, var(--line));
}

.soundbar-volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    margin-top: -4px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--track-accent);
    box-shadow: 0 0 0 1px var(--track-accent);
}

.soundbar-volume-range::-moz-range-track {
    height: 3px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--track-accent) 28%, var(--line));
}

.soundbar-volume-range::-moz-range-thumb {
    width: 8px;
    height: 8px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--track-accent);
    box-shadow: 0 0 0 1px var(--track-accent);
}

.soundbar-time {
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.soundbar-close {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.soundbar-close:hover {
    color: var(--text);
}

@media (max-width: 52rem) {
    .soundbar {
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        grid-template-areas:
            "cover info controls close"
            "progress progress progress time";
        gap: 0.45rem 0.8rem;
        padding: 0.6rem 0.8rem;
    }

    .soundbar-progress {
        height: 0.7rem;
    }

    .soundbar-volume-range {
        width: 3.5rem;
    }

    .soundbar-time {
        padding-left: 0.4rem;
    }

    .soundbar.needs-resume [data-sound-meta] {
        display: none;
    }
}

@media (max-width: 30rem) {
    .soundbar-skip {
        display: none;
    }

    .soundbar-cover {
        width: 2.5rem;
        height: 2.5rem;
    }

    .soundbar-toggle {
        width: 2.3rem;
        height: 2.3rem;
    }

    .soundbar-volume-range {
        width: 2.8rem;
    }
}

@media (max-width: 24rem) {
    /* At the narrowest widths the artwork would starve the title and close button. */
    .soundbar {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "info controls close"
            "progress progress time";
    }

    .soundbar-cover-link {
        display: none;
    }

    .soundbar-volume-range {
        width: 2.3rem;
    }

    .soundbar-title {
        font-size: 0.9rem;
    }

    .soundbar-meta {
        font-size: 0.72rem;
    }
}

@media (max-width: 30rem) {
    .audio-grid {
        gap: 0.6rem;
    }

    .audio-grid > * {
        flex-basis: calc((100% - 0.6rem) / 2);
    }
}

/* ---------- About and contact ---------- */

/* Contact uses the full page width; About keeps text and photo side by side. */
.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.split.about {
    grid-template-columns: minmax(0, 1fr) minmax(0, 23rem);
    gap: 1.5rem;
    align-items: center;
}

.split img {
    justify-self: end;
    width: 100%;
    max-width: 23rem;
    border-radius: var(--radius);
}

/* The photo keeps its original size and sits centred against the copy, not in a corner. */

.form {
    display: grid;
    gap: 1rem;
}

.form label {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
}

.form input,
.form textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

.form textarea {
    min-height: 10rem;
    resize: vertical;
}

.form input:focus,
.form textarea:focus {
    border-color: var(--sky);
    outline: none;
}

.form .button {
    justify-self: start;
}

.form-note {
    color: var(--muted);
    font-size: var(--step--1);
}

.form-note.is-error {
    color: var(--text);
    font-weight: 700;
}

/* One contact card spans the whole form: QR, social links and email together. */
.contact-form {
    grid-template-columns: minmax(0, 1fr) 18rem;
    grid-template-areas:
        "name    card"
        "message card"
        "button  card"
        "note    card";
    align-items: start;
}

.contact-form .field-name { grid-area: name; }
.contact-form .field-message { grid-area: message; }
.contact-form .button { grid-area: button; }
.contact-form .form-note { grid-area: note; }

.contact-card {
    grid-area: card;
    align-self: center;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.6rem;
    width: 18rem;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.contact-card .contact-email {
    margin: 0;
    color: var(--muted);
    font-size: var(--step--1);
    line-height: 1.35;
    text-align: center;
}

.contact-email a {
    background-image: linear-gradient(currentColor, currentColor);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 0 1px;
    transition: background-size 0.1s ease-out;
}

.contact-email a:hover,
.contact-email a:focus-visible {
    background-size: 100% 1px;
}

@media (max-width: 36rem) {
    .contact-form {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "name"
            "message"
            "button"
            "note"
            "card";
    }

    .contact-card {
        width: min(100%, 18rem);
        align-self: center;
        justify-self: center;
    }

    /* Phones get one generous card per row instead of a grid of thumbnails. */
    [data-featured],
    .group > .cards,
    .group > .games {
        gap: 1rem;
    }

    [data-featured] > *,
    .group > .cards > *,
    .group > .games > * {
        flex-basis: 100%;
    }
}

.split a[href^="mailto:"],
.site-footer a[href^="mailto:"] {
    overflow-wrap: anywhere;
}

/* ---------- Share page ---------- */

.share-card {
    display: grid;
    justify-items: center;
    gap: 0.85rem;
    width: min(100%, 26rem);
    margin-inline: auto;
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}

.share-portrait {
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 50%;
    object-fit: cover;
}

.share-card h2 {
    margin: 0;
    font-size: var(--step-1);
}

.share-role,
.share-hint {
    margin: 0;
    color: var(--muted);
    font-size: var(--step--1);
}

.share-role {
    margin-top: -0.4rem;
}

.share-actions {
    display: grid;
    width: 100%;
    gap: 1.1rem;
}

.share-copy {
    position: relative;
    display: grid;
    justify-items: center;
}

.copy-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--link);
    font: inherit;
    font-size: var(--step--1);
    font-weight: 600;
    cursor: pointer;
}

.copy-link:hover {
    border-color: var(--sky);
    background: var(--sky-soft);
}

.copy-link .icon {
    flex: none;
    width: 0.95rem;
    height: 0.95rem;
}

/* The same button becomes "Share" when the device offers a native share sheet. */
.copy-link .native-icon,
.copy-link .native-text { display: none; }

.has-native-share .copy-link .copy-icon,
.has-native-share .copy-link .copy-text { display: none; }

.has-native-share .copy-link .native-icon { display: block; }
.has-native-share .copy-link .native-text { display: inline; }

.copy-status {
    position: absolute;
    inset: calc(100% + 0.2rem) 0 auto;
    color: var(--muted);
    font-size: var(--step--1);
    text-align: center;
    pointer-events: none;
}

main:has(.share-card) {
    padding-bottom: 1rem;
}

.share-qr {
    display: block;
    width: 13rem;
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fff;
}

.share-qr img {
    width: 100%;
}

.share-links {
    display: grid;
    width: min(100%, 19rem);
    margin-inline: auto;
    gap: 0.5rem;
}

.share-link {
    display: grid;
    grid-template-columns: 1.15rem 1fr 1.15rem;
    align-items: center;
    gap: 0.5rem;
    padding-block: 0.8rem;
    padding-inline: 0.71rem 1rem;
    border: 1px solid var(--line);
    border-left: 0.35rem solid var(--accent, var(--sky));
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.share-link:hover {
    border-color: var(--sky);
    border-left-color: var(--accent, var(--sky));
    background: var(--sky-soft);
}

.share-link .icon {
    width: 1.05rem;
    height: 1.05rem;
}

.share-link .icon:first-child { justify-self: start; color: var(--accent, var(--sky)); }
.share-link .icon:last-child { justify-self: end; opacity: 0.65; }
.share-link span { justify-self: center; }

.share-link.game { --accent: var(--zone-game); }
.share-link.code { --accent: var(--zone-code); }
.share-link.art { --accent: var(--zone-art); }
.share-link.audio { --accent: var(--zone-audio); }
.share-link.contact { --accent: var(--sky-deep); }

.share-card .social {
    justify-content: center;
    margin-top: -0.35rem;
    margin-bottom: -0.2rem;
}

@media (max-width: 30rem) {
    .share-card {
        padding: 1.15rem;
    }

    .share-qr {
        width: min(100%, 11rem);
    }
}

/* ---------- Small screens ---------- */

@media (max-width: 52rem) {
    .split.about,
    [data-featured] {
        grid-template-columns: 1fr;
    }

    [data-featured] > .card:first-child {
        grid-row: auto;
    }

    .split.about img {
        max-width: 20rem;
        justify-self: center;
    }

    .bar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        padding-block: 0.6rem;
    }

    .bar-actions {
        justify-self: auto;
        margin-left: auto;
    }

    .site-nav ul {
        justify-content: center;
        gap: 0.2rem 1.2rem;
    }

    .site-nav {
        flex: 1 1 auto;
        min-width: 0;
        justify-self: auto;
        margin-left: 0;
    }

}

/* Once the hero stacks, centre the portrait and the greeting as one block. */
@media (max-width: 44rem) {
    .intro {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 1.35rem;
        text-align: center;
    }

    .intro > div {
        width: 100%;
        max-width: 34rem;
    }

    .intro .lead {
        margin-inline: auto;
    }

    .intro .actions,
    .intro .social {
        justify-content: center;
    }

    .portrait {
        max-width: 9rem;
    }
}

@media (max-width: 36.5rem) {
    /* One-line bar: brand + Contact + menu button; links open below on demand. */
    .bar {
        flex-wrap: nowrap;
        gap: 0.4rem;
        padding-block: 0.5rem;
    }

    .brand {
        font-size: 1rem;
        white-space: nowrap;
    }

    .bar-actions {
        order: 1;
        margin-left: auto;
        gap: 0.55rem;
    }

    .bar-actions .button.small {
        font-size: 0.9rem;
        padding: 0.3em 0.55em;
        white-space: nowrap;
    }

    .header-share {
        width: 1.9rem;
        height: 1.9rem;
    }

    .header-share .icon {
        width: 1rem;
        height: 1rem;
    }

    .nav-toggle {
        order: -1;
        display: flex;
        margin-right: 0.35rem;
    }

    .site-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 60;
        display: none;
        width: auto;
        min-width: 0;
        margin: 0;
        padding: 0.5rem var(--gutter) 0.75rem;
        border-top: 1px solid rgb(255 255 255 / 0.16);
        background: var(--header);
        box-shadow: 0 4px 18px rgb(23 48 79 / 0.22);
    }

    .site-header.nav-open .site-nav {
        display: block;
    }

    .site-nav ul {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.35rem 1rem;
    }

    .site-nav a {
        display: block;
        padding: 0.25rem 0;
        font-size: 1rem;
    }

    /* Compact menus: both pills stay side by side at the narrowest width. */
    .filter-bar,
    .filter-controls {
        gap: 0.2rem;
    }

    .filter-bar .filter-external {
        padding: 0.2em;
    }

    .filter-menu > summary {
        gap: 0.2rem;
        padding: 0.32em 0.5em;
        font-size: 0.78rem;
    }

    .filter-menu > summary::after {
        font-size: 0.65rem;
    }

    /* The filter name stays visible at every width; only spacing tightens. */
    .filter-menu .menu-label {
        display: inline;
    }

    .filter-menu .filters button {
        padding: 0.3em 0.6em;
        font-size: 0.78rem;
    }

    .filter-menu .count {
        display: none;
    }
}

@media (max-width: 19rem) {
    /* Below this the share pill would push the one-line header past the viewport. */
    .header-share {
        display: none;
    }
}

@media (max-width: 30rem) {
    .gallery {
        gap: 0.6rem;
    }

    .gallery > * {
        flex-basis: calc((100% - 0.6rem) / 2);
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.lightbox .pixel-img {
    image-rendering: pixelated;
}

/* "All" is a single flat shelf: every card together, with no category heads.
   "None" restores the grouped view with the heads visible. */
.flat {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem 1.25rem;
}

.flat > .group:not([hidden]) {
    display: contents;
}

.flat > .group > .group-head,
.flat > .group > .cards,
.flat > .group > .games,
.flat > .group > .gallery,
.flat > .group > .audio-grid {
    display: none;
}

.flat > .group:not([hidden]) > .cards,
.flat > .group:not([hidden]) > .games,
.flat > .group:not([hidden]) > .gallery,
.flat > .group:not([hidden]) > .audio-grid {
    display: contents;
}

/* Groups: spacing alone separates zones; no full-width divider line. */
.group + .group {
    margin-top: 2.5rem;
}

/* Three tracks keep the badge at the title's left without shifting the title off-centre. */
.group-head {
    --ink: var(--zone-accent);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0 0.6rem;
    margin: 0 0 1rem;
    text-align: center;
}

.group-head::after {
    content: "";
    grid-column: 3;
}

.group-badge {
    grid-column: 1;
    justify-self: end;
    /* Align to the text line, not to the h2 box that also contains the underline. */
    align-self: start;
    margin-top: 0.1rem;
}

.group-head h2 {
    grid-column: 2;
    min-width: 0;
}

/* Subcategories are shades of the page hue, never another colour. */
.group-head.tone-mid { --ink: var(--zone-accent-mid); }
.group-head.tone-deep { --ink: var(--zone-accent-deep); }

.group-badge {
    display: inline-flex;
    align-items: center;
    color: var(--ink);
}

.group-badge .icon {
    width: 1.1rem;
    height: 1.1rem;
}

.group .group-intro {
    display: none;
    flex: 1 1 24rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

/* Flat mode hides the section heads; one All head labels the whole shelf.
   The negative margin cancels the flex row-gap so every mode leaves 1rem
   between a head and its cards, just like the category sections. */
.all-head {
    display: none;
}

.flat > .all-head:not([hidden]) {
    display: grid;
    flex: 0 0 100%;
    width: 100%;
    margin: 0 0 -0.5rem;
}

.group .cards,
.group .games {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

@media (max-width: 30rem) {
    .filter-menu[open] .filters {
        width: min(90vw, 18rem);
        min-width: 0;
    }

    .filter-bar {
        padding: 0.4rem 0.35rem;
    }

    .filter-bar .filter-controls {
        gap: 0.35rem;
    }

    /* Keep the icon beside the title while both side tracks stay equal. */
    .group-head {
        grid-template-columns: minmax(1.4rem, 1fr) auto minmax(1.4rem, 1fr);
        gap: 0 0.35rem;
    }

    .group-badge .icon {
        width: 1rem;
        height: 1rem;
    }

    /* One full-width card per row: small previews are hard to read on a phone. */
    [data-featured],
    .group > .cards,
    .group > .games {
        gap: 0.9rem;
    }

    [data-featured] > *,
    .group > .cards > *,
    .group > .games > * {
        flex-basis: 100%;
    }

    .group .card h3 {
        font-size: 0.92rem;
        line-height: 1.2;
    }

    .group .card .context {
        margin-bottom: 0.5rem;
        font-size: 0.72rem;
    }

    .card-links {
        gap: 0.25rem;
    }

    .icon-link {
        width: 1.3rem;
        height: 1.3rem;
    }

    .card-details {
        height: 1.3rem;
        padding-inline: 0.45rem;
    }

    .icon-link .icon {
        width: 0.7rem;
        height: 0.7rem;
    }

    .group .card .actions {
        gap: 0.3rem;
    }

    .group .card .actions .button {
        width: 100%;
        justify-content: center;
        padding: 0.3em 0.45em;
        font-size: 0.72rem;
    }

    .group .card .context,
    .group .games .game .context {
        font-size: 0.75rem;
    }
}

/* Focus returned by a closed viewer is transient: no halo on its card. */
.focus-quiet:focus-visible,
img.focus-quiet:focus-visible,
button.focus-quiet:focus-visible {
    outline: none;
}

