/* Pipefall - Falling-Pipe Puzzle Page Styles (Alchemy / Observatory Theme) */

.pipefall-page {
    color-scheme: dark;
    --pf-base: #140d1c;
    --pf-panel: #1c1227;
    --pf-line: #443550;
    --pf-text: #f7edf4;
    --pf-muted: #d5c4d8;
    --pf-accent: #e1bded;
    --pf-gold: #ebd1ad;
    --pf-silver: #dfd8e5;
    background-color: var(--pf-base);
    color: var(--pf-text);
    font: 16px/1.65 'DM Sans', system-ui, sans-serif;
}

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

.pipefall-page main h1,
.pipefall-page main h2,
.pipefall-page main h3,
.pipefall-page .pf-tagline,
.pipefall-page .pf-button,
.pipefall-page .pf-kicker,
.pipefall-page .pf-milestones,
.pipefall-page .pf-screen-caption,
.pipefall-page dt {
    font-family: Georgia, 'Noto Serif', serif;
}

.pipefall-page main h1,
.pipefall-page main h2,
.pipefall-page main h3 {
    font-weight: 600;
    line-height: 1.14;
    letter-spacing: -.025em;
    text-transform: none;
    margin: 0 0 .5em;
    text-wrap: balance;
    color: var(--pf-text);
}

.pipefall-page main h2 {
    font-size: clamp(2rem, 4vw, 3.5rem);
}

.pipefall-page main h3 {
    font-size: 1.4rem;
}

.pipefall-page main p {
    color: var(--pf-muted);
    margin: 0 0 1.2em;
}

.pipefall-page main img {
    display: block;
    max-width: 100%;
    height: auto;
}

.pipefall-page .pf-wrap {
    width: min(1120px, calc(100% - 3rem));
    margin-inline: auto;
}

/* Hero Section (overrides global .hero from /style.css) */
.pipefall-page .hero.pf-hero {
    position: relative;
    height: auto;
    min-height: 640px;
    display: grid;
    align-items: center;
    justify-content: stretch;
    text-align: left;
    overflow: hidden;
    background:
        linear-gradient(90deg, #150a1f 0%, #14091dc9 36%, #14091d05 65%),
        url('/pipefall/images/pipefall-hero-art.webp') center / cover no-repeat;
    background-color: var(--pf-base);
    border-bottom: 1px solid var(--pf-line);
    padding-top: 96px;
}

.pipefall-page .hero.pf-hero::before {
    display: none;
}

.pipefall-page .hero.pf-hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #66516f 23%, #cfbddb 50%, #66516f 77%, transparent);
    pointer-events: none;
}

.pipefall-page .pf-hero-copy {
    position: relative;
    z-index: 1;
    padding: 64px 0 72px;
}

.pipefall-page .pf-hero-mark {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.5vw, 22px);
    margin: 0 0 1.15rem;
}

.pipefall-page .pf-hero-mark .pf-icon {
    width: clamp(72px, 7.25vw, 104px);
    flex: none;
    filter: drop-shadow(0 2px 7px #0b0411) drop-shadow(0 0 17px #b35df130);
}

.pipefall-page .pf-hero h1 {
    font-size: clamp(3.15rem, 6vw, 5.25rem);
    margin: 0;
    line-height: 1;
    letter-spacing: .025em;
    font-weight: 700;
    text-transform: uppercase;
    color: #f9effb;
    text-shadow: 0 2px 15px #170c1d, 0 1px 0 #8d739b;
}

.pipefall-page .pf-tagline {
    font-style: italic;
    color: #dfc4ea;
    font-size: clamp(1.15rem, 2.3vw, 1.65rem);
    margin: 0 0 .7em;
    letter-spacing: .005em;
}

.pipefall-page .pf-lede {
    max-width: 36ch;
    font-size: 1.12rem;
    color: var(--pf-text);
    margin: 0 0 1.2em;
}

.pipefall-page .pf-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Seal Buttons */
.pipefall-page .pf-button {
    --seal: url('/pipefall/ui/amethyst-seal-silver.png');
    position: relative;
    z-index: 0;
    display: inline-grid;
    place-items: center;
    background: none;
    border: 0;
    border-radius: 0;
    color: #fff4ff;
    text-shadow: 0 2px 5px #0b0211;
    text-align: center;
    text-decoration: none;
    min-height: 54px;
    min-width: 168px;
    padding: 7px 23px 11px;
    line-height: 1.12;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    isolation: isolate;
    transition: none;
}

.pipefall-page .pf-button::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--seal) center / 100% 100% no-repeat;
    transition: filter 160ms ease;
}

.pipefall-page .pf-button.pf-primary,
.pipefall-page .pf-seal-tab[aria-selected="true"] {
    --seal: url('/pipefall/ui/turquoise-seal.png');
}

.pipefall-page .pf-button:hover::before {
    filter: brightness(1.18);
}

.pipefall-page .pf-button:active::before {
    filter: brightness(.87);
}

.pipefall-page .pf-button:focus-visible {
    outline: 2px solid #f4d590;
    outline-offset: 3px;
}

