/* Home page: "the forge floor".
   A full-width dark stage (a tilted wall of real URage work, an oversized headline and our games fanned out beside
   it), then wide, quiet sections. The stage stays dark in every theme; the theme comes through its accent colour,
   its heading font and everything below the stage. Rules start with :root[data-theme] #view-home so they win over
   the older per-theme home rules in styles/themes/*.scss. Plain CSS, loaded after style.css. */

#view-home {
    --home-width: 1560px;
    --home-gutter: clamp(1rem, 4vw, 4rem);
    --home-section-space: clamp(2.75rem, 5vw, 4.75rem);
    --home-panel-radius: 12px;
    /* The stage: a near-black tinted by the theme's own page colour, light text on it. */
    --stage-ink: color-mix(in srgb, var(--bg) 22%, #050304);
    --stage-text: #f7f0ea;
    --stage-dim: #ddd2ca;
    --stage-line: rgba(255, 255, 255, 0.14);
    /* The headline's longest line fills its column: font size = this many % of the column width. Each theme's
       heading font is a different width (measured "Hating Unity?" at 100px: Archivo 811px), see the end. */
    --stage-title-fit: 12.3;
}

/* ---------- the stage ---------- */

:root[data-theme] #view-home .home-hero.home-stage {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    min-height: min(calc(100svh - var(--nav-height) - var(--ticker-height)), 1000px);
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: var(--stage-ink);
    color: var(--stage-text);
    text-align: left;
}

/* Older themes decorate the hero with ::after art; the stage has its own. */
:root[data-theme] #view-home .home-hero.home-stage::after {
    content: none;
}

:root[data-theme] #view-home .home-hero.home-stage > #pixel-bg {
    display: none;
}

/* The wall: one pre-composited picture (images/home/forge-wall-*.webp, made from tool screens and game shots). */
#view-home .home-stage-wall {
    position: absolute;
    z-index: -2;
    inset: -4% -5%;
    background: url("/images/home/forge-wall-1920.webp") center / cover no-repeat;
    opacity: 0.62;
    animation: home-wall-drift 48s ease-in-out infinite alternate;
    will-change: transform;
}

/* Shade over the wall: dark where the words are, open on the right where the games sit, and an ember glow in the
   theme's accent rising from the floor. */
:root[data-theme] #view-home .home-hero.home-stage::before {
    position: absolute;
    z-index: -1;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        radial-gradient(ellipse 55% 50% at 22% 108%, color-mix(in srgb, var(--accent) 42%, transparent), transparent 72%),
        linear-gradient(0deg, var(--stage-ink) 0%, transparent 26%),
        linear-gradient(90deg,
            var(--stage-ink) 0%,
            color-mix(in srgb, var(--stage-ink) 90%, transparent) 32%,
            color-mix(in srgb, var(--stage-ink) 45%, transparent) 64%,
            color-mix(in srgb, var(--stage-ink) 62%, transparent) 100%);
}

#view-home .home-stage-inner {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    gap: clamp(2rem, 5vw, 6rem);
    align-items: center;
    width: min(var(--home-width), 100% - var(--home-gutter) * 2);
    margin: 0 auto;
    padding: clamp(2.5rem, 7vh, 5.5rem) 0 clamp(2rem, 5vh, 3.5rem);
}

:root[data-theme] #view-home .home-stage .home-stage-title {
    margin: 0 0 clamp(1.1rem, 2.4vh, 1.75rem);
    padding: 0;
    font-family: var(--heading-font-family, var(--font-family));
    font-size: min(calc(var(--stage-title-fit) * 0.97cqi), 9rem);
    font-weight: 800;
    line-height: 0.92;
    letter-spacing: -0.02em;
    text-align: left;
    text-shadow: none;
    color: var(--stage-text);
    filter: drop-shadow(0 0.06em 0 rgba(0, 0, 0, 0.45));
}

#view-home .home-stage-copy {
    container-type: inline-size;
}

/* Molten metal: every line is white-hot at the top and cools into the theme's accent at its foot. */
#view-home .home-stage-line {
    display: block;
    width: fit-content;
    white-space: nowrap;
    background: linear-gradient(180deg, var(--stage-text) 0%, var(--stage-text) 48%, color-mix(in srgb, var(--accent) 80%, #fff 20%) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#view-home .home-stage-lede {
    max-width: 36rem;
    margin: 0 0 1.75rem;
    color: var(--stage-dim);
    font-size: clamp(1.05rem, 1.3vw, 1.28rem);
    line-height: 1.55;
}

#view-home .home-stage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1rem;
    align-items: center;
}

