/* ============================================================
   ZIYING ZHANG — Architecture Portfolio
   Premium Book-Style Single Page Website
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
    --bg-primary: #080808;
    --bg-secondary: #111111;
    --text-primary: #f0ece6;
    --text-secondary: #8a8580;
    --text-muted: #5a5550;
    --accent: #c9a96e;
    --accent-dim: rgba(201, 169, 110, 0.15);
    --page-bg: #1a1815;
    --shadow-color: rgba(0, 0, 0, 0.6);

    --font-serif: 'Cormorant Garamond', 'Playfair Display', 'Georgia', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --transition-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    --header-height: 56px;
    --footer-height: 52px;
    --nav-width: 64px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
}

/* Subtle background gradient — spotlight effect */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 45%, rgba(30, 26, 22, 0.6) 0%, transparent 70%),
        radial-gradient(ellipse 120% 80% at 50% 50%, rgba(20, 18, 15, 0.4) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* Subtle noise texture overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.03;
    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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    pointer-events: none;
    z-index: 0;
}

/* ============================================================
   LOADING SCREEN
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s var(--transition-smooth), visibility 0.8s;
}

.loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    animation: loadingFadeIn 1s var(--transition-smooth) both;
}

.loading-name {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 300;
    letter-spacing: 0.35em;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
}

.loading-subtitle {
    font-family: var(--font-sans);
    font-size: clamp(0.65rem, 1.2vw, 0.85rem);
    font-weight: 300;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

.loading-bar {
    width: 180px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 auto 1rem;
    border-radius: 1px;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: var(--accent);
    transition: width 0.3s var(--transition-smooth);
    border-radius: 1px;
}

.loading-percent {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

@keyframes loadingFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    opacity: 1;
    transition: opacity 0.6s var(--transition-smooth);
}

.app.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-name {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.22em;
    color: var(--text-primary);
}

.header-sep {
    width: 1px;
    height: 14px;
    background: var(--text-muted);
    opacity: 0.4;
}

.header-title {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--transition-smooth);
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
}

/* ============================================================
   BOOK AREA
   ============================================================ */
.book-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 0 var(--nav-width);
}

/* Navigation Buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s var(--transition-smooth);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
}

.book-area:hover .nav-btn,
.nav-btn:focus-visible {
    opacity: 1;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    transform: translateY(-50%) scale(1.08);
}

.nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.nav-prev {
    left: 16px;
}

.nav-next {
    right: 16px;
}

.nav-btn.disabled {
    opacity: 0 !important;
    pointer-events: none;
}

/* Book Container */
.book-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 1400px;
}

/* StPageFlip container */
#book {
    position: relative;
}

/* ---- Page Styling ---- */
.page {
    background: #f5f3ef;
    overflow: hidden;
    position: relative;
}

.page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

/* Hard cover pages get a subtle border */
.page[data-density="hard"] {
    background: #f5f3ef;
}

/* ---- StPageFlip overrides ---- */
.stf__wrapper {
    /* Premium book shadow */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3))
            drop-shadow(0 16px 32px rgba(0, 0, 0, 0.3))
            drop-shadow(0 32px 64px rgba(0, 0, 0, 0.25));
}

/* Book spine / center shadow — soft inward shadow for realism */
/* .book-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: calc(100% - 60px);
    max-height: 85%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 0, 0, 0.03) 25%,
        rgba(0, 0, 0, 0.10) 45%,
        rgba(0, 0, 0, 0.14) 50%,
        rgba(0, 0, 0, 0.10) 55%,
        rgba(0, 0, 0, 0.03) 75%,
        transparent 100%
    );
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s var(--transition-smooth);
} */

.book-container.show-spine::after {
    opacity: 1;
}

/* Hide spine during active flipping */
.book-container.is-flipping::after {
    opacity: 0 !important;
    transition: opacity 0.15s;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.35rem;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    padding: 0 2rem;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#page-display {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: center;
}

.progress-track {
    width: 120px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 1px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent);
    transition: width 0.5s var(--transition-smooth);
    border-radius: 1px;
}

.hint {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    opacity: 1;
    transition: opacity 2s var(--transition-smooth);
}

.hint.fade {
    opacity: 0;
}

.hint-mobile {
    display: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --header-height: 48px;
        --footer-height: 44px;
        --nav-width: 10px;
    }

    .header {
        padding: 0 1rem;
    }

    .header-title {
        display: none;
    }

    .header-sep {
        display: none;
    }

    .header-name {
        font-size: 0.8rem;
        letter-spacing: 0.18em;
    }

    .book-area {
        padding: 0 8px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
        opacity: 0.6;
    }

    .nav-prev {
        left: 4px;
    }

    .nav-next {
        right: 4px;
    }

    .book-area:hover .nav-btn {
        opacity: 0.8;
    }

    .hint-desktop {
        display: none;
    }

    .hint-mobile {
        display: inline;
    }

    .progress-track {
        width: 80px;
    }

    .book-container::after {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-name {
        font-size: 0.72rem;
        letter-spacing: 0.14em;
    }

    .nav-btn {
        width: 36px;
        height: 36px;
    }

    .nav-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* ============================================================
   ANIMATIONS & UTILITIES
   ============================================================ */

/* Entry animation for the book */
@keyframes bookEntry {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.book-container.animate-in .stf__wrapper {
    animation: bookEntry 0.8s var(--transition-smooth) both;
    animation-delay: 0.2s;
}

/* Fullscreen styling */
body.is-fullscreen .header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(8, 8, 8, 0.8) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

body.is-fullscreen .footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(8, 8, 8, 0.8) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

body.is-fullscreen .header:hover,
body.is-fullscreen .footer:hover {
    opacity: 1;
}

body.is-fullscreen .book-area {
    height: 100vh;
}

/* Scrollbar (hidden) */
::-webkit-scrollbar {
    display: none;
}

/* Focus styles */
*:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--accent-dim);
    color: var(--text-primary);
}
