/* ============================================
   MAGICAL LIBRARY - Static Background + Particles
   Moonlit anime library aesthetic
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Inter:wght@300;400;500;600&display=swap');

/* ---- CSS Variables ---- */
:root {
    --color-bg: #060812;
    --color-gold: #c9a84c;
    --color-gold-light: #e8d48b;
    --color-gold-dark: #8a6d2b;
    --color-magic-blue: #6ba4ff;
    --color-magic-purple: #9b7fd4;
    --color-magic-teal: #5ce0d0;
    --color-moon-silver: #d4dff7;
    --color-moon-glow: #a8c4f0;
    --color-text: #e8e4f0;
    --color-text-dim: #9a96b0;
    --color-wood-dark: #1e1428;
    --color-wood: #382848;
    --color-wood-light: #4a3860;
    --color-leather: #3c2a50;
    --font-display: 'Cinzel Decorative', serif;
    --font-body: 'Crimson Text', serif;
    --font-ui: 'Inter', sans-serif;
}

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

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

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    overflow: hidden;
}

/* ============================================
   DOOR OPENING ANIMATION
   ============================================ */
.door-intro {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #050508;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
}

.door-frame {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.door-left, .door-right {
    width: 50%;
    height: 100%;
    position: relative;
    z-index: 2;
}

.door-left {
    transform-origin: left center;
}

.door-right {
    transform-origin: right center;
}

.door-panel {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0818 0%, #1a1030 30%, #251840 50%, #1a1030 70%, #0a0818 100%);
    border: 2px solid var(--color-gold-dark);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10vh 0;
}

.door-ornament {
    width: 60%;
    height: 25vh;
    border: 2px solid var(--color-gold-dark);
    border-radius: 50% 50% 0 0;
    position: relative;
    opacity: 0.6;
}

.door-ornament.bottom {
    border-radius: 0 0 50% 50%;
}

.door-ornament::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: inherit;
}

.door-handle-left, .door-handle-right {
    width: 20px;
    height: 80px;
    background: linear-gradient(to bottom, var(--color-gold-light), var(--color-gold), var(--color-gold-dark));
    border-radius: 10px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.5), inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.door-handle-left { right: 30px; }
.door-handle-right { left: 30px; }

.door-light {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(168, 196, 240, 0.2) 0%, transparent 70%);
    z-index: 1;
    opacity: 0;
}

.door-text {
    position: absolute;
    z-index: 3;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
}

.door-welcome {
    display: block;
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--color-moon-silver);
    letter-spacing: 8px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.door-title {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--color-gold);
    text-shadow: 0 0 30px rgba(168, 196, 240, 0.4), 0 0 60px rgba(168, 196, 240, 0.2);
}

/* ============================================
   MAIN LIBRARY SCENE — Static Background
   ============================================ */
.library-scene {
    position: fixed;
    inset: 0;
    opacity: 0;
    background: var(--color-bg);
}

/* Background image — parallax scrolling (slower than content) */
.library-bg {
    position: fixed;
    inset: 0;
    background-image: url('background_image.png');
    background-size: cover;
    background-position: center 0%;
    background-repeat: no-repeat;
    z-index: 0;
    will-change: background-position;
}

/* Dark vignette — keeps edges dark for text readability */
.library-vignette {
    position: fixed;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(ellipse at 50% 30%, transparent 15%, rgba(6, 8, 18, 0.4) 55%, rgba(6, 8, 18, 0.8) 100%),
        linear-gradient(to bottom, rgba(6, 8, 18, 0.1) 0%, rgba(6, 8, 18, 0.3) 50%, rgba(6, 8, 18, 0.5) 100%);
    pointer-events: none;
}

/* Moonlight glow — top-center bloom matching the moon in the image */
.moonlight-glow {
    position: fixed;
    top: -10%;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    height: 50vh;
    background: radial-gradient(ellipse at center, rgba(168, 196, 240, 0.08) 0%, transparent 70%);
    z-index: 2;
    pointer-events: none;
    animation: moonPulse 6s ease-in-out infinite;
}

@keyframes moonPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Magic dust particles — moonlit colors */
.magic-particles {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}

.magic-particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
}

/* Silver-blue moonlight particles */
.magic-particle.moon {
    background: var(--color-moon-silver);
    box-shadow: 0 0 6px var(--color-moon-glow), 0 0 12px rgba(168, 196, 240, 0.4);
    animation: particleFloatUp var(--duration) var(--delay) ease-in-out infinite;
}

/* Warm golden particles (lantern-like) */
.magic-particle.warm {
    background: var(--color-gold-light);
    box-shadow: 0 0 6px var(--color-gold), 0 0 10px rgba(201, 168, 76, 0.4);
    animation: particleFloatUp var(--duration) var(--delay) ease-in-out infinite;
}

