/* ============================================
   Menu Simulation - Write Your Journey
   ============================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-bg: #1a1410;
    --color-leather: #4a3728;
    --color-leather-dark: #2a1f15;
    --color-leather-light: #5c4633;
    --color-parchment: #d2c4a0;
    --color-parchment-light: #e8dcc0;
    --color-parchment-dark: #b8a880;
    --color-gold: #c9a961;
    --color-gold-bright: #e8c968;
    --color-text: #e8dcc0;
    --color-text-muted: #a89878;
    --color-ink: #30261e;
    --color-red: #8b2500;
    --color-sepia: #6b4423;
    
    --font-display: 'Rye', cursive;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Lora', serif;
    --font-handwriting: 'Lora', cursive;
}

html, body {
    height: 100%;
    overflow: hidden;
}

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

/* ============================================
   Menu Selector
   ============================================ */
.menu-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: 
        radial-gradient(ellipse at center, rgba(74, 55, 40, 0.3) 0%, transparent 70%),
        linear-gradient(180deg, #1a1410 0%, #2a1f15 50%, #1a1410 100%);
    padding: 40px;
}

.selector-title {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--color-parchment-light);
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
}

.selector-subtitle {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--color-text-muted);
    font-style: italic;
    margin-bottom: 50px;
}

.menu-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    max-width: 700px;
    margin-bottom: 50px;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 30px 40px;
    background: linear-gradient(135deg, var(--color-leather), var(--color-leather-dark));
    border: 2px solid var(--color-gold);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-body);
    color: var(--color-text);
}

.menu-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    border-color: var(--color-gold-bright);
    background: linear-gradient(135deg, var(--color-leather-light), var(--color-leather));
}

.btn-icon {
    font-size: 2.5rem;
    color: var(--color-gold);
}

.btn-text {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-parchment);
}

.btn-desc {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.back-link {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--color-gold);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 12px 30px;
    border: 1px solid var(--color-gold);
    transition: all 0.3s ease;
}

.back-link:hover {
    background: var(--color-gold);
    color: var(--color-bg);
}

/* ============================================
   Simulation Common
   ============================================ */
.simulation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--color-bg);
}

.sim-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 30px;
    background: rgba(26, 20, 16, 0.95);
    border-bottom: 1px solid var(--color-leather);
}

.sim-header h2 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.controls-hint {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.controls-hint span {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

kbd {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-leather);
    border: 1px solid var(--color-leather-light);
    border-radius: 3px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--color-parchment);
    margin: 0 2px;
}

.exit-btn {
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--color-red);
    color: var(--color-red);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.exit-btn:hover {
    background: var(--color-red);
    color: var(--color-parchment);
}

/* ============================================
   Journal Simulation
   ============================================ */
.journal-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    perspective: 1200px;
}

/* Cover */
.journal-cover {
    position: relative;
    width: 400px;
    height: 560px;
    background: linear-gradient(135deg, #5c3a1e 0%, #3d2614 50%, #2a1a0e 100%);
    border-radius: 4px 12px 12px 4px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.7),
        inset 0 0 40px rgba(0, 0, 0, 0.3),
        -5px 0 15px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: coverAppear 0.8s ease-out;
}

@keyframes coverAppear {
    from { opacity: 0; transform: scale(0.9) rotateY(-10deg); }
    to { opacity: 1; transform: scale(1) rotateY(0deg); }
}

.cover-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
    border-radius: 4px 12px 12px 4px;
    pointer-events: none;
}

.cover-content {
    text-align: center;
    padding: 40px;
    position: relative;
    z-index: 1;
}

.cover-ornament {
    width: 200px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
    margin: 20px auto;
}

.cover-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--color-gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin: 20px 0;
}

.cover-divider {
    width: 100px;
    height: 2px;
    background: var(--color-gold);
    margin: 15px auto;
    opacity: 0.6;
}

.cover-subtitle {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--color-parchment-dark);
    letter-spacing: 4px;
}

.cover-prompt {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-style: italic;
    margin-top: 40px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Open Journal */
.journal-open {
    display: flex;
    gap: 0;
    animation: bookOpen 0.6s ease-out;
    position: relative;
}

@keyframes bookOpen {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.journal-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 20px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #3d2614, #2a1a0e, #3d2614);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.journal-page {
    width: 380px;
    height: 520px;
    background: linear-gradient(135deg, var(--color-parchment-light) 0%, var(--color-parchment) 50%, var(--color-parchment-dark) 100%);
    position: relative;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 0 30px rgba(139, 69, 19, 0.1);
}

.left-page {
    border-radius: 4px 0 0 4px;
    border-right: 1px solid rgba(139, 69, 19, 0.3);
}

.right-page {
    border-radius: 0 4px 4px 0;
    border-left: 1px solid rgba(139, 69, 19, 0.3);
}

.page-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 40px 35px;
    overflow: hidden;
}