:root[data-theme] #view-home .home-stage-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 54px;
    padding: 0.85rem 1.55rem;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

:root[data-theme] #view-home .home-stage-actions .home-stage-secondary {
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.05);
    color: var(--stage-text);
}

:root[data-theme] #view-home .home-stage-actions .home-stage-secondary:hover {
    border-color: var(--stage-text);
    background: rgba(255, 255, 255, 0.12);
}

#view-home .home-stage-counts {
    margin: 1.4rem 0 0;
    color: var(--stage-dim);
    font-size: 0.95rem;
}

/* Our games, fanned out like cards just pulled from the forge: the featured one in front. */
#view-home .home-stage-games {
    position: relative;
    height: clamp(320px, 33vw, 560px);
}

:root[data-theme] #view-home .home-stage-game {
    position: absolute;
    display: block;
    width: 70%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: 14px;
    background: #111;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 34px 60px -24px rgba(0, 0, 0, 0.85), 0 0 0 1px var(--stage-line);
    transition: transform 0.35s ease, filter 0.35s ease, box-shadow 0.35s ease;
}

/* The two cards overlap only at a corner, so both names stay readable. */
#view-home .home-stage-game[data-stage-slot="1"] {
    z-index: 2;
    right: 0;
    bottom: 0;
    transform: rotate(2.5deg);
}

#view-home .home-stage-game[data-stage-slot="2"] {
    z-index: 1;
    left: 2%;
    top: 2%;
    transform: rotate(-4deg);
    filter: brightness(0.85);
}

#view-home .home-stage-game:hover,
#view-home .home-stage-game:focus-visible {
    z-index: 3;
    transform: translateY(-8px) rotate(0deg);
    filter: none;
    box-shadow: 0 40px 70px -22px rgba(0, 0, 0, 0.9), 0 0 0 2px var(--accent);
}

#view-home .home-stage-game > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#view-home .home-stage-game-copy {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 2.5rem 1.2rem 1.1rem;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.82) 55%);
}

#view-home .home-stage-game-icon {
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#view-home .home-stage-game-copy b {
    display: block;
    font-family: var(--heading-font-family, var(--font-family));
    font-size: clamp(1.15rem, 1.6vw, 1.55rem);
    line-height: 1.1;
}

#view-home .home-stage-game-copy small {
    display: block;
    margin-top: 0.2rem;
    color: #eee4dc;
    font-size: 0.9rem;
    line-height: 1.35;
}

/* The way into every part of the site, docked along the foot of the stage. */
:root[data-theme] #view-home .home-dock {
    display: block;
    width: min(var(--home-width), 100% - var(--home-gutter) * 2);
    margin: 0 auto clamp(1.25rem, 3vh, 2.25rem);
    padding: 0;
    border: 1px solid var(--stage-line);
    border-radius: var(--home-panel-radius);
    background: rgba(8, 6, 6, 0.72);
    box-shadow: none;
}

#view-home .home-dock-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

:root[data-theme] #view-home .home-dock ul {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    margin: 0;
    padding: 0.35rem;
    list-style: none;
}

:root[data-theme] #view-home .home-dock a {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
    min-height: 76px;
    padding: 0.6rem 0.5rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--stage-text);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

:root[data-theme] #view-home .home-dock a > i {
    color: var(--accent);
    font-size: 1.35rem;
}

:root[data-theme] #view-home .home-dock a:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ---------- the sections below ---------- */

:root[data-theme] #view-home #homeContentStart.content-wrapper {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 0 var(--home-section-space);
    border: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

:root[data-theme] #view-home #homeContentStart > .container {
    width: min(var(--home-width), 100% - var(--home-gutter) * 2);
    max-width: none;
    margin: 0 auto;
    padding: 0;
}

#view-home .home-games,
#view-home .home-launch,
#view-home .home-featured-assets,
#view-home .home-split,
#view-home .home-bluesky-feed {
    margin-top: var(--home-section-space);
}

:root[data-theme] #view-home .home-section-title-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.45rem 1.25rem;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.15rem;
}

:root[data-theme] #view-home .home-section-title-row h2,
:root[data-theme] #view-home .home-rage h2 {
    margin: 0;
    font-size: clamp(1.55rem, 2.3vw, 2.3rem);
    line-height: 1.1;
}

