/* ============================================
   VAN GOGH — REAL OPEN BOOK
   Two-page spread with 3D page flip
   ============================================ */

:root {
    --pw: clamp(180px, 42vw, 450px);
    --ph: clamp(300px, 78vh, 660px);
    --cover-gold: #c9a84c;
    --cover-gold-light: #e8d491;
    --page-cream: #f5f0e1;
    --page-cream-dark: #e8dcc8;
    --text-dark: #2c2416;
    --text-brown: #4a3728;
    --text-muted: #7a6a5a;
    --accent-blue: #2a4a7f;
    --accent-gold: #b8942e;
    --flip-time: 1s;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; overflow: hidden; }

/* ============================================
   LOADER
   ============================================ */
.loader {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    background: #080810;
    background-image:
        radial-gradient(ellipse at 30% 40%, rgba(26,26,60,0.8) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(42,74,127,0.25) 0%, transparent 55%);
    transition: opacity 0.8s ease, visibility 0.8s ease;
}
.loader.loader-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Floating stars */
.loader-stars {
    position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.loader-star {
    position: absolute;
    width: 3px; height: 3px;
    background: var(--cover-gold-light);
    border-radius: 50%;
    opacity: 0;
    animation: loaderStarFloat 2.5s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.3s);
}
.loader-star:nth-child(1) { top: 15%; left: 20%; }
.loader-star:nth-child(2) { top: 25%; left: 75%; width: 4px; height: 4px; }
.loader-star:nth-child(3) { top: 60%; left: 10%; }
.loader-star:nth-child(4) { top: 70%; left: 85%; width: 2px; height: 2px; }
.loader-star:nth-child(5) { top: 40%; left: 50%; width: 4px; height: 4px; }
.loader-star:nth-child(6) { top: 80%; left: 35%; }
.loader-star:nth-child(7) { top: 10%; left: 55%; width: 2px; height: 2px; }
.loader-star:nth-child(8) { top: 50%; left: 90%; }

@keyframes loaderStarFloat {
    0%   { opacity: 0; transform: translateY(10px) scale(0.5); }
    40%  { opacity: 1; transform: translateY(-5px) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.3); }
}

/* Swirling rings (Starry Night inspired) */
.loader-swirl {
    width: 120px; height: 120px; margin-bottom: 28px;
    position: relative;
}
.loader-svg {
    width: 100%; height: 100%;
    animation: loaderSwirlRotate 3s linear infinite;
}
.loader-ring {
    fill: none;
    stroke: var(--cover-gold);
    stroke-width: 1.5;
    stroke-dasharray: 60 190;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    opacity: 0.7;
    animation: loaderDash 2s ease-in-out infinite;
}
.loader-ring-2 {
    stroke: rgba(42,74,127,0.6);
    stroke-dasharray: 40 150;
    animation: loaderDash 2s ease-in-out infinite reverse;
    animation-delay: -0.5s;
}
@keyframes loaderSwirlRotate {
    to { transform: rotate(360deg); }
}
@keyframes loaderDash {
    0%   { stroke-dashoffset: 0; }
    50%  { stroke-dashoffset: -100; }
    100% { stroke-dashoffset: -250; }
}

/* Letter-by-letter reveal */
.loader-text {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 6vw, 3.2rem);
    font-weight: 900;
    letter-spacing: 6px;
    background: linear-gradient(135deg, var(--cover-gold), var(--cover-gold-light), var(--cover-gold));
    background-size: 200% 200%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s ease-in-out infinite;
}
.loader-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(15px);
    animation: loaderLetterIn 0.5s ease forwards;
    animation-delay: calc(var(--d) * 0.1s + 0.3s);
}
@keyframes loaderLetterIn {
    to { opacity: 1; transform: translateY(0); }
}

.loader-sub {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    font-style: italic;
    color: rgba(232,212,145,0.5);
    letter-spacing: 8px;
    margin-top: 6px;
    opacity: 0;
    animation: loaderFadeIn 0.8s ease 1s forwards;
}
@keyframes loaderFadeIn {
    to { opacity: 1; }
}