/* Engraved Nine-Sliced Frame */
.pipefall-page .pf-engraved {
    position: relative;
    isolation: isolate;
}

.pipefall-page .pf-engraved::after {
    content: "";
    position: absolute;
    inset: 0;
    border: clamp(23px, 4vw, 54px) solid transparent;
    border-image: url('/pipefall/ui/collections-frame.webp') 116 stretch;
    pointer-events: none;
    z-index: 2;
    filter: grayscale(.77) brightness(1.15);
    opacity: .9;
}

/* Story Section */
.pipefall-page .pf-story {
    max-width: 940px;
    margin-block: clamp(2.5rem, 7vw, 6rem);
    padding: clamp(2.6rem, 5.5vw, 5rem) clamp(1.35rem, 6vw, 5.75rem);
    background: radial-gradient(ellipse at top, #30203e, #1c1327 64%);
    border-radius: 14px;
    text-align: center;
}

.pipefall-page .pf-story .pf-ornament {
    display: inline-block;
    color: #dac0e8;
    text-shadow: 0 0 14px #c2a0e253;
    font-size: 1.5rem;
    margin-bottom: .35rem;
}

.pipefall-page .pf-story-text {
    max-width: 64ch;
    margin: auto;
}

.pipefall-page .pf-story-text p:last-child {
    font-family: Georgia, 'Noto Serif', serif;
    font-style: italic;
    color: var(--pf-gold);
    margin-bottom: 0;
}

/* Gameplay & Progression Panels */
.pipefall-page .pf-panel {
    background: var(--pf-panel);
    border-block: 1px solid var(--pf-line);
}

.pipefall-page .pf-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 7vw, 6rem);
    align-items: center;
    padding-block: clamp(3.5rem, 8vw, 7rem);
}

.pipefall-page .pf-kicker {
    font-size: .83rem;
    text-transform: uppercase;
    letter-spacing: .17em;
    color: #dfc4ea;
    font-weight: 700;
    margin-bottom: .6rem;
}

.pipefall-page dl {
    margin: 0;
}

.pipefall-page dl > div {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 12px;
    border-top: 1px solid var(--pf-line);
    padding: 8px 0;
}

.pipefall-page dt {
    color: var(--pf-gold);
    font-weight: 600;
}

.pipefall-page dd {
    margin: 0;
    color: var(--pf-muted);
}

/* Interactive Game Deck */
.pipefall-page .pf-game-deck {
    background: radial-gradient(ellipse at top, #382446, #1b1126 68%);
    padding: clamp(1.2rem, 3vw, 2rem);
    border-radius: 12px;
}

.pipefall-page .pf-game-deck::after {
    border-width: clamp(20px, 3vw, 34px);
}

.pipefall-page .pf-seal-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    margin: .35rem 0 1.1rem;
}

.pipefall-page .pf-seal-tab {
    min-width: 0;
    min-height: 37px;
    padding: 3px 7px 7px;
    font-size: clamp(.76rem, 1.12vw, 1rem);
}

