/* ============================================
   bada.day - Isometric Scholastic Warmth
   Terracotta Tower Library Descent
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --fired-terracotta: #C2663E;
    --kiln-shadow: #8B3A1F;
    --sun-bleached-linen: #F5EDE3;
    --warm-parchment: #EDE0CE;
    --iron-gall-ink: #2C1810;
    --aged-script: #6B5145;
    --burnished-gold: #D4A853;
    --clerestory-blue: #4A6B8A;

    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;
}

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

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

body {
    background-color: var(--sun-bleached-linen);
    color: var(--iron-gall-ink);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* --- Sky Gradient Strip --- */
#sky-strip {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(to bottom, rgba(74, 107, 138, 0.1), transparent);
    z-index: 100;
    pointer-events: none;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    right: 16px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: rgba(44, 24, 16, 0.06);
    z-index: 200;
    pointer-events: none;
}

#scroll-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--burnished-gold);
    transition: height 0.1s linear;
}

#scroll-bookmark {
    position: absolute;
    left: 50%;
    top: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    transition: top 0.1s linear;
}

.bookmark-book {
    width: 16px;
    height: 12px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
}

.bookmark-page-left,
.bookmark-page-right {
    width: 7px;
    height: 10px;
    background: var(--fired-terracotta);
}

.bookmark-page-left {
    transform: skewY(-5deg);
    border-radius: 1px 0 0 0;
}

.bookmark-page-right {
    transform: skewY(5deg);
    border-radius: 0 1px 0 0;
}

/* --- Navigation Cube --- */
#nav-cube-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 300;
}

#nav-cube {
    width: 24px;
    height: 24px;
    position: relative;
    cursor: pointer;
    animation: cube-spin 8s linear infinite;
    transform-style: preserve-3d;
}

@keyframes cube-spin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.cube-face {
    position: absolute;
    width: 24px;
    height: 24px;
}

.cube-top {
    width: 24px;
    height: 14px;
    background: var(--warm-parchment);
    transform: skewX(-30deg);
    top: -4px;
    left: 4px;
}

.cube-left {
    width: 18px;
    height: 20px;
    background: var(--fired-terracotta);
    transform: skewY(-30deg);
    top: 2px;
    left: -2px;
}

.cube-right {
    width: 18px;
    height: 20px;
    background: var(--kiln-shadow);
    transform: skewY(30deg);
    top: 2px;
    left: 10px;
}

#nav-list {
    list-style: none;
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--sun-bleached-linen);
    border: 1px solid rgba(44, 24, 16, 0.1);
    border-radius: 4px;
    box-shadow: 4px 4px 16px rgba(44, 24, 16, 0.1);
    min-width: 180px;
}

#nav-cube-container:hover #nav-list,
#nav-cube-container.nav-open #nav-list {
    display: flex;
}

#nav-cube-container:hover #nav-cube,
#nav-cube-container.nav-open #nav-cube {
    animation-play-state: paused;
}

#nav-list li a {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--aged-script);
    text-decoration: none;
    transition: color 0.3s ease;
    display: block;
    padding: 4px 0;
}

#nav-list li a:hover {
    color: var(--fired-terracotta);
}

/* --- Floor (Section) Base --- */
.floor {
    position: relative;
    width: 100%;
}

/* --- Floor 0: The Observation Deck (Hero) --- */
.floor-hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sun-bleached-linen);
    perspective: 1200px;
}

.floor-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

/* Hero Book */
.hero-book {
    display: flex;
    align-items: stretch;
    justify-content: center;
    transform: scale(0.9) rotateX(55deg) rotateZ(-45deg);
    transform-style: preserve-3d;
    opacity: 0;
    will-change: transform, opacity;
    filter: drop-shadow(8px 8px 16px rgba(44, 24, 16, 0.15));
}

.hero-book.revealed {
    opacity: 1;
    transform: scale(1) rotateX(55deg) rotateZ(-45deg);
    transition: opacity 800ms cubic-bezier(0.22, 1, 0.36, 1), transform 800ms cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-book-page {
    width: clamp(140px, 28vw, 300px);
    height: clamp(180px, 36vw, 380px);
    background: var(--sun-bleached-linen);
    border: 2px solid var(--fired-terracotta);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
}

.hero-page-left {
    transform-origin: right center;
    transform: rotateY(0deg);
    border-right: none;
    border-radius: 4px 0 0 4px;
}

.hero-book.revealed .hero-page-left {
    transform: rotateY(-8deg);
    transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1) 400ms;
}

.hero-page-right {
    transform-origin: left center;
    transform: rotateY(0deg);
    border-left: none;
    border-radius: 0 4px 4px 0;
}