/* Progress line */
.loader-line {
    width: clamp(120px, 30vw, 200px);
    height: 2px;
    background: rgba(201,168,76,0.15);
    border-radius: 2px;
    margin-top: 32px;
    overflow: hidden;
}
.loader-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cover-gold), var(--cover-gold-light));
    border-radius: 2px;
    animation: loaderProgress 2.6s cubic-bezier(0.4,0,0.2,1) 0.4s forwards;
}
@keyframes loaderProgress {
    to { width: 100%; }
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #080810;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(26,26,46,0.7) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(42,74,127,0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(201,168,76,0.08) 0%, transparent 50%);
    font-family: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
    color: var(--text-dark);
    overflow: hidden;
    user-select: none;
}

/* ============================================
   PARTICLES
   ============================================ */
#particles {
    position: fixed; inset: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
}

/* ============================================
   UI CONTROLS
   ============================================ */
.lang-switcher {
    position: fixed; top: 16px; right: 20px; z-index: 200;
    display: flex; align-items: center; gap: 8px;
    background: rgba(20,20,35,0.85); backdrop-filter: blur(12px);
    padding: 7px 14px; border-radius: 30px;
    border: 1px solid rgba(201,168,76,0.25);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.lang-btn {
    background: none; border: none;
    color: rgba(201,168,76,0.45); font-family: 'Playfair Display', serif;
    font-size: 0.8rem; font-weight: 700; letter-spacing: 2px;
    cursor: pointer; padding: 4px 8px; border-radius: 4px;
    transition: all 0.3s ease;
}
.lang-btn:hover { color: var(--cover-gold-light); }
.lang-btn.active { color: var(--cover-gold); background: rgba(201,168,76,0.15); }
.lang-divider { color: rgba(201,168,76,0.25); font-size: 0.8rem; }

.nav-hint {
    position: fixed; top: 50%; transform: translateY(-50%); z-index: 200;
    color: rgba(201,168,76,0.4); cursor: pointer;
    transition: all 0.3s ease; padding: 16px; border-radius: 50%;
    background: rgba(20,20,35,0.5); backdrop-filter: blur(6px);
    border: 1px solid rgba(201,168,76,0.12);
}
.nav-hint:hover {
    color: var(--cover-gold); background: rgba(20,20,35,0.75);
    border-color: rgba(201,168,76,0.35);
    transform: translateY(-50%) scale(1.1);
}
.nav-hint:active { transform: translateY(-50%) scale(0.95); }
.nav-hint-left { left: 12px; }
.nav-hint-right { right: 12px; }
.nav-hint.hidden { opacity: 0; pointer-events: none; }

.page-counter {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    z-index: 200; color: rgba(201,168,76,0.55);
    font-family: 'Playfair Display', serif; font-size: 0.8rem;
    letter-spacing: 3px; background: rgba(20,20,35,0.7);
    backdrop-filter: blur(8px); padding: 7px 18px; border-radius: 20px;
    border: 1px solid rgba(201,168,76,0.15);
    transition: opacity 0.3s;
}

/* ============================================
   THE BOOK
   ============================================ */
.book-scene {
    perspective: 2200px;
    z-index: 10;
    position: relative;
    animation: bookAppear 1.2s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes bookAppear {
    from { opacity: 0; transform: scale(0.9) rotateX(3deg); }
    to   { opacity: 1; transform: scale(1) rotateX(0); }
}

.book {
    width: calc(var(--pw) * 2);
    height: var(--ph);
    position: relative;
    transform-style: preserve-3d;
    border-radius: 6px;
    box-shadow:
        0 15px 50px rgba(0,0,0,0.5),
        0 5px 15px rgba(0,0,0,0.3);
    transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   BOOK BACKGROUNDS (behind all sheets)
   ============================================ */
.book-bg {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.book-bg-left {
    left: 0;
    background: linear-gradient(135deg, #14142a 0%, #1a1a35 50%, #12122a 100%);
    border-radius: 6px 0 0 6px;
    border: 2px solid rgba(201,168,76,0.2);
    border-right: none;
}
.book-bg-right {
    right: 0;
    background: linear-gradient(225deg, #14142a 0%, #1a1a35 50%, #12122a 100%);
    border-radius: 0 6px 6px 0;
    border: 2px solid rgba(201,168,76,0.2);
    border-left: none;
}
.bg-inner {
    display: flex; justify-content: center; align-items: center;
    width: 100%; height: 100%;
}
.bg-ornament {
    color: rgba(201,168,76,0.12);
    font-size: 2.5rem;
}

/* ============================================
   SPINE
   ============================================ */
.book-spine {
    position: absolute;
    left: calc(50% - 4px);
    top: 0;
    width: 8px;
    height: 100%;
    z-index: 100;
    background: linear-gradient(90deg,
        rgba(0,0,0,0.35),
        rgba(0,0,0,0.05) 30%,
        rgba(255,255,255,0.03) 50%,
        rgba(0,0,0,0.05) 70%,
        rgba(0,0,0,0.35)
    );
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* ============================================
   BOOK CLOSED STATES (cover / back cover)
   Book shifts to center the visible single page.
   ============================================ */
.book.book-closed-start {
    transform: translateX(-25%);
}
.book.book-closed-start .book-bg-left {
    opacity: 0;
    visibility: hidden;
}
.book.book-closed-start .book-spine {
    opacity: 0;
}
.book.book-closed-start .page-cover {
    border-left: 2px solid var(--cover-gold);
    border-radius: 6px;
}
.book.book-closed-start .page-cover::after {
    display: block;
}

.book.book-closed-end {
    transform: translateX(25%);
}
.book.book-closed-end .book-bg-right {
    opacity: 0;
    visibility: hidden;
}
.book.book-closed-end .book-spine {
    opacity: 0;
}
.book.book-closed-end .page-final {
    border-radius: 6px;
}

/* ============================================
   SHEET (one physical leaf of the book)
   Each sheet sits on the RIGHT half,
   and rotates around the LEFT edge (spine).
   When flipped: rotateY(-180deg) → shows on LEFT half.
   ============================================ */
.sheet {
    position: absolute;
    width: 50%;
    height: 100%;
    top: 0;
    left: 50%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform var(--flip-time) cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
}

.sheet.flipped {
    transform: rotateY(-180deg);
}

/* ============================================
   SHEET FACES
   ============================================ */
.sheet-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}

.sheet-front {
    /* Faces right when unflipped */
    z-index: 1;
    border-radius: 0 6px 6px 0;
}

.sheet-back {
    /* Faces left when flipped */
    transform: rotateY(180deg);
    z-index: 1;
    border-radius: 6px 0 0 6px;
}

/* Page edge illusion on right side */
.sheet-front::after {
    content: '';
    position: absolute;
    top: 4px; bottom: 4px; right: -5px;
    width: 7px;
    background: linear-gradient(90deg,
        var(--page-cream-dark) 0px, var(--page-cream) 1px,
        var(--page-cream-dark) 2px, var(--page-cream) 3px,
        var(--page-cream-dark) 4px, #d5cbb5 7px
    );
    border-radius: 0 3px 3px 0;
    box-shadow: 2px 0 5px rgba(0,0,0,0.12);
    z-index: 10;
}

/* Page edge illusion on left side */
.sheet-back::after {
    content: '';
    position: absolute;
    top: 4px; bottom: 4px; left: -5px;
    width: 7px;
    background: linear-gradient(270deg,
        var(--page-cream-dark) 0px, var(--page-cream) 1px,
        var(--page-cream-dark) 2px, var(--page-cream) 3px,
        var(--page-cream-dark) 4px, #d5cbb5 7px
    );
    border-radius: 3px 0 0 3px;
    box-shadow: -2px 0 5px rgba(0,0,0,0.12);
    z-index: 10;
}

/* Spine shadows on pages */
.spine-shadow-left {
    position: absolute; top: 0; left: 0;
    width: 35px; height: 100%;
    background: linear-gradient(90deg, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.03) 50%, transparent 100%);
    z-index: 5; pointer-events: none;
}
.spine-shadow-right {
    position: absolute; top: 0; right: 0;
    width: 35px; height: 100%;
    background: linear-gradient(270deg, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.03) 50%, transparent 100%);
    z-index: 5; pointer-events: none;
}

/* Page numbers */
.page-num {
    position: absolute;
    bottom: 16px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    z-index: 6;
    opacity: 0.6;
}
.page-num-right { right: 24px; }
.page-num-left { left: 24px; }

/* ============================================
   COVER PAGE (Sheet 0 Front)
   ============================================ */
.page-cover {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    display: flex; justify-content: center; align-items: center;
    border: 2px solid var(--cover-gold);
    border-left: none;
    border-radius: 0 6px 6px 0;
}
.page-cover::after { display: none; } /* no page-edge on cover */

.cover-texture {
    position: absolute; inset: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(201,168,76,0.015) 2px, rgba(201,168,76,0.015) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(201,168,76,0.015) 2px, rgba(201,168,76,0.015) 4px);
    pointer-events: none;
}
.cover-ornament {
    position: absolute; width: 50px; height: 50px;
    border: 2px solid var(--cover-gold); opacity: 0.4;
}
.cover-ornament.tl { top: 16px; left: 16px; border-right: none; border-bottom: none; }
.cover-ornament.tr { top: 16px; right: 16px; border-left: none; border-bottom: none; }
.cover-ornament.bl { bottom: 16px; left: 16px; border-right: none; border-top: none; }
.cover-ornament.br { bottom: 16px; right: 16px; border-left: none; border-top: none; }

.cover-content { text-align: center; z-index: 2; padding: 30px 20px; }
.cover-line {
    width: 160px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--cover-gold), transparent);
    margin: 16px auto;
}
.cover-title { display: flex; flex-direction: column; gap: 2px; }
.cover-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.85rem; font-weight: 300; font-style: italic;
    color: var(--cover-gold-light); letter-spacing: 3px; text-transform: uppercase;
    margin-bottom: 6px;
}
.cover-name {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    font-weight: 900; letter-spacing: 4px; line-height: 1.15;
    background: linear-gradient(135deg, var(--cover-gold), var(--cover-gold-light), var(--cover-gold), var(--cover-gold-light), var(--cover-gold));
    background-size: 200% 200%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 6s ease-in-out infinite;
}
@keyframes shimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.cover-years {
    font-family: 'Cormorant Garamond', serif;
    color: var(--cover-gold-light); font-size: 0.95rem;
    letter-spacing: 6px; margin-top: 6px; opacity: 0.75;
}
.cover-star {
    color: var(--cover-gold); font-size: 1.2rem; margin: 16px 0;
    animation: pulseStar 3s ease-in-out infinite;
}
@keyframes pulseStar {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50%      { opacity: 1; transform: scale(1.2); }
}
.cover-quote {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic; color: var(--cover-gold-light);
    font-size: 0.85rem; max-width: 260px; margin: 0 auto;
    line-height: 1.5; opacity: 0.6;
}

