/* ============================================
   gabs.games — Wabi-Sabi Candy-Bright Arcade
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --charred-umber: #1a0f0a;
    --kiln-bisque: #f2e6d9;
    --bubblegum-shock: #ff6b9d;
    --reef-flash: #00d4aa;
    --mango-burst: #ffb347;
    --kintsugi-seam: #d4a574;
    --abyssal-indigo: #1a2744;
    --sugar-orchid: #c49bff;
    --bisque-mid: #e8d5c4;
    --bisque-deep: #d4c4b0;

    --font-headline: 'Libre Baskerville', 'Georgia', serif;
    --font-body: 'Karla', 'Helvetica Neue', sans-serif;
    --font-accent: 'Inconsolata', 'Courier New', monospace;

    --bg-current: var(--kiln-bisque);
    --crack-glow: 0 0 0px transparent;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    color: var(--charred-umber);
    background: var(--kiln-bisque);
    background-image:
        repeating-conic-gradient(from 23deg at 47% 53%, transparent 0deg, rgba(26, 15, 10, 0.02) 3deg, transparent 6deg),
        radial-gradient(ellipse at 30% 20%, #f2e6d9 0%, #e8d5c4 60%, #d4c4b0 100%);
    overflow-x: hidden;
    line-height: 1.72;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Skeleton Loading Overlay --- */
#skeleton-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    background: var(--kiln-bisque);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 3rem;
    padding: 8vh 6vw;
    transition: opacity 0.6s ease-out;
}

#skeleton-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.skeleton-item {
    border-radius: 8px;
    background: linear-gradient(
        90deg,
        var(--mango-burst) 0%,
        var(--bubblegum-shock) 33%,
        var(--sugar-orchid) 66%,
        var(--mango-burst) 100%
    );
    background-size: 300% 100%;
    animation: skeletonShimmer 2s ease-in-out infinite;
}

.skeleton-title {
    width: 60%;
    height: 60%;
    align-self: end;
    border-radius: 4px;
}

.skeleton-fish-cluster {
    width: 80%;
    height: 70%;
    justify-self: end;
    border-radius: 50% 30% 50% 30%;
}

.skeleton-text-block {
    width: 75%;
    height: 40%;
    align-self: start;
    border-radius: 4px;
}

.skeleton-motif {
    width: 50%;
    height: 50%;
    justify-self: end;
    align-self: start;
    border-radius: 12px;
}

@keyframes skeletonShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* --- Chamber Navigation --- */
#chamber-nav {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.chamber-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid var(--kintsugi-seam);
    background: var(--bisque-mid);
    cursor: pointer;
    position: relative;
    transition: all 0.4s ease;
    box-shadow: inset 0 0 2px rgba(26, 15, 10, 0.15);
}

.chamber-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: transparent;
    transition: all 0.4s ease;
}

.chamber-dot.active {
    background: var(--kintsugi-seam);
    border-color: var(--bubblegum-shock);
    box-shadow:
        0 0 8px rgba(255, 107, 157, 0.5),
        0 0 20px rgba(255, 107, 157, 0.2),
        inset 0 0 3px rgba(255, 107, 157, 0.3);
}

.chamber-dot:hover {
    transform: scale(1.3);
    border-color: var(--bubblegum-shock);
}

/* Hairline crack on dots */
.chamber-dot::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 2px;
    width: 8px;
    height: 1px;
    background: linear-gradient(90deg, var(--kintsugi-seam), transparent);
    transform: rotate(-15deg);
    opacity: 0.6;
}

/* --- Chambers --- */
.chamber {
    min-height: 110vh;
    position: relative;
    overflow: hidden;
}

#chamber-foyer {
    min-height: 120vh;
}

#chamber-depth {
    min-height: 90vh;
    background: var(--abyssal-indigo);
}

.chamber-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8vh 5vw;
    position: relative;
    min-height: 100vh;
}

/* --- Z-Pattern Grid --- */
.z-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
        "tl tr"
        "bl br";
    gap: 3rem 4rem;
    align-items: start;
}

.z-tl { grid-area: tl; }
.z-tr { grid-area: tr; }
.z-bl { grid-area: bl; }
.z-br { grid-area: br; }

/* Intentional wabi-sabi misalignment */
.z-tl { transform: translate(-2px, 0px); }
.z-tr { transform: translate(3px, -2px); }
.z-bl { transform: translate(0px, 4px); }
.z-br { transform: translate(-3px, 2px); }

/* --- Foyer (Chamber 1) --- */
.foyer-grid {
    padding-top: 12vh;
}

.site-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 6rem);
    letter-spacing: -0.02em;
    color: var(--charred-umber);
    text-shadow: 1px 1px 0 var(--bubblegum-shock);
    line-height: 1.1;
}