.pipefall-page .pf-duo {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.pipefall-page .pf-solo {
    max-width: 215px;
    margin: auto;
}

.pipefall-page .pf-shot {
    display: block;
    border: 1px solid #876995;
    border-radius: 5px;
    overflow: hidden;
    background: #100b15;
}

.pipefall-page .pf-shot img {
    width: 100%;
    height: auto;
}

.pipefall-page .pf-shot:hover,
.pipefall-page .pf-shot:focus-visible {
    border-color: var(--pf-gold);
    outline: 2px solid var(--pf-gold);
    outline-offset: 3px;
}

.pipefall-page .pf-screen-caption {
    margin: .75rem .25rem .2rem;
    text-align: center;
    font-size: .92rem;
    color: #e7cce8;
}

.pipefall-page .pf-screen-panel[hidden] {
    display: none;
}

/* Progression / Relics */
.pipefall-page .pf-relic {
    background: radial-gradient(ellipse at top, #30203e, #1c1327 64%);
    border-radius: 14px;
    margin-block: clamp(2.5rem, 6vw, 5rem);
    padding-inline: clamp(1.25rem, 5vw, 4.25rem);
    padding-block: clamp(2.5rem, 5vw, 4.25rem);
}

.pipefall-page .pf-relic::after {
    border-width: clamp(22px, 3vw, 43px);
}

.pipefall-page .pf-relic-img {
    width: min(310px, 100%);
    justify-self: center;
    border: 1px solid #977fa6;
    border-radius: 8px;
    box-shadow: 0 10px 36px #08040dae;
}

.pipefall-page .pf-milestones {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 1.3rem 0 1.8rem;
}

.pipefall-page .pf-milestones span {
    background: linear-gradient(#36243f, #24172d);
    border: 1px solid #7c6687;
    color: #f0dff4;
    padding: 4px 9px;
    border-radius: 4px;
}

/* Gallery Section (high specificity to override /gallery.css loaded in body) */
.pipefall-page .pf-gallery {
    background:
        linear-gradient(#1b1123ec, #1b1123f9),
        url('/pipefall/ui/room.webp') center 45% / cover;
}

.pipefall-page .pf-gallery .pf-wrap {
    padding-block: clamp(3.5rem, 8vw, 6rem);
}

.pipefall-page .pf-gallery h2 {
    text-align: center;
    margin-bottom: 1em;
}

.pipefall-page .pf-gallery .pf-gallery-frame {
    padding: clamp(1.2rem, 3vw, 2rem);
    background: #150d1d8f;
    border-radius: 8px;
}

.pipefall-page .pf-gallery .pf-gallery-frame::after {
    border-width: clamp(18px, 2.8vw, 35px);
}

.pipefall-page .pf-gallery .gallery-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: start;
    gap: 12px;
    padding: 0;
}

.pipefall-page .pf-gallery .gallery-item {
    display: block;
    border: 1px solid #806d8f;
    border-radius: 4px;
    padding: 3px;
    background: #100b15;
    overflow: hidden;
    box-shadow: none;
    cursor: pointer;
    transition: border-color .2s ease;
}

.pipefall-page .pf-gallery .gallery-item:hover,
.pipefall-page .pf-gallery .gallery-item:focus-visible {
    transform: none;
    box-shadow: none;
    border-color: var(--pf-gold);
    outline: 2px solid var(--pf-gold);
    outline-offset: 3px;
}

.pipefall-page .pf-gallery .gallery-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    object-position: center;
    display: block;
}

.pipefall-page .pf-gallery .page-link {
    border-color: var(--pf-line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--pf-text);
}

.pipefall-page .pf-gallery .page-link:hover {
    border-color: var(--pf-gold);
    color: var(--pf-gold);
}

.pipefall-page .pf-gallery .page-link.active {
    background: var(--pf-gold);
    color: #140d1c;
    border-color: var(--pf-gold);
    box-shadow: 0 4px 15px rgba(235, 209, 173, 0.3);
}

/* Closing Availability CTA */
.pipefall-page .pf-end {
    max-width: 900px;
    margin-block: clamp(2.5rem, 7vw, 6rem);
    padding: clamp(2.5rem, 5.5vw, 4.25rem) clamp(1.5rem, 6vw, 4.5rem);
    background: radial-gradient(ellipse at top, #30203e, #1c1327 64%);
    border-radius: 14px;
    text-align: center;
}

.pipefall-page .pf-end::after {
    border-width: clamp(22px, 3vw, 43px);
}

.pipefall-page .pf-closing-emblem {
    margin: 0 auto 1rem;
    filter: drop-shadow(0 3px 10px #0a0612);
}

.pipefall-page .pf-end p {
    margin-bottom: 1.3rem;
}

/* Game Deck Dialog Lightbox */
.pipefall-page dialog#pf-lightbox {
    background: #130d1a;
    border: 1px solid var(--pf-line);
    color: var(--pf-text);
    padding: 12px;
    max-height: 95vh;
    max-width: 90vw;
    margin: auto;
}

.pipefall-page dialog#pf-lightbox::backdrop {
    background: #0b0611e8;
}

.pipefall-page dialog#pf-lightbox img {
    display: block;
    max-height: 87vh;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.pipefall-page dialog#pf-lightbox button {
    position: absolute;
    right: 8px;
    top: 8px;
    border: 1px solid var(--pf-line);
    border-radius: 4px;
    background: var(--pf-base);
    color: var(--pf-text);
    font-size: 24px;
    line-height: 1;
    padding: 4px 10px;
    cursor: pointer;
}

/* Responsive Breakpoints */
@media (max-width: 980px) {
    .pipefall-page .pf-gallery .gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 740px) {
    .pipefall-page .pf-wrap {
        width: calc(100% - 2rem);
    }

    .pipefall-page .hero.pf-hero {
        min-height: 0;
        background:
            linear-gradient(0deg, #170b20 0%, #170b20 46%, #14091d00 100%),
            url('/pipefall/images/pipefall-hero-art.webp') 80% 70px / auto 330px no-repeat,
            #170b20;
        padding-top: 0;
    }

    .pipefall-page .pf-hero-copy {
        padding: 300px 0 50px;
    }

    .pipefall-page .pf-hero-mark {
        gap: 12px;
        margin-bottom: 1rem;
    }

    .pipefall-page .pf-hero-mark .pf-icon {
        width: clamp(52px, 16vw, 74px);
    }

    .pipefall-page .pf-hero h1 {
        font-size: clamp(2.35rem, 9vw, 4.15rem);
    }

    .pipefall-page .pf-hero .pf-button {
        min-width: 145px;
        min-height: 49px;
        padding-inline: 17px;
    }

    .pipefall-page .pf-split {
        grid-template-columns: 1fr;
    }

    .pipefall-page .pf-relic > div {
        grid-row: 1;
    }

    .pipefall-page .pf-duo {
        max-width: 520px;
    }

    .pipefall-page .pf-seal-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    .pipefall-page .pf-seal-tab {
        min-height: 44px;
        font-size: .94rem;
    }

    .pipefall-page .pf-gallery .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .pipefall-page .pf-button::before {
        transition: none;
    }
}