.hero-book.revealed .hero-page-right {
    transform: rotateY(8deg);
    transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1) 400ms;
}

.hero-book-spine {
    width: 4px;
    background: var(--burnished-gold);
    flex-shrink: 0;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 4.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--iron-gall-ink);
    overflow: hidden;
}

.site-title .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 120ms ease;
}

.site-title .char.visible {
    opacity: 1;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1.1rem);
    color: var(--aged-script);
    font-style: italic;
    text-align: center;
}

.scroll-prompt {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--aged-script);
    animation: pulse 2s ease-in-out infinite;
    opacity: 0;
}

.scroll-prompt.visible {
    opacity: 1;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* --- Tile Transitions --- */
.tile-transition {
    height: 80px;
    background:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(194, 102, 62, 0.08) 10px,
            rgba(194, 102, 62, 0.08) 11px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 10px,
            rgba(194, 102, 62, 0.08) 10px,
            rgba(194, 102, 62, 0.08) 11px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 10px,
            rgba(194, 102, 62, 0.04) 10px,
            rgba(194, 102, 62, 0.04) 11px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 10px,
            rgba(194, 102, 62, 0.04) 10px,
            rgba(194, 102, 62, 0.04) 11px
        );
    background-color: var(--warm-parchment);
    mask-image: linear-gradient(transparent, black 20%, black 80%, transparent);
    -webkit-mask-image: linear-gradient(transparent, black 20%, black 80%, transparent);
}

/* --- Reading Rooms (Floors 1-3) --- */
.reading-room {
    min-height: 200vh;
    padding: 6rem 0;
    background: var(--sun-bleached-linen);
}

.reading-room.alt-bg {
    background: var(--warm-parchment);
}

/* Floor Label */
.floor-label {
    text-align: center;
    margin-bottom: 3rem;
}

.floor-label-text {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--aged-script);
}

/* Room Grid */
.room-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(12px, 2vw, 24px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 48px);
    opacity: 0.3;
    transform: scale(0.85);
    will-change: transform, opacity;
}

/* Content Column */
.room-content {
    grid-column: 1 / 8;
}

.room-heading {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.01em;
    line-height: 1.15;
    color: var(--fired-terracotta);
    margin-bottom: 1.5rem;
}

.room-content p {
    max-width: 38ch;
    margin-bottom: 1.5rem;
    color: var(--iron-gall-ink);
}

/* Book Divider */
.book-divider {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2px;
    margin: 0 auto 2.5rem 0;
    width: 40px;
    height: 28px;
}

.divider-page-left,
.divider-page-right {
    width: 16px;
    height: 20px;
    background: var(--fired-terracotta);
    border-radius: 1px;
}

.divider-page-left {
    transform: skewY(-6deg);
}

.divider-page-right {
    transform: skewY(6deg);
}

/* Illustration Column */
.room-illustration {
    grid-column: 8 / 13;
    position: sticky;
    top: 15vh;
    height: fit-content;
    align-self: start;
}

/* --- Isometric Rooms --- */
.iso-room {
    position: relative;
    width: 280px;
    height: 360px;
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateZ(-45deg);
    margin: 0 auto;
}

.iso-floor-surface {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--warm-parchment);
    border: 2px solid rgba(44, 24, 16, 0.08);
}

.iso-wall-left {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 12px;
    height: 100%;
    background: var(--fired-terracotta);
    transform-origin: bottom left;
    transform: skewY(-0deg);
}

.iso-wall-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 12px;
    background: var(--kiln-shadow);
    transform-origin: bottom right;
}

/* --- Bookshelf Construction --- */
.shelf-unit {
    position: absolute;
    top: 20px;
    left: 30px;
    right: 20px;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
}

.shelf-row {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding: 0 4px;
}

.book-spine {
    border-radius: 1px;
    flex-shrink: 0;
    box-shadow: 1px 1px 2px rgba(44, 24, 16, 0.1);
}

.shelf-board {
    height: 4px;
    background: var(--kiln-shadow);
    width: 100%;
    border-radius: 1px;
    box-shadow: 0 2px 4px rgba(44, 24, 16, 0.12);
}