/* ============================================
   PAPER PAGE
   ============================================ */
.page-paper {
    background: var(--page-cream);
}
.page-texture {
    position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none; opacity: 0.5;
}

.page-inner {
    position: relative; z-index: 2;
    padding: 32px 28px;
    height: 100%; display: flex; flex-direction: column;
    overflow-y: auto; scrollbar-width: none;
}
.page-inner::-webkit-scrollbar { display: none; }

/* ============================================
   TYPOGRAPHY
   ============================================ */
.chapter-number {
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem; color: var(--accent-gold);
    letter-spacing: 6px; text-align: center; margin-bottom: 2px;
}
.chapter-marker {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.75rem; color: var(--text-muted);
    letter-spacing: 4px; text-transform: uppercase;
    text-align: center; margin-bottom: 20px;
}
.chapter-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
    font-weight: 700; color: var(--text-dark);
    text-align: center; margin-bottom: 3px; line-height: 1.3;
}
.title-ornament {
    text-align: center; color: var(--accent-gold);
    font-size: 0.85rem; margin-bottom: 16px; letter-spacing: 4px;
}
.decorative-initial {
    font-family: 'Playfair Display', serif;
    font-size: 3.2rem; font-weight: 900; color: var(--accent-blue);
    float: left; line-height: 0.8; margin-right: 8px; margin-top: 3px;
    text-shadow: 2px 2px 0 rgba(42,74,127,0.1);
}
.book-text {
    font-family: 'EB Garamond', serif;
    font-size: clamp(0.82rem, 2vw, 0.95rem);
    line-height: 1.7; color: var(--text-brown);
    margin-bottom: 12px; text-align: justify; hyphens: auto;
}