/* Sparkle particles — twinkle in place */
.magic-particle.sparkle {
    background: white;
    box-shadow: 0 0 4px rgba(212, 223, 247, 0.8), 0 0 8px rgba(168, 196, 240, 0.5);
    animation: particleTwinkle var(--duration) var(--delay) ease-in-out infinite;
}

@keyframes particleFloatUp {
    0% { opacity: 0; transform: translateY(100vh) translateX(0) scale(0.3); }
    10% { opacity: 0.9; }
    50% { transform: translateY(40vh) translateX(var(--drift, 20px)) scale(1); }
    90% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-10vh) translateX(var(--drift-end, -10px)) scale(0.5); }
}

@keyframes particleTwinkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    20% { opacity: 0.8; transform: scale(1.2); }
    50% { opacity: 0.3; transform: scale(0.8); }
    80% { opacity: 0.9; transform: scale(1); }
}

/* Sparkle canvas (fireflies) — layered above bg, below content */
.sparkle-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    pointer-events: none;
}

/* ============================================
   CONTENT OVERLAY
   ============================================ */
.content-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
    pointer-events: none;

    scrollbar-width: thin;
    scrollbar-color: rgba(168, 196, 240, 0.3) transparent;
}

.content-overlay::-webkit-scrollbar {
    width: 6px;
}
.content-overlay::-webkit-scrollbar-track {
    background: transparent;
}
.content-overlay::-webkit-scrollbar-thumb {
    background: rgba(168, 196, 240, 0.3);
    border-radius: 3px;
}

.content-overlay > * {
    pointer-events: auto;
}

/* ---- Header ---- */
.library-header {
    text-align: center;
    padding: 15vh 2rem 10vh;
    position: relative;
}

.library-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.title-glow {
    background: linear-gradient(135deg, var(--color-moon-silver), var(--color-gold-light), var(--color-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(168, 196, 240, 0.5));
    animation: titlePulse 4s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { filter: drop-shadow(0 0 20px rgba(168, 196, 240, 0.4)); }
    50% { filter: drop-shadow(0 0 40px rgba(168, 196, 240, 0.8)); }
}

.library-subtitle {
    font-family: var(--font-body);
    font-size: 1.3rem;
    color: var(--color-text-dim);
    letter-spacing: 4px;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 0, 0, 0.7);
}

/* ---- Scroll Content ---- */
.scroll-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem 10vh;
}

/* ---- Book Sections ---- */
.book-section {
    margin-bottom: 8vh;
    opacity: 0;
    transform: translateY(40px);
}

.book-section.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section-header {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--color-gold);
    text-align: center;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-shadow:
        0 0 10px rgba(0, 0, 0, 1),
        0 0 20px rgba(0, 0, 0, 0.9),
        0 0 40px rgba(0, 0, 0, 0.7),
        0 2px 4px rgba(0, 0, 0, 1);
    background: radial-gradient(ellipse at center, rgba(6, 8, 18, 0.6) 0%, transparent 70%);
    padding: 1rem 2rem;
    border-radius: 8px;
}

.section-icon {
    font-size: 2rem;
}

/* ============================================
   BOOK CARDS — Glass-morphism with library feel
   ============================================ */
.book-card {
    background: linear-gradient(145deg, rgba(10, 12, 30, 0.85), rgba(20, 18, 40, 0.9));
    border: 1px solid rgba(168, 196, 240, 0.15);
    border-radius: 4px 16px 16px 4px;
    position: relative;
    overflow: hidden;
    display: flex;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    backdrop-filter: blur(16px);
}

.book-card:hover {
    transform: translateY(-4px) rotateY(-2deg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 30px rgba(168, 196, 240, 0.08);
}

/* Book spine */
.book-card__spine {
    width: 12px;
    min-height: 100%;
    background: linear-gradient(to right, var(--color-gold-dark), var(--color-gold), var(--color-gold-dark));
    flex-shrink: 0;
    position: relative;
    border-radius: 4px 0 0 4px;
}

.book-card__spine.closed {
    background: linear-gradient(to right, #556, #778, #556);
}

.book-card__spine.merged {
    background: linear-gradient(to right, var(--color-magic-purple), #b89de0, var(--color-magic-purple));
}

.book-card__spine::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 50%;
    width: 2px;
    height: 80%;
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-50%);
}

.book-card__content {
    padding: 2rem 2.5rem;
    flex: 1;
}

.book-card__badge {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-gold);
    background: rgba(201, 168, 76, 0.1);
    border: 1px solid rgba(201, 168, 76, 0.3);
    padding: 4px 12px;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.archive-badge {
    color: #aaa;
    background: rgba(150, 150, 150, 0.1);
    border-color: rgba(150, 150, 150, 0.3);
}

.merged-badge {
    color: var(--color-magic-purple);
    background: rgba(155, 127, 212, 0.1);
    border-color: rgba(155, 127, 212, 0.3);
}

.book-card__title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--color-moon-silver);
    margin-bottom: 0.3rem;
}