.title-dot {
    color: var(--bubblegum-shock);
    text-shadow: none;
}

.manifesto-label {
    margin-top: 1rem;
}

.accent-text {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--kintsugi-seam);
}

.manifesto-text {
    font-family: var(--font-headline);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    line-height: 1.5;
    color: var(--charred-umber);
    max-width: 38em;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    max-width: 38em;
    color: var(--charred-umber);
}

.italic-text {
    font-family: var(--font-headline);
    font-style: italic;
    font-weight: 400;
}

.chamber-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    letter-spacing: -0.02em;
    color: var(--charred-umber);
    text-shadow: 1px 1px 0 var(--bubblegum-shock);
    margin-bottom: 1rem;
}

/* --- Fish Collage --- */
.fish-collage {
    position: relative;
    height: 100%;
    min-height: 300px;
}

.fish-collage .fish-angel {
    position: absolute;
    width: 180px;
    top: 0;
    right: 10%;
    transform: rotate(-8deg);
}

.fish-collage .fish-betta {
    position: absolute;
    width: 220px;
    top: 30%;
    right: 25%;
    transform: rotate(5deg);
}

.fish-collage .fish-clown {
    position: absolute;
    width: 140px;
    bottom: 15%;
    right: 5%;
    transform: rotate(-3deg);
}

/* --- Fish Interactions --- */
.fish {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: default;
}

.fish:hover {
    animation: fishWiggle 0.6s ease-in-out;
}

.fish-puffer {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fish-puffer:hover {
    transform: scale(1.4) !important;
}

@keyframes fishWiggle {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    50% { transform: rotate(-10deg); }
    75% { transform: rotate(8deg); }
    100% { transform: rotate(0deg); }
}

/* --- Skeleton Motif (Permanent decorative) --- */
.skeleton-motif-permanent {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    opacity: 0.6;
}

.skeleton-pulse {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--mango-burst),
        var(--bubblegum-shock),
        var(--sugar-orchid),
        var(--mango-burst)
    );
    background-size: 300% 100%;
    animation: skeletonShimmer 2s ease-in-out infinite;
}

.skeleton-pulse:nth-child(1) { width: 80%; }
.skeleton-pulse:nth-child(2) { width: 60%; }
.skeleton-pulse:nth-child(3) { width: 70%; }

.skeleton-pulse.delay-1 { animation-delay: 0.3s; }
.skeleton-pulse.delay-2 { animation-delay: 0.6s; }

/* --- Kintsugi Cracks --- */
.kintsugi-crack {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 10;
    pointer-events: none;
}

.crack-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: filter 0.5s ease;
}

.crack-path.drawn {
    stroke-dashoffset: 0;
    filter: drop-shadow(0 0 6px var(--bubblegum-shock));
}

/* --- Torn-Edge Cards --- */
.torn-card {
    padding: 2rem 2.5rem;
    position: relative;
    background: var(--kiln-bisque);
    background-image:
        repeating-conic-gradient(from 23deg at 47% 53%, transparent 0deg, rgba(26, 15, 10, 0.015) 3deg, transparent 6deg);
    box-shadow: 0 0 0 1px var(--kintsugi-seam);
}

.card-style-1 {
    clip-path: polygon(2% 1%, 15% 0%, 28% 2%, 41% 0%, 55% 1%, 68% 0%, 82% 2%, 95% 0%, 98% 1%, 100% 15%, 99% 35%, 100% 55%, 98% 75%, 100% 90%, 99% 100%, 85% 98%, 70% 100%, 55% 99%, 40% 100%, 25% 98%, 10% 100%, 0% 99%, 1% 80%, 0% 60%, 2% 40%, 0% 20%);
}

.card-style-2 {
    clip-path: polygon(0% 2%, 12% 0%, 25% 1%, 38% 0%, 52% 2%, 65% 0%, 78% 1%, 90% 0%, 100% 2%, 99% 18%, 100% 38%, 98% 58%, 100% 78%, 99% 95%, 100% 100%, 88% 99%, 75% 100%, 62% 98%, 48% 100%, 35% 99%, 22% 100%, 8% 98%, 0% 100%, 1% 82%, 0% 62%, 2% 42%, 0% 22%);
}

.card-style-3 {
    clip-path: polygon(1% 0%, 18% 2%, 32% 0%, 48% 1%, 62% 0%, 78% 2%, 92% 0%, 100% 1%, 99% 20%, 100% 42%, 98% 62%, 100% 82%, 99% 100%, 82% 98%, 65% 100%, 48% 99%, 32% 100%, 15% 98%, 0% 100%, 2% 78%, 0% 58%, 1% 38%, 0% 18%);
}

