/* ============================================
   gabs.boo - Surreal Dreamscape
   Impossible house with rooms and doors
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    color: #3d3552;
    background: #f0e6d3;
    overflow-x: hidden;
    position: relative;
}

/* --- Film Grain Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Opening Intro Overlay --- */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0e6d3;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.8s ease-in;
}

#intro-overlay.slide-up {
    transform: translateY(-100vh);
}

#intro-overlay.hidden {
    display: none;
}

#door-frame {
    position: relative;
    width: 200px;
    height: 60vh;
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#door {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid #3d3552;
    border-radius: 4px;
    background: #f0e6d3;
    transform-origin: left center;
    transition: transform 1.2s ease-in-out;
    z-index: 2;
    opacity: 0;
    animation: doorFadeIn 0.4s ease 0.3s forwards;
}

@keyframes doorFadeIn {
    to { opacity: 1; }
}

#door.open {
    transform: perspective(800px) rotateY(-45deg);
}

#doorknob {
    position: absolute;
    right: 20px;
    top: 50%;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e8b84b;
    transform: translateY(-50%);
}

#door-reveal {
    position: relative;
    z-index: 1;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#door-reveal.visible {
    opacity: 1;
}

#title-text {
    display: block;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 8vw;
    color: #1a1035;
    letter-spacing: -0.03em;
}

#title-text .char {
    display: inline-block;
    opacity: 0;
    animation: charFadeIn 0.3s ease forwards;
}

@keyframes charFadeIn {
    to { opacity: 1; }
}

#annotation {
    display: block;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#annotation.visible {
    opacity: 1;
}

/* --- Caveat handwritten notes --- */
.caveat-note {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 22px;
    color: #7b6fa0;
}

.margin-note {
    position: absolute;
    pointer-events: none;
    white-space: nowrap;
}

/* --- Hallway Navigation --- */
#hallway {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: #2d2340;
    z-index: 500;
    display: flex;
    flex-direction: column;
    padding: 80px 20px 40px;
    gap: 20px;
    transform: translateX(-100%);
    transition: transform 0.4s ease;
    overflow-y: auto;
}

#hallway.open {
    transform: translateX(0);
}

.hallway-floor {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 38px,
        rgba(240, 230, 211, 0.06) 38px,
        rgba(240, 230, 211, 0.06) 40px
    );
    pointer-events: none;
}

.nav-door {
    display: block;
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #3d3552;
    border-radius: 4px;
    text-decoration: none;
    position: relative;
    transition: border-color 0.2s ease, transform 0.15s ease;
    background: transparent;
}

.nav-door:hover {
    border-color: #e8b84b;
    transform: rotate(1.5deg);
}

.nav-door::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 10%;
    width: 80%;
    height: 2px;
    background: #a8d8c8;
    transition: height 0.2s ease;
    border-radius: 1px;
}

.nav-door:hover::after {
    height: 6px;
}

.door-label {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 16px;
    color: #d4c8b8;
    letter-spacing: -0.01em;
}

.door-knob-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e8b84b;
    transform: translateY(-50%);
}

/* --- Mobile Nav Toggle --- */
#mobile-nav-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 600;
    background: none;
    border: none;
    cursor: pointer;
    display: none;
    padding: 0;
}

/* --- Main Content --- */
#main-content {
    position: relative;
    transition: transform 1.5s ease-in-out;
}

#main-content.gravity-shifted {
    transform: rotate(180deg);
}

/* --- Rooms --- */
.room {
    position: relative;
    min-height: 100vh;
    padding: 120px 80px;
    overflow: hidden;
    transition: background-color 0.6s ease;
}

.room-light {
    background: #f0e6d3;
    color: #3d3552;
}

.room-dark {
    background: #1a1035;
    color: #d4c8b8;
}

.room-dark .room-title {
    color: #f0e6d3;
}

.room-dark .room-text {
    color: #d4c8b8;
}

.room-inner {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
}

/* --- Skewed sections --- */
.skew-section {
    transform: skewY(-2deg);
}

.skew-section .room-inner {
    transform: skewY(2deg);
}

/* --- Room Typography --- */
.room-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 64px;
    letter-spacing: -0.03em;
    color: #1a1035;
    margin-bottom: 32px;
    position: relative;
}

.room-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    margin-bottom: 24px;
    max-width: 680px;
}

.room-text em,
.room-text strong {
    font-weight: 600;
}

/* --- Scroll reveal --- */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

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

/* --- Pull quote --- */
.pull-quote {
    margin: 48px 0;
    padding: 32px 40px;
    border-left: 4px solid #c4573a;
    position: relative;
}

.pull-quote blockquote {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 24px;
    color: #1a1035;
    letter-spacing: -0.01em;
    line-height: 1.5;
    font-style: italic;
}