.book-card__subtitle {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--color-text-dim);
    font-style: italic;
    margin-bottom: 1rem;
}

.book-card__description {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--color-text);
    margin-bottom: 1.5rem;
}

.book-card__tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tech-gem {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    background: rgba(107, 164, 255, 0.12);
    border: 1px solid rgba(107, 164, 255, 0.3);
    border-radius: 20px;
    color: var(--color-magic-blue);
    letter-spacing: 0.5px;
}

.tech-gem.faded {
    background: rgba(150, 150, 170, 0.08);
    border-color: rgba(150, 150, 170, 0.2);
    color: var(--color-text-dim);
}

.book-card__link {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-gold);
    text-decoration: none;
    padding: 8px 20px;
    border: 1px solid var(--color-gold-dark);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.book-card__link:hover {
    background: rgba(201, 168, 76, 0.15);
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.2);
    color: var(--color-gold-light);
}

/* Flagship card */
.flagship-card {
    border-color: rgba(201, 168, 76, 0.3);
    box-shadow: 0 0 40px rgba(201, 168, 76, 0.05);
}

.flagship-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.25), transparent 50%, rgba(168, 196, 240, 0.15));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.flagship-card:hover::before {
    opacity: 1;
}

/* Archive grid */
.archive-grid {
    display: grid;
    gap: 1.5rem;
}

.archive-card .book-card__title {
    font-size: 1.3rem;
    color: var(--color-text);
}

/* ============================================
   SKILLS - Books on shelves
   ============================================ */
.skills-shelves {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    background: linear-gradient(145deg, rgba(10, 12, 30, 0.8), rgba(20, 18, 40, 0.85));
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    border: 1px solid rgba(168, 196, 240, 0.12);
}

.skill-shelf {
    position: relative;
}

.shelf-label {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.skill-books {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    padding: 1rem 0;
    position: relative;
}

/* Shelf wood underneath */
.skill-books::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 5%;
    width: 90%;
    height: 8px;
    background: linear-gradient(to bottom, var(--color-wood-light), var(--color-wood-dark));
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.skill-book {
    width: 70px;
    height: calc(40px + var(--book-height, 80px));
    background: linear-gradient(to right, 
        color-mix(in srgb, var(--book-color) 80%, black),
        var(--book-color),
        color-mix(in srgb, var(--book-color) 80%, black)
    );
    border-radius: 3px 6px 6px 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.4);
}

.skill-book:hover {
    transform: translateY(-10px);
}

.skill-book::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 10%;
    width: 2px;
    height: 80%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 1px;
}

.skill-book__title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ============================================
   CONTACT SECTION
   ============================================ */
.contact-scroll {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.scroll-ornament {
    height: 30px;
    background: linear-gradient(to bottom, var(--color-wood), var(--color-wood-light), var(--color-wood));
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.scroll-body {
    background: linear-gradient(to bottom, 
        rgba(20, 18, 40, 0.92),
        rgba(15, 14, 35, 0.95),
        rgba(20, 18, 40, 0.92)
    );
    padding: 3rem 2rem;
    border-left: 3px solid rgba(168, 196, 240, 0.15);
    border-right: 3px solid rgba(168, 196, 240, 0.15);
    backdrop-filter: blur(16px);
}

.contact-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--color-gold);
    margin-bottom: 0.5rem;
}

.contact-desc {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text-dim);
    margin-bottom: 2rem;
    font-style: italic;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    color: var(--color-moon-silver);
    text-decoration: none;
    padding: 10px 20px;
    border: 1px solid rgba(168, 196, 240, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.contact-link:hover {
    background: rgba(168, 196, 240, 0.08);
    border-color: var(--color-moon-glow);
    box-shadow: 0 0 20px rgba(168, 196, 240, 0.15);
}

.contact-link__icon {
    font-size: 1.2rem;
}

.contact-location {
    font-size: 0.9rem;
    color: var(--color-text-dim);
}

/* ============================================
   FOOTER
   ============================================ */
.library-footer {
    text-align: center;
    padding: 4rem 2rem 2rem;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: rgba(168, 196, 240, 0.3);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .library-header { padding: 12vh 1.5rem 8vh; }
    .scroll-content { padding: 0 1rem 10vh; }
    .book-card__content { padding: 1.5rem; }
    .book-card__title { font-size: 1.4rem; }
    .archive-grid { gap: 1rem; }
    .skill-book { width: 55px; }
    .skill-books { gap: 0.5rem; }
    .contact-links { flex-direction: column; align-items: center; }
}

@media (max-width: 480px) {
    .library-title { font-size: 2rem; }
    .book-card__content { padding: 1rem 1.2rem; }
    .skill-book { width: 45px; }
    .skill-book__title { font-size: 0.55rem; }
}