/* --- Desk Construction --- */
.iso-desk .desk-surface {
    position: absolute;
    top: 40%;
    left: 25px;
    right: 25px;
    height: 120px;
    background: var(--kiln-shadow);
    border-radius: 2px;
    box-shadow: 0 4px 8px rgba(44, 24, 16, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.desk-book-open {
    display: flex;
    align-items: center;
    gap: 2px;
}

.desk-page {
    width: 50px;
    height: 68px;
    background: var(--sun-bleached-linen);
    border-radius: 1px;
}

.desk-page-l {
    transform: skewY(-2deg);
}

.desk-page-r {
    transform: skewY(2deg);
}

.desk-book-spine-line {
    width: 2px;
    height: 72px;
    background: var(--burnished-gold);
}

.desk-inkwell {
    position: absolute;
    top: 12px;
    right: 18px;
    width: 16px;
    height: 16px;
    background: var(--iron-gall-ink);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(44, 24, 16, 0.2);
}

.desk-leg {
    position: absolute;
    width: 8px;
    height: 80px;
    background: var(--kiln-shadow);
}

.desk-leg-1 {
    bottom: 20px;
    left: 40px;
}

.desk-leg-2 {
    bottom: 20px;
    right: 40px;
}

/* --- Window Alcove Construction --- */
.iso-window .iso-wall-left {
    width: 50px;
    position: relative;
}

.window-opening {
    position: absolute;
    top: 30%;
    left: 8px;
    width: 34px;
    height: 80px;
    background: var(--clerestory-blue);
    border-radius: 17px 17px 0 0;
    overflow: hidden;
}

.window-sky {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #6B8FAF, var(--clerestory-blue));
}

.window-arch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid var(--fired-terracotta);
    border-radius: 17px 17px 0 0;
    box-sizing: border-box;
}

.alcove-seat {
    position: absolute;
    bottom: 40px;
    left: 14px;
    width: 60px;
    height: 24px;
    background: var(--kiln-shadow);
    border-radius: 2px;
}

.alcove-cushion {
    position: absolute;
    bottom: 48px;
    left: 18px;
    width: 52px;
    height: 16px;
    background: var(--fired-terracotta);
    border-radius: 4px 4px 2px 2px;
}

/* --- Floor 4: The Foundation --- */
.floor-foundation {
    min-height: 150vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: var(--warm-parchment);
}

.foundation-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    opacity: 0.3;
    transform: scale(0.85);
    will-change: transform, opacity;
}

.foundation-tile {
    width: clamp(250px, 50vw, 450px);
    height: clamp(250px, 50vw, 450px);
    background: var(--fired-terracotta);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 8px 8px 24px rgba(44, 24, 16, 0.2);
    position: relative;
}

.foundation-tile::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px solid rgba(245, 237, 227, 0.2);
}

.foundation-domain {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--sun-bleached-linen);
}

.foundation-note {
    max-width: 38ch;
    text-align: center;
    color: var(--aged-script);
    font-family: var(--font-body);
    font-style: italic;
}

/* --- Shadow Play --- */
.iso-room {
    filter: drop-shadow(4px 4px 8px rgba(44, 24, 16, 0.15));
    transition: filter 0.3s ease;
}

/* Shadows deepen on deeper floors */
#floor-1 .iso-room {
    filter: drop-shadow(4px 4px 8px rgba(44, 24, 16, 0.15));
}

#floor-2 .iso-room {
    filter: drop-shadow(7px 7px 12px rgba(44, 24, 16, 0.15));
}

#floor-3 .iso-room {
    filter: drop-shadow(10px 10px 16px rgba(44, 24, 16, 0.15));
}

/* --- Links --- */
a {
    color: var(--iron-gall-ink);
    text-decoration: underline;
    text-decoration-color: var(--burnished-gold);
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--fired-terracotta);
}

a:visited {
    color: var(--kiln-shadow);
}

/* --- Responsive: Below 768px --- */
@media (max-width: 768px) {
    #nav-cube-container {
        top: auto;
        bottom: 24px;
        right: 24px;
        left: auto;
    }

    #nav-list {
        position: absolute;
        bottom: 36px;
        right: 0;
    }

    .room-grid {
        grid-template-columns: 1fr;
    }

    .room-content {
        grid-column: 1 / -1;
        order: 1;
    }

    .room-illustration {
        grid-column: 1 / -1;
        position: relative;
        top: auto;
        order: 0;
        margin-bottom: 2rem;
    }

    .iso-room {
        transform: rotateX(55deg) rotateZ(-45deg) scale(0.55);
        margin: -40px auto;
    }

    .room-content p {
        max-width: 100%;
    }

    #scroll-progress {
        right: 8px;
    }

    .hero-book-page {
        width: 130px;
        height: 170px;
    }

    .reading-room {
        min-height: auto;
        padding: 4rem 0;
    }
}

/* --- Selection Color --- */
::selection {
    background: rgba(194, 102, 62, 0.2);
    color: var(--iron-gall-ink);
}

/* --- Scrollbar Styling (Webkit) --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--sun-bleached-linen);
}

::-webkit-scrollbar-thumb {
    background: var(--fired-terracotta);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--kiln-shadow);
}