/* --- Section Dividers --- */
.room-divider {
    position: relative;
    height: 120px;
    margin: -1px 0;
}

.divider-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.section-divider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
}

.section-divider svg {
    width: 100%;
    height: 100%;
}

/* --- Hexagonal Grid (Gallery) --- */
.hex-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 48px;
    max-width: 600px;
}

.hex-card {
    aspect-ratio: 1;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(240, 230, 211, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.hex-card:hover {
    background: rgba(240, 230, 211, 0.15);
}

.hex-inner {
    text-align: center;
    padding: 20px;
}

.hex-label {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 16px;
    color: #d4c8b8;
    margin-top: 8px;
}

/* --- Inverted Mountains --- */
.inverted-mountains {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200px;
    pointer-events: none;
}

.inverted-mountains svg {
    width: 100%;
    height: 100%;
}

/* --- Sideways Mountains --- */
.sideways-mountains {
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 100%;
    pointer-events: none;
}

.sideways-mountains svg {
    width: 100%;
    height: 100%;
}

/* --- Surreal Clock --- */
.surreal-clock {
    position: absolute;
    top: 30px;
    right: 0;
    opacity: 0.6;
}

.clock-study {
    top: auto;
    bottom: 40px;
    right: 20px;
}

/* --- Floating Keys --- */
.floating-key {
    position: absolute;
    z-index: 50;
    pointer-events: none;
    animation: floatKey 3s ease-in-out infinite;
    opacity: 0.7;
    transition: transform 0.4s ease;
}

@keyframes floatKey {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-12px);
    }
}

.floating-key:nth-child(2) {
    animation-delay: 1s;
}
.floating-key:nth-child(3) {
    animation-delay: 2s;
}
.floating-key:nth-child(4) {
    animation-delay: 0.5s;
}
.floating-key:nth-child(5) {
    animation-delay: 1.5s;
}

/* --- Swimming Fish --- */
.swimming-fish {
    position: absolute;
    left: -80px;
    z-index: 50;
    pointer-events: none;
    animation: swimAcross 20s linear infinite;
    opacity: 0.6;
}

@keyframes swimAcross {
    0% {
        transform: translateX(-80px);
    }
    50% {
        transform: translateX(calc(100vw + 80px));
    }
    50.01% {
        transform: translateX(-80px);
    }
    100% {
        transform: translateX(-80px);
    }
}

.swimming-fish:nth-of-type(2) {
    animation-delay: 2s;
    animation-duration: 25s;
}
.swimming-fish:nth-of-type(3) {
    animation-delay: 4s;
    animation-duration: 18s;
}

/* --- Floating Bowler Hat --- */
.floating-hat {
    position: absolute;
    z-index: 50;
    pointer-events: none;
    opacity: 0.5;
    animation: floatHat 4s ease-in-out infinite;
}

@keyframes floatHat {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

/* --- Ceiling Furniture (Inverted Room) --- */
.ceiling-furniture {
    display: flex;
    justify-content: center;
    margin: 40px 0;
    transform: rotate(180deg);
}

/* --- Gravity Shift Wrapper --- */
.gravity-shift-wrapper {
    transition: transform 1.5s ease-in-out;
}

.gravity-shifted .gravity-shift-wrapper {
    transform: rotate(180deg);
}

/* --- Garden Door Illustration --- */
.garden-door-illustration {
    display: flex;
    justify-content: center;
    margin: 48px 0;
}

/* --- Footer --- */
#room-exit {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.footer-text {
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    color: #d4c8b8;
    margin-bottom: 16px;
}

.return-door {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    margin-top: 32px;
    transition: transform 0.3s ease;
}

.return-door:hover {
    transform: scale(1.05);
}

.return-label {
    font-family: 'Caveat', cursive;
    font-size: 20px;
    color: #e8b84b;
}

/* --- Dark room grain overlay --- */
.room-dark::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.07;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    #hallway {
        display: none;
    }

    #mobile-nav-toggle {
        display: block;
    }

    #hallway.mobile-open {
        display: flex;
        transform: translateX(0);
        width: 200px;
    }

    .room {
        padding: 80px 24px;
    }

    .room-title {
        font-size: 42px;
    }

    .hex-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .skew-section {
        transform: none;
    }

    .skew-section .room-inner {
        transform: none;
    }

    .floating-key,
    .floating-hat,
    .swimming-fish {
        display: none;
    }

    .margin-note {
        position: relative;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        display: block;
        margin-bottom: 16px;
    }

    #title-text {
        font-size: 12vw;
    }

    .pull-quote blockquote {
        font-size: 20px;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(196, 87, 58, 0.3);
    color: #1a1035;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f0e6d3;
}

::-webkit-scrollbar-thumb {
    background: #d4c8b8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #7b6fa0;
}