.card-style-4 {
    clip-path: polygon(0% 1%, 14% 0%, 30% 2%, 44% 0%, 58% 1%, 72% 0%, 88% 2%, 100% 0%, 98% 22%, 100% 45%, 99% 68%, 100% 88%, 98% 100%, 84% 99%, 68% 100%, 52% 98%, 36% 100%, 20% 99%, 4% 100%, 0% 98%, 2% 75%, 0% 50%, 1% 25%);
}

.card-label {
    display: block;
    margin-bottom: 0.5rem;
}

/* --- Reef Grid Offset --- */
.reef-grid .z-tl {
    transform: translate(-2px, -8px);
}
.reef-grid .z-tr {
    transform: translate(4px, 12px);
    position: relative;
}
.reef-grid .z-bl {
    transform: translate(2px, -6px);
}

.reef-grid .fish-angel-small {
    position: absolute;
    width: 60px;
    bottom: -40px;
    right: 20px;
    opacity: 0.3;
}

.reef-grid .coral-branch {
    position: absolute;
    width: 80px;
    bottom: -60px;
    right: -20px;
}

/* --- Archive Collage (Chamber 3) --- */
.archive-collage {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto;
    gap: 1rem;
    padding: 10vh 5vw;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
}

.collage-card {
    padding: 2rem 2.2rem;
    position: relative;
    z-index: var(--card-z, 1);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: default;
}

.collage-card:hover {
    z-index: 20 !important;
    transform: translateY(-8px) scale(1.02) rotate(0deg) !important;
    box-shadow: 0 16px 40px rgba(26, 15, 10, 0.15);
}

.collage-card:hover ~ .collage-card {
    opacity: 0.85;
    transform: scale(0.98);
}

/* Card textures */
.card-parchment {
    background: var(--kiln-bisque);
    background-image:
        repeating-conic-gradient(from 45deg at 50% 50%, transparent 0deg, rgba(26, 15, 10, 0.02) 4deg, transparent 8deg);
    box-shadow: 0 4px 12px rgba(26, 15, 10, 0.08), inset 0 0 0 1px var(--kintsugi-seam);
    clip-path: polygon(2% 1%, 15% 0%, 28% 2%, 41% 0%, 55% 1%, 68% 0%, 82% 2%, 95% 0%, 98% 1%, 100% 15%, 99% 35%, 100% 55%, 98% 75%, 100% 90%, 99% 100%, 85% 98%, 70% 100%, 55% 99%, 40% 100%, 25% 98%, 10% 100%, 0% 99%, 1% 80%, 0% 60%, 2% 40%, 0% 20%);
}

.card-candy {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.08), rgba(196, 155, 255, 0.08));
    background-color: var(--kiln-bisque);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.1), inset 0 0 0 1px var(--sugar-orchid);
    clip-path: polygon(0% 2%, 12% 0%, 25% 1%, 38% 0%, 52% 2%, 65% 0%, 78% 1%, 90% 0%, 100% 2%, 99% 18%, 100% 38%, 98% 58%, 100% 78%, 99% 95%, 100% 100%, 88% 99%, 75% 100%, 62% 98%, 48% 100%, 35% 99%, 22% 100%, 8% 98%, 0% 100%, 1% 82%, 0% 62%, 2% 42%, 0% 22%);
}

.card-foil {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.06), rgba(255, 179, 71, 0.08));
    background-color: var(--kiln-bisque);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.1), inset 0 0 0 1px var(--reef-flash);
    clip-path: polygon(1% 0%, 18% 2%, 32% 0%, 48% 1%, 62% 0%, 78% 2%, 92% 0%, 100% 1%, 99% 20%, 100% 42%, 98% 62%, 100% 82%, 99% 100%, 82% 98%, 65% 100%, 48% 99%, 32% 100%, 15% 98%, 0% 100%, 2% 78%, 0% 58%, 1% 38%, 0% 18%);
}

/* Card rotations */
.rotate-pos-2 { transform: rotate(2deg); }
.rotate-pos-3 { transform: rotate(3deg); }
.rotate-pos-5 { transform: rotate(5deg); }
.rotate-neg-2 { transform: rotate(-2deg); }
.rotate-neg-3 { transform: rotate(-3deg); }
.rotate-neg-4 { transform: rotate(-4deg); }

/* Card overlap positioning */
.archive-collage .collage-card:nth-child(1) {
    grid-column: 1 / 3;
    margin-right: -2rem;
}

.archive-collage .collage-card:nth-child(2) {
    grid-column: 2 / 4;
    margin-left: -3rem;
    margin-top: -2rem;
}

.archive-collage .collage-card:nth-child(3) {
    grid-column: 1 / 2;
    margin-right: -1rem;
}

.archive-collage .collage-card:nth-child(4) {
    grid-column: 2 / 4;
    margin-left: -2rem;
    margin-top: -3rem;
}