/* ============================================
   IMAGES
   ============================================ */
.page-image-frame { margin: 12px auto; text-align: center; }
.page-image {
    width: 100%; max-height: clamp(110px, 25vh, 200px);
    object-fit: cover;
    border: 2px solid var(--page-cream-dark);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    border-radius: 2px;
}
.starry-frame .page-image { border-color: var(--accent-blue); }
.image-caption {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic; font-size: 0.78rem;
    color: var(--text-muted); margin-top: 6px; letter-spacing: 1px;
}

/* ============================================
   QUOTES
   ============================================ */
.quote-block {
    margin: 14px 0; padding: 12px 18px;
    background: linear-gradient(135deg, rgba(42,74,127,0.04), rgba(201,168,76,0.04));
    border-left: 3px solid var(--accent-gold);
    border-radius: 0 4px 4px 0;
}
.quote-mark {
    font-family: 'Playfair Display', serif;
    font-size: 2.4rem; color: var(--accent-gold);
    opacity: 0.25; line-height: 1; margin-bottom: -10px;
}
.quote-text {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic; font-size: clamp(0.82rem, 2vw, 0.95rem);
    line-height: 1.6; color: var(--accent-blue);
}
.quote-author {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.78rem; color: var(--text-muted);
    margin-top: 6px; text-align: right;
}
.page-decoration {
    text-align: center; color: var(--accent-gold);
    font-size: 1.1rem; margin-top: auto; padding-top: 12px; opacity: 0.4;
}