#view-home .home-section-title-row > a {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    padding-block: 0.4rem;
    color: var(--accent);
    font-weight: 700;
}

/* Our games: one wide panel each. */
#view-home .home-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
    gap: clamp(1rem, 2vw, 1.75rem);
}

#view-home .home-game-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--home-panel-radius);
    background: var(--card-bg);
    color: var(--text-main);
}

#view-home .home-game-panel-art {
    display: block;
    overflow: hidden;
}

#view-home .home-game-panel-art img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    transition: transform 0.4s ease;
}

#view-home .home-game-panel:hover .home-game-panel-art img {
    transform: scale(1.04);
}

#view-home .home-game-panel-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.1rem, 2vw, 1.85rem);
}

:root[data-theme] #view-home .home-game-panel h3 {
    margin: 0 0 0.35rem;
    font-size: clamp(1.45rem, 2.2vw, 2.15rem);
    line-height: 1.08;
}

#view-home .home-game-panel h3 a {
    color: inherit;
    text-decoration: none;
}

#view-home .home-game-panel-meta {
    margin: 0 0 0.7rem;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
}

#view-home .home-game-panel-copy > p:not(.home-game-panel-meta) {
    margin: 0 0 1.1rem;
    color: var(--text-dim);
    line-height: 1.55;
}

#view-home .home-game-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 0.75rem;
    align-items: center;
}

:root[data-theme] #view-home .home-game-panel-actions a {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    min-height: 44px;
    padding: 0.6rem 1.05rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
}

:root[data-theme] #view-home .home-game-panel-actions .home-game-panel-more {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-main);
}

:root[data-theme] #view-home .home-game-panel-actions .home-game-panel-more:hover {
    border-color: var(--accent);
}

/* Start creating: three wide cards. */
#view-home .home-launch-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.8rem, 1.8vw, 1.5rem);
}

:root[data-theme] #view-home .home-launch-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--home-panel-radius);
    background: var(--card-bg);
    color: var(--text-main);
    text-decoration: none;
}

#view-home .home-launch-card > img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

#view-home .home-launch-copy {
    position: relative;
    flex: 1;
    padding: 1.1rem 2.75rem 1.2rem 1.25rem;
}

#view-home .home-launch-copy > span {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
}

:root[data-theme] #view-home .home-launch-copy > h3 {
    margin: 0.25rem 0 0.4rem;
    font-size: clamp(1.15rem, 1.6vw, 1.5rem);
    line-height: 1.15;
}

#view-home .home-launch-copy > p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.45;
}

#view-home .home-launch-copy > i {
    position: absolute;
    top: 50%;
    right: 1.1rem;
    color: var(--accent);
    transform: translateY(-50%);
}

#view-home .home-launch-card:hover {
    border-color: var(--accent);
}

/* Featured assets: the page shows five (script.js), so five across fills the row. */
:root[data-theme] #view-home .home-featured-assets-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(0.75rem, 1.5vw, 1.25rem);
}

@media (max-width: 1180px) {
    :root[data-theme] #view-home .home-featured-assets-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

:root[data-theme] #view-home .home-split {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: clamp(1rem, 2vw, 1.75rem);
}

#view-home .home-section-loading {
    grid-column: 1 / -1;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--home-panel-radius);
    background: var(--card-bg);
    text-align: left;
}

#view-home .home-featured-asset-copy b {
    font-size: 0.92rem;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
}

#view-home .home-featured-asset-copy small {
    font-size: 0.8rem;
}

#view-home .home-stage-game:focus-visible,
#view-home .home-dock a:focus-visible,
#view-home .home-launch-card:focus-visible,
#view-home .home-game-panel a:focus-visible,
#view-home .home-stage-actions a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* ---------- one orchestrated entrance ---------- */

#view-home .home-stage-line,
#view-home .home-stage-lede,
#view-home .home-stage-actions,
#view-home .home-stage-counts,
#view-home .home-stage-game,
#view-home .home-dock {
    animation: home-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

#view-home .home-stage-line:nth-child(2) { animation-delay: 0.08s; }
#view-home .home-stage-lede { animation-delay: 0.18s; }
#view-home .home-stage-actions { animation-delay: 0.26s; }
#view-home .home-stage-counts { animation-delay: 0.32s; }
#view-home .home-stage-game[data-stage-slot="2"] { animation-delay: 0.22s; }
#view-home .home-stage-game[data-stage-slot="1"] { animation-delay: 0.34s; }
#view-home .home-dock { animation-delay: 0.42s; }