.archive-collage .collage-card:nth-child(5) {
    grid-column: 1 / 3;
    margin-top: -2rem;
}

.archive-collage .collage-card:nth-child(6) {
    grid-column: 2 / 4;
    margin-left: -4rem;
    margin-top: -2rem;
}

/* Decorative tape */
.tape {
    position: absolute;
    width: 60px;
    height: 18px;
    background: rgba(255, 179, 71, 0.35);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(26, 15, 10, 0.1);
}

.tape-tl {
    top: -6px;
    left: 20px;
    transform: rotate(-12deg);
    background: rgba(255, 107, 157, 0.3);
}

.tape-tr {
    top: -6px;
    right: 20px;
    transform: rotate(8deg);
    background: rgba(196, 155, 255, 0.35);
}

.tape-bl {
    bottom: -6px;
    left: 30px;
    transform: rotate(5deg);
    background: rgba(0, 212, 170, 0.3);
}

/* Pufferfish in archive */
.archive-collage .fish-puffer {
    position: absolute;
    width: 80px;
    bottom: 15%;
    right: 8%;
    z-index: 15;
}

/* --- Depth Chamber (Chamber 4) --- */
.depth-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90vh;
}

.depth-title-container {
    text-align: center;
}

.depth-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #d4a574 0%, #ff6b9d 35%, #ffb347 65%, #d4a574 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    text-shadow: none;
}

.depth-dot {
    /* Dots inherit the gradient since it's a child of depth-title */
}

#chamber-depth {
    background:
        repeating-conic-gradient(from 10deg at 40% 60%, transparent 0deg, rgba(212, 165, 116, 0.03) 2deg, transparent 5deg),
        radial-gradient(ellipse at 50% 50%, #1a2744 0%, #0f1a2e 100%);
}

/* --- Reveal Animation --- */
.reveal-item {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger delays via JS-applied styles, fallback here */
.reveal-item:nth-child(1) { transition-delay: 0ms; }
.reveal-item:nth-child(2) { transition-delay: 150ms; }
.reveal-item:nth-child(3) { transition-delay: 300ms; }
.reveal-item:nth-child(4) { transition-delay: 450ms; }
.reveal-item:nth-child(5) { transition-delay: 600ms; }
.reveal-item:nth-child(6) { transition-delay: 750ms; }

/* --- Ambient Fish --- */
.ambient-fish {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.ambient-angel-1 {
    position: absolute;
    width: 80px;
    top: 20%;
    left: 8%;
}

.ambient-betta-1 {
    position: absolute;
    width: 100px;
    top: 55%;
    right: 12%;
}

.ambient-clown-1 {
    position: absolute;
    width: 60px;
    top: 75%;
    left: 15%;
}

/* --- Background chamber transitions --- */
.chamber[data-bg="foyer"] {
    background:
        repeating-conic-gradient(from 23deg at 47% 53%, transparent 0deg, rgba(26, 15, 10, 0.02) 3deg, transparent 6deg),
        radial-gradient(ellipse at 30% 20%, #f2e6d9 0%, #e8d5c4 60%, #d4c4b0 100%);
}

.chamber[data-bg="reef"] {
    background:
        repeating-conic-gradient(from 15deg at 50% 50%, transparent 0deg, rgba(26, 15, 10, 0.015) 3deg, transparent 6deg),
        radial-gradient(ellipse at 40% 30%, #eee3d8 0%, #e2d5c8 60%, #d0c3b5 100%);
}

.chamber[data-bg="archive"] {
    background:
        repeating-conic-gradient(from 30deg at 45% 55%, transparent 0deg, rgba(212, 165, 116, 0.03) 3deg, transparent 6deg),
        radial-gradient(ellipse at 50% 40%, #f5ead0 0%, #ecdcc5 60%, #ddd0b8 100%);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .z-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "tl"
            "tr"
            "bl"
            "br";
        gap: 2rem;
    }

    .foyer-grid {
        padding-top: 6vh;
    }

    .fish-collage {
        min-height: 200px;
    }

    .fish-collage .fish-angel { width: 120px; }
    .fish-collage .fish-betta { width: 150px; }
    .fish-collage .fish-clown { width: 100px; }

    #chamber-nav {
        right: 0.8rem;
    }

    .archive-collage {
        grid-template-columns: 1fr;
        padding: 6vh 4vw;
    }

    .archive-collage .collage-card {
        grid-column: 1 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: -1rem !important;
    }

    .torn-card {
        padding: 1.5rem 1.8rem;
    }

    .site-title {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    .depth-title {
        font-size: clamp(3rem, 15vw, 6rem);
    }
}

@media (max-width: 480px) {
    .chamber-inner {
        padding: 5vh 4vw;
    }

    .kintsugi-crack {
        height: 40px;
    }
}
