/*
 * Game page: the day and night themes of the home page (main.home), tinted with the colour of the game. A hero with the
 * game name in gold and engraved in outline behind it, then one tile per map with an art area above its name.
 */
.game-page {
    --game-color: var(--home-gold);
    /* End of the title gradient: the game colour, darkened by day to stay readable on parchment. */
    --game-title-to: light-dark(color-mix(in srgb, var(--game-color) 55%, var(--color-text)), var(--game-color));
}

.game-page--thronefall {
    --game-color: var(--color-thronefall);
}

.game-page--craaghelm {
    --game-color: var(--color-craaghelm);
}

/* Hero: the bottom padding leaves a band for the engraved name, below the buttons. */
.game-hero {
    --watermark-size: clamp(4.5rem, 15vw, 14rem);

    position: relative;
    isolation: isolate;
    /* Clipped sideways only, so the glow can rise behind the header. */
    overflow-x: clip;
    padding-block: clamp(4rem, 10vw, 8rem) calc(var(--watermark-size) * 0.85);
}

/* The glow starts at the top of the window, behind the header, rather than under it where the page begins. */
.game-hero::before {
    content: '';
    position: absolute;
    z-index: -2;
    inset: calc(-1 * (var(--header-height) + var(--frame-gap))) 0 0;
    background:
        radial-gradient(ellipse 55% 75% at 85% 0, color-mix(in srgb, var(--game-color) 28%, transparent), transparent 70%),
        linear-gradient(transparent 60%, var(--home-bg));
    pointer-events: none;
}

/*
 * The game name engraved in outline, bleeding off the right edge. Capped to the width of the hero, so that a name wider
 * than the screen keeps its first letter visible and overflows on the right instead.
 */
.game-hero::after {
    content: attr(data-title) / '';
    position: absolute;
    z-index: -1;
    right: -0.06em;
    bottom: -0.05em;
    max-width: calc(100% + 0.06em);
    color: transparent;
    font-family: var(--font-family-display);
    font-size: var(--watermark-size);
    font-weight: 700;
    line-height: 0.8;
    text-transform: uppercase;
    white-space: nowrap;
    -webkit-text-stroke: 1px color-mix(in srgb, var(--game-color) 40%, transparent);
    pointer-events: none;
}

.game-hero__inner {
    display: grid;
    justify-items: start;
    gap: var(--space-m);
    max-width: var(--home-content-width);
    margin-inline: auto;
    padding-inline: var(--home-gutter);
}

.game-hero__title {
    margin: var(--space-s) 0 0;
    background: linear-gradient(175deg, var(--home-title-from) 35%, var(--game-title-to) 80%);
    background-clip: text;
    color: transparent;
    font-size: clamp(3rem, 9vw, 8rem);
    line-height: 0.95;
    letter-spacing: -0.005em;
}

.game-hero__lead {
    max-width: 36rem;
    margin: 0;
    color: var(--home-text-muted);
    font-size: clamp(1.0625rem, 1.4vw, 1.25rem);
}

/* Map tiles */
.game-maps {
    max-width: var(--home-content-width);
    margin-inline: auto;
    padding: calc(var(--space-l) + var(--space-m)) var(--home-gutter) var(--home-section-space);
}

.game-maps__empty {
    margin: 0;
    padding: var(--space-l);
    border: 1px dashed var(--home-line-strong);
    border-radius: var(--home-radius-inner);
    color: var(--home-text-muted);
    text-align: center;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
    gap: clamp(1rem, 2vw, 1.5rem);
    margin: 0;
    padding: 0;
    list-style: none;
}

.map-tile {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--home-line);
    border-radius: var(--home-radius-inner);
    background-color: var(--home-surface);
    color: var(--home-text);
    text-decoration: none;
    transition:
        transform 0.6s var(--home-ease),
        box-shadow 0.6s var(--home-ease),
        border-color 0.6s ease;
}

.map-tile:hover {
    border-color: color-mix(in srgb, var(--game-color) 60%, transparent);
    color: var(--home-text);
    box-shadow: 0 30px 70px -30px color-mix(in srgb, var(--game-color) 55%, transparent);
    transform: translateY(-6px);
}

/* Placeholder art until the map screenshots exist: a night landscape whose glow moves from tile to tile. */
.map-tile__art {
    --art-glow-x: 20%;

    display: block;
    aspect-ratio: 16 / 9;
    background-image:
        linear-gradient(transparent 55%, var(--home-surface)),
        linear-gradient(160deg, transparent 60%, var(--art-landscape-hill) 60%),
        linear-gradient(205deg, transparent 50%, var(--art-landscape-mountain) 50% 68%, transparent 68%),
        radial-gradient(circle at var(--art-glow-x) 35%, color-mix(in srgb, var(--game-color) 45%, transparent), transparent 55%),
        linear-gradient(var(--art-landscape-sky-top), var(--art-landscape-sky-bottom));
    transition: transform 1.2s var(--home-ease);
}

/*
 * The square preview of the map, cropped to the art area and fading into the body of the tile like the placeholder.
 * The image itself fades out: an overlay would leave a line of the image at its bottom edge while the tile zooms.
 */
.map-tile__art--preview {
    background-image: none;
}

.map-tile__art--preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    mask-image: linear-gradient(#000 65%, transparent);
}

.map-grid > li:nth-child(3n + 2) .map-tile__art {
    --art-glow-x: 55%;
}

.map-grid > li:nth-child(3n) .map-tile__art {
    --art-glow-x: 85%;
}

.map-tile:hover .map-tile__art {
    transform: scale(1.06);
}

.map-tile__badge {
    position: absolute;
    top: var(--space-m);
    left: var(--space-m);
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--game-color);
    border-radius: 999px;
    background-color: var(--home-shade-night);
    color: var(--game-color);
    font-family: var(--font-family-ui);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.map-tile__body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-m);
    padding: var(--space-s) 1.25rem 1.25rem;
}

.map-tile__name {
    min-width: 0;
    font-family: var(--font-family-display);
    font-size: clamp(1.125rem, 1.6vw, 1.375rem);
    font-weight: 700;
    letter-spacing: var(--letter-spacing-display);
    line-height: 1.1;
    text-transform: uppercase;
}

.map-tile__action {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--home-line-strong);
    border-radius: 50%;
    color: var(--home-gold);
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease;
}

.map-tile:hover .map-tile__action {
    border-color: var(--game-color);
    background-color: var(--game-color);
    color: var(--color-night-deep);
}

.map-tile__icon {
    width: 1.125rem;
    height: 1.125rem;
}

/* One tile per row on phones: a wider, shorter art area so the list stays compact. */
@media (max-width: 30rem) {
    .map-tile__art {
        aspect-ratio: 3 / 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-tile,
    .map-tile__art,
    .map-tile__action {
        transition: none;
    }

    .map-tile:hover,
    .map-tile:hover .map-tile__art {
        transform: none;
    }
}