.page-number {
    position: absolute;
    bottom: 15px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--color-sepia);
    opacity: 0.5;
}

.left-page .page-number {
    left: 35px;
}

.right-page .page-number {
    right: 35px;
}

.page-text {
    font-family: var(--font-handwriting);
    font-size: 0.95rem;
    color: var(--color-ink);
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    height: 100%;
    overflow-y: auto;
    position: relative;
    z-index: 2;
}

.page-text::-webkit-scrollbar {
    width: 4px;
}

.page-text::-webkit-scrollbar-thumb {
    background: var(--color-sepia);
    border-radius: 2px;
    opacity: 0.3;
}

.page-textarea {
    position: absolute;
    top: 40px;
    left: 35px;
    right: 35px;
    bottom: 40px;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-handwriting);
    font-size: 0.95rem;
    color: var(--color-ink);
    line-height: 1.8;
}

.page-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.page-canvas.drawing-active {
    pointer-events: auto;
    cursor: crosshair;
}

/* Journal Help */
.journal-help {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    background: rgba(26, 20, 16, 0.8);
    padding: 10px 25px;
    border-radius: 4px;
    border: 1px solid var(--color-leather);
}

/* Night tint overlay */
.journal-open::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(60, 55, 45, 0.08);
    pointer-events: none;
    border-radius: 4px;
}

/* ============================================
   CustomBooks Simulation
   ============================================ */
.custombooks-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding-top: 80px;
}

.books-inventory {
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.inventory-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    color: var(--color-parchment-light);
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 40px;
}

.books-carousel {
    display: flex;
    align-items: center;
    gap: 40px;
}

.carousel-btn {
    width: 50px;
    height: 50px;
    background: var(--color-leather);
    border: 2px solid var(--color-gold);
    color: var(--color-gold);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-btn:hover {
    background: var(--color-gold);
    color: var(--color-bg);
}

.book-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.book-3d {
    position: relative;
    width: 250px;
    height: 350px;
    perspective: 800px;
}

.book-3d .book-spine {
    position: absolute;
    left: -20px;
    top: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(90deg, #3d2010, #5c3a1e, #3d2010);
    border-radius: 4px 0 0 4px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.4);
    transform: rotateY(-20deg);
    transform-origin: right center;
}

.book-3d .book-cover {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #5c3a1e 0%, #3d2010 100%);
    border-radius: 0 6px 6px 0;
    border: 3px solid var(--color-gold);
    box-shadow: 
        10px 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.book-3d:hover .book-cover {
    transform: rotateY(-5deg);
}

.book-cover-content {
    text-align: center;
    padding: 30px;
}

.book-cover-content .book-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--color-gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
}

.book-cover-content .book-author {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--color-parchment);
    font-style: italic;
    margin-bottom: 10px;
}

.book-cover-content .book-year {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--color-parchment-dark);
    letter-spacing: 3px;
}

.book-info {
    text-align: center;
}

.book-category {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.book-counter {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.inventory-help {
    margin-top: 40px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    background: rgba(26, 20, 16, 0.8);
    padding: 10px 25px;
    border-radius: 4px;
    display: inline-block;
}

/* Book Open View */
.book-open {
    display: flex;
    gap: 0;
    animation: bookOpen 0.6s ease-out;
    position: relative;
}

.book-page {
    width: 380px;
    height: 520px;
    background: linear-gradient(135deg, var(--color-parchment-light) 0%, var(--color-parchment) 50%, var(--color-parchment-dark) 100%);
    position: relative;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 0 30px rgba(139, 69, 19, 0.1);
}

.book-page .page-content {
    padding: 35px 30px;
}

.book-page .page-text {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-sepia);
    line-height: 1.7;
}

.book-nav-help {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    background: rgba(26, 20, 16, 0.8);
    padding: 10px 25px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ============================================
   Letters Simulation
   ============================================ */
.letters-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding-top: 80px;
    background: rgba(0, 0, 0, 0.5);
}

.envelope-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    animation: fadeIn 0.5s ease-out;
}

.envelope {
    position: relative;
    width: 550px;
    height: 340px;
}