/* The cards rise from below while keeping their tilt. */
#view-home .home-stage-game[data-stage-slot="1"] { --stage-tilt: 2.5deg; }
#view-home .home-stage-game[data-stage-slot="2"] { --stage-tilt: -5deg; }

@keyframes home-rise {
    from { opacity: 0; translate: 0 22px; }
    to { opacity: 1; translate: 0 0; }
}

@keyframes home-wall-drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(-3%, -2%, 0) scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
    #view-home .home-stage-wall,
    #view-home .home-stage-line,
    #view-home .home-stage-lede,
    #view-home .home-stage-actions,
    #view-home .home-stage-counts,
    #view-home .home-stage-game,
    #view-home .home-dock {
        animation: none;
    }

    #view-home .home-stage-game,
    #view-home .home-game-panel-art img {
        transition: none;
    }
}

/* ---------- smaller screens ---------- */

@media (max-width: 1180px) {
    #view-home .home-game-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    :root[data-theme] #view-home .home-dock ul {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    :root[data-theme] #view-home .home-dock a {
        flex-direction: row;
        min-height: 52px;
    }
}

@media (max-width: 900px) {
    :root[data-theme] #view-home .home-hero.home-stage {
        min-height: 0;
    }

    #view-home .home-stage-inner {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
    }

    :root[data-theme] #view-home .home-hero.home-stage::before {
        background:
            radial-gradient(ellipse 80% 40% at 30% 100%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 72%),
            linear-gradient(180deg, color-mix(in srgb, var(--stage-ink) 82%, transparent) 0%, color-mix(in srgb, var(--stage-ink) 88%, transparent) 55%, var(--stage-ink) 100%);
    }

    /* The games sit side by side under the words instead of fanned out. */
    #view-home .home-stage-games {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.85rem;
        height: auto;
    }

    :root[data-theme] #view-home .home-stage-game {
        position: relative;
        inset: auto;
        width: auto;
        aspect-ratio: 4 / 3;
        transform: none;
        filter: none;
    }

    #view-home .home-stage-game-copy {
        padding: 2rem 0.75rem 0.75rem;
    }

    #view-home .home-stage-game-copy small {
        display: none;
    }

    #view-home .home-stage-game-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    #view-home .home-launch-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    :root[data-theme] #view-home .home-launch-card {
        display: grid;
        grid-template-columns: 34% minmax(0, 1fr);
    }

    #view-home .home-launch-card > img {
        height: 100%;
        aspect-ratio: auto;
    }

    :root[data-theme] #view-home .home-split {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    #view-home .home-stage-wall {
        background-image: url("/images/home/forge-wall-1200.webp");
    }

    :root[data-theme] #view-home .home-dock ul {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :root[data-theme] #view-home .home-featured-assets-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :root[data-theme] #view-home .home-dock a {
        justify-content: flex-start;
        padding-inline: 0.85rem;
    }

    #view-home .home-stage-actions a {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* Press Start 2P is the widest button font: a step smaller keeps "Explore free tools" on one line. */
    :root[data-theme="pixel"] #view-home .home-stage-actions a {
        padding-inline: 1rem;
        font-size: 0.9rem;
    }

    /* Two small cards side by side: the name alone, smaller, so it fits. */
    #view-home .home-stage-game-icon {
        display: none;
    }

    #view-home .home-stage-game-copy b {
        font-size: 1.05rem;
        overflow-wrap: anywhere;
    }
}

/* ---------- headline fit per theme font ---------- */
/* 10000 / the width of "Hating Unity?" set at 100px in the theme's heading font. */
:root[data-theme="pixel"] #view-home { --stage-title-fit: 14.6; }      /* Pixelify Sans in this theme, 685px */
:root[data-theme="mario"] #view-home,
:root[data-theme="crash"] #view-home,
:root[data-theme="spyro"] #view-home { --stage-title-fit: 15.5; }      /* Quicksand, 645px */
:root[data-theme="cyberpunk"] #view-home { --stage-title-fit: 19.2; }  /* VT323 in this theme, 520px */
:root[data-theme="gb-green"] #view-home,
:root[data-theme="gb-blue"] #view-home { --stage-title-fit: 19.8; }    /* VT323, 505px */