/* ============================================
   FINAL / EPILOGUE PAGE
   ============================================ */
.page-final { background: linear-gradient(180deg, var(--page-cream) 0%, #e8dcc8 100%); }
.final-inner { justify-content: center; align-items: center; }
.final-content {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; padding: 10px;
}
.final-star {
    font-size: 1.6rem; color: var(--accent-gold);
    margin-bottom: 16px; animation: pulseStar 3s ease-in-out infinite;
}
.final-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
    font-weight: 700; color: var(--text-dark); margin-bottom: 6px;
}
.final-ornament {
    color: var(--accent-gold); letter-spacing: 6px; margin-bottom: 16px;
}
.final-text {
    font-family: 'EB Garamond', serif;
    font-size: clamp(0.82rem, 2vw, 0.92rem);
    line-height: 1.7; color: var(--text-brown);
    max-width: 320px; margin-bottom: 16px;
}
.final-quote {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic; font-size: clamp(0.8rem, 1.8vw, 0.88rem);
    color: var(--accent-blue); max-width: 300px; line-height: 1.6;
    margin-bottom: 20px; padding: 12px;
    border-top: 1px solid rgba(184,148,46,0.25);
    border-bottom: 1px solid rgba(184,148,46,0.25);
}
.final-signature {
    font-family: 'Playfair Display', serif; font-style: italic;
    font-size: 1.8rem; color: var(--text-dark); opacity: 0.5; margin-bottom: 8px;
}
.final-dates {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.82rem; color: var(--accent-gold); letter-spacing: 5px;
}

.page-starry { background: linear-gradient(180deg, #e8e0d0 0%, var(--page-cream) 30%); }
::selection { background: rgba(201,168,76,0.3); color: var(--text-dark); }

/* ============================================
   RESPONSIVE — TABLET
   ============================================ */
@media (max-width: 900px) {
    :root {
        --pw: clamp(160px, 40vw, 380px);
        --ph: clamp(280px, 75vh, 580px);
    }
    .page-inner { padding: 24px 20px; }
    .cover-ornament { width: 38px; height: 38px; }
    .cover-content { padding: 22px 16px; }
    .nav-hint { padding: 14px; }
}

/* ============================================
   RESPONSIVE — SMALL TABLET / LARGE PHONE LANDSCAPE
   ============================================ */
@media (max-width: 700px) {
    :root {
        --pw: clamp(140px, 42vw, 320px);
        --ph: clamp(260px, 72vh, 500px);
        --flip-time: 0.8s;
    }
    .page-inner { padding: 18px 14px; }
    .book-text { font-size: clamp(0.75rem, 2.2vw, 0.88rem); line-height: 1.6; margin-bottom: 8px; }
    .chapter-title { font-size: clamp(0.95rem, 3.2vw, 1.3rem); }
    .quote-block { padding: 10px 14px; margin: 10px 0; }
    .quote-text { font-size: clamp(0.75rem, 2vw, 0.88rem); }
    .quote-mark { font-size: 2rem; }
    .decorative-initial { font-size: 2.6rem; }
    .cover-ornament { width: 32px; height: 32px; }
    .cover-content { padding: 18px 12px; }
    .cover-name { font-size: clamp(1.3rem, 4.5vw, 2rem); letter-spacing: 3px; }
    .cover-subtitle { font-size: 0.75rem; letter-spacing: 2px; }
    .cover-quote { font-size: 0.78rem; max-width: 200px; }
    .cover-line { width: 120px; margin: 12px auto; }
    .page-image { max-height: clamp(90px, 22vh, 170px); }
    .image-caption { font-size: 0.72rem; }
    .page-decoration { font-size: 0.95rem; padding-top: 8px; }
    .nav-hint { padding: 12px; }
    .nav-hint-left { left: 6px; }
    .nav-hint-right { right: 6px; }
    .nav-hint svg { width: 20px; height: 20px; }
    .lang-switcher { top: 10px; right: 10px; padding: 5px 10px; gap: 6px; }
    .lang-btn { font-size: 0.7rem; padding: 3px 6px; }
    .page-counter { font-size: 0.72rem; padding: 5px 14px; bottom: 14px; }
    .spine-shadow-left, .spine-shadow-right { width: 20px; }
    .book-spine { width: 5px; left: calc(50% - 2.5px); }
    .sheet-front::after, .sheet-back::after { width: 4px; }
    .sheet-front::after { right: -3px; }
    .sheet-back::after { left: -3px; }
}

/* ============================================
   RESPONSIVE — PHONE PORTRAIT
   ============================================ */
@media (max-width: 520px) {
    :root {
        --pw: clamp(130px, 46vw, 240px);
        --ph: clamp(240px, 68vh, 440px);
        --flip-time: 0.7s;
    }
    html { font-size: 15px; }
    body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
    .page-inner { padding: 14px 10px; }
    .book-text { font-size: clamp(0.68rem, 2.5vw, 0.82rem); line-height: 1.55; margin-bottom: 6px; }
    .chapter-number { font-size: 0.78rem; letter-spacing: 4px; }
    .chapter-marker { font-size: 0.65rem; margin-bottom: 12px; }
    .chapter-title { font-size: clamp(0.85rem, 3.5vw, 1.1rem); margin-bottom: 2px; }
    .title-ornament { font-size: 0.75rem; margin-bottom: 10px; letter-spacing: 3px; }
    .decorative-initial { font-size: 2.2rem; margin-right: 6px; }
    .quote-block { padding: 8px 10px; margin: 8px 0; }
    .quote-mark { font-size: 1.6rem; margin-bottom: -8px; }
    .quote-text { font-size: clamp(0.68rem, 2.2vw, 0.82rem); line-height: 1.5; }
    .quote-author { font-size: 0.68rem; }
    .page-image { max-height: clamp(70px, 18vh, 140px); }
    .page-image-frame { margin: 8px auto; }
    .image-caption { font-size: 0.65rem; margin-top: 4px; }
    .cover-ornament { width: 24px; height: 24px; top: 10px !important; }
    .cover-ornament.tl, .cover-ornament.bl { left: 10px !important; }
    .cover-ornament.tr, .cover-ornament.br { right: 10px !important; }
    .cover-ornament.bl, .cover-ornament.br { bottom: 10px !important; }
    .cover-content { padding: 14px 10px; }
    .cover-name { font-size: clamp(1.1rem, 5vw, 1.6rem); letter-spacing: 2px; }
    .cover-subtitle { font-size: 0.68rem; letter-spacing: 2px; }
    .cover-years { font-size: 0.8rem; letter-spacing: 4px; }
    .cover-star { font-size: 1rem; margin: 10px 0; }
    .cover-quote { font-size: 0.7rem; max-width: 170px; line-height: 1.4; }
    .cover-line { width: 90px; margin: 10px auto; }
    .page-num { bottom: 10px; font-size: 0.7rem; }
    .page-num-right { right: 14px; }
    .page-num-left { left: 14px; }
    .nav-hint { padding: 10px; }
    .nav-hint-left { left: 2px; }
    .nav-hint-right { right: 2px; }
    .nav-hint svg { width: 18px; height: 18px; }
    .lang-switcher { top: 6px; right: 6px; padding: 4px 8px; gap: 4px; border-radius: 20px; }
    .lang-btn { font-size: 0.65rem; padding: 2px 5px; letter-spacing: 1px; }
    .lang-divider { font-size: 0.65rem; }
    .page-counter { font-size: 0.65rem; padding: 4px 12px; bottom: 10px; border-radius: 16px; }
    .page-decoration { font-size: 0.85rem; padding-top: 6px; }
    .final-star { font-size: 1.2rem; margin-bottom: 10px; }
    .final-title { font-size: clamp(0.9rem, 3.5vw, 1.2rem); }
    .final-text { font-size: clamp(0.7rem, 2.2vw, 0.82rem); max-width: 250px; margin-bottom: 10px; }
    .final-quote { font-size: clamp(0.68rem, 2vw, 0.78rem); max-width: 220px; padding: 8px; margin-bottom: 14px; }
    .final-signature { font-size: 1.3rem; }
    .final-dates { font-size: 0.72rem; letter-spacing: 3px; }
    .spine-shadow-left, .spine-shadow-right { width: 15px; }
    .book-spine { width: 4px; left: calc(50% - 2px); }
    .sheet-front::after, .sheet-back::after { width: 3px; }
    .sheet-front::after { right: -2px; }
    .sheet-back::after { left: -2px; }
    .book { box-shadow: 0 10px 35px rgba(0,0,0,0.5), 0 3px 10px rgba(0,0,0,0.3); border-radius: 4px; }
    .book-bg-left { border-radius: 4px 0 0 4px; }
    .book-bg-right { border-radius: 0 4px 4px 0; }
    .sheet-front { border-radius: 0 4px 4px 0; }
    .sheet-back { border-radius: 4px 0 0 4px; }
    .page-cover { border-radius: 0 4px 4px 0; }
    .bg-ornament { font-size: 1.8rem; }
    .starry-frame .page-image { border-width: 1px; }
}

/* ============================================
   RESPONSIVE — VERY SMALL PHONE
   ============================================ */
@media (max-width: 380px) {
    :root {
        --pw: clamp(120px, 47vw, 190px);
        --ph: clamp(220px, 65vh, 400px);
    }
    html { font-size: 14px; }
    .page-inner { padding: 10px 8px; }
    .book-text { font-size: 0.68rem; line-height: 1.5; }
    .cover-name { font-size: clamp(0.95rem, 5vw, 1.3rem); }
    .cover-quote { display: none; }
    .cover-star { margin: 6px 0; }
    .nav-hint { padding: 8px; }
    .nav-hint svg { width: 16px; height: 16px; }
    .page-image { max-height: clamp(60px, 16vh, 110px); }
}

/* ============================================
   RESPONSIVE — LANDSCAPE PHONE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --pw: clamp(160px, 30vw, 300px);
        --ph: clamp(200px, 85vh, 380px);
        --flip-time: 0.7s;
    }
    .page-inner { padding: 12px 14px; }
    .book-text { font-size: 0.72rem; line-height: 1.45; margin-bottom: 5px; }
    .chapter-title { font-size: 0.95rem; }
    .quote-block { padding: 6px 10px; margin: 6px 0; }
    .page-image { max-height: clamp(50px, 20vh, 100px); }
    .page-image-frame { margin: 5px auto; }
    .cover-content { padding: 10px 8px; }
    .cover-line { margin: 6px auto; }
    .cover-star { margin: 6px 0; }
    .cover-quote { display: none; }
    .lang-switcher { top: 4px; right: 4px; }
    .page-counter { bottom: 4px; }
    .nav-hint-left { left: 2px; }
    .nav-hint-right { right: 2px; }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .nav-hint {
        padding: 14px;
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .nav-hint:hover {
        transform: translateY(-50%);
    }
    .sheet {
        cursor: default;
    }
    .page-inner {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   PREFERS REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .sheet { transition: transform 0.3s ease; }
    .cover-name { animation: none; background-size: 100% 100%; }
    .cover-star { animation: none; opacity: 0.7; }
    .final-star { animation: none; opacity: 0.7; }
    @keyframes bookAppear { from { opacity: 1; } to { opacity: 1; } }
}