.envelope-body {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-parchment-light) 0%, var(--color-parchment) 100%);
    border: 2px solid var(--color-parchment-dark);
    border-radius: 4px;
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(139, 69, 19, 0.1);
    position: relative;
    overflow: hidden;
}

.envelope-flap {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    height: 100px;
    background: linear-gradient(180deg, var(--color-parchment), var(--color-parchment-light));
    clip-path: polygon(0 0, 50% 80%, 100% 0);
    border: 2px solid var(--color-parchment-dark);
    z-index: 5;
}

.envelope-stamp {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 60px;
    height: 70px;
    background: var(--color-red);
    border: 3px dashed var(--color-parchment);
    border-radius: 2px;
    z-index: 3;
}

.envelope-fields {
    position: absolute;
    bottom: 60px;
    left: 40px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.field-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.field-group label {
    font-family: var(--font-handwriting);
    font-size: 1.1rem;
    color: var(--color-ink);
    font-style: italic;
    min-width: 50px;
}

.field-group input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-sepia);
    font-family: var(--font-handwriting);
    font-size: 1rem;
    color: var(--color-ink);
    padding: 5px 10px;
    width: 250px;
    outline: none;
}

.field-group input:focus {
    border-bottom-color: var(--color-gold);
    background: rgba(255, 255, 240, 0.3);
}

.envelope-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.envelope-canvas.drawing-active {
    pointer-events: auto;
    cursor: crosshair;
}

.envelope-help {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    background: rgba(26, 20, 16, 0.8);
    padding: 10px 25px;
    border-radius: 4px;
}

/* ============================================
   Sheet Overlay Simulation
   ============================================ */
.sheet-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
}

.sheet-overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.sheet-paper {
    position: relative;
    width: 500px;
    height: 700px;
    z-index: 10;
    animation: sheetAppear 0.5s ease-out;
}

@keyframes sheetAppear {
    from { opacity: 0; transform: translateY(30px) rotate(-2deg); }
    to { opacity: 1; transform: translateY(0) rotate(0deg); }
}

.sheet-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--color-parchment-light) 0%, var(--color-parchment) 50%, var(--color-parchment-dark) 100%);
    clip-path: polygon(
        0% 2%, 3% 0%, 8% 1%, 15% 0%, 22% 1.5%, 30% 0%, 38% 1%, 45% 0.5%, 52% 0%, 60% 1.5%, 68% 0%, 75% 1%, 82% 0%, 90% 0.5%, 95% 0%, 100% 1.5%,
        100% 5%, 99% 12%, 100% 20%, 99.5% 28%, 100% 35%, 99% 42%, 100% 50%, 99.5% 58%, 100% 65%, 99% 72%, 100% 80%, 99.5% 88%, 100% 95%,
        100% 98%, 97% 100%, 90% 99%, 82% 100%, 75% 99.5%, 68% 100%, 60% 99%, 52% 100%, 45% 99.5%, 38% 100%, 30% 99%, 22% 100%, 15% 99.5%, 8% 100%, 3% 99.5%, 0% 100%,
        0% 95%, 0.5% 88%, 0% 80%, 1% 72%, 0% 65%, 0.5% 58%, 0% 50%, 1% 42%, 0% 35%, 0.5% 28%, 0% 20%, 1% 12%, 0% 5%
    );
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.sheet-content {
    position: relative;
    z-index: 1;
    padding: 50px 40px;
    height: 100%;
    overflow: hidden;
}

.sheet-text {
    font-family: var(--font-handwriting);
    font-size: 0.95rem;
    color: var(--color-ink);
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.sheet-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sheet-help {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    background: rgba(26, 20, 16, 0.8);
    padding: 10px 25px;
    border-radius: 4px;
    z-index: 20;
    white-space: nowrap;
}

/* ============================================
   Mode Indicator
   ============================================ */
.mode-indicator {
    position: absolute;
    top: 90px;
    right: 30px;
    padding: 8px 20px;
    background: var(--color-leather);
    border: 1px solid var(--color-gold);
    border-radius: 4px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 50;
    display: none;
}

.mode-indicator.visible {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    .menu-buttons {
        grid-template-columns: 1fr;
    }
    
    .journal-page, .book-page {
        width: 280px;
        height: 400px;
    }
    
    .journal-cover {
        width: 300px;
        height: 420px;
    }
    
    .envelope {
        width: 400px;
        height: 260px;
    }
    
    .sheet-paper {
        width: 350px;
        height: 500px;
    }
    
    .controls-hint {
        display: none;
    }
}
