:root {
    --desk-bg: #1a1a1a;
    --paper-color: #f4ecd8;
    --text-color: #2c2825;
    --text-faded: #5a544e;
    --font-serif: 'EB Garamond', serif;
    --cover-color: #4a1515;
    --gold: #d4af37;
}

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

body {
    background-color: var(--desk-bg);
    font-family: var(--font-serif);
    color: var(--text-color);
    overflow: hidden; /* Zero UI Clutter */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    /* subtle desk texture */
    background-image: radial-gradient(circle at center, #2a2a2a 0%, #0a0a0a 100%);
}

#desk-environment {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.book-container {
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    transition: transform 0.5s ease;
}

#book {
    width: 800px;
    height: 600px;
}

/* Page base */
.page {
    background-color: var(--paper-color);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* Hard cover styles */
.page-cover {
    background-color: var(--cover-color);
}

.page-content {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Front Cover Image */
.cover-front {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Endpapers (inside cover) */
.endpaper {
    width: 100%;
    height: 100%;
    background-color: #3d2c23;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.1) 10px, rgba(0,0,0,0.1) 20px);
}

/* Paper Texture */
.paper-texture {
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.05"/></svg>');
    padding: 40px 50px;
    display: flex;
    flex-direction: column;
}

.flex-center {
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Typography */
h1 {
    font-size: 3rem;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 2px;
}
.subtitle {
    font-size: 1.5rem;
    font-style: italic;
    color: var(--text-faded);
    margin-bottom: 40px;
}
.author {
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.dedication {
    font-style: italic;
    font-size: 1.2rem;
}

h2 {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 10px;
}

.chapter-title {
    text-align: left;
    border: none;
    margin-bottom: 30px;
}

p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 15px;
    text-align: justify;
}

.dropcap {
    float: left;
    font-size: 3.5rem;
    line-height: 0.8;
    padding-right: 8px;
    padding-top: 6px;
}

.inline-text {
    display: inline;
}

.footnote {
    margin-top: auto;
    border-top: 1px solid var(--text-faded);
    padding-top: 10px;
}

.footnote p {
    font-size: 0.85rem;
    color: var(--text-faded);
    margin: 0;
}

/* Illustrations */
.illustration-container {
    width: 100%;
    height: 80%;
    border: 2px solid var(--text-color);
    padding: 5px;
    position: relative; /* Crucial for positioning secret zones */
}

.book-illustration {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(0.3) contrast(1.1);
}

.caption {
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
    margin-top: 15px;
    color: var(--text-faded);
}

/* -------------------------------------
   SUBMERGED LAYER
------------------------------------- */

.secret-zone {
    position: absolute;
    cursor: pointer;
    /* Invisible by default, reveals on hover or active */
    background: transparent;
    transition: background 0.3s ease;
    z-index: 10;
}

/* Subtle pulse on hover to indicate a secret */
.secret-zone:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    border-radius: 50%;
}

/* Specific secret coordinates over the illustration */
#secret-cottage {
    top: 50%;
    left: 60%;
    width: 40px;
    height: 40px;
}

#secret-tree {
    top: 30%;
    left: 20%;
    width: 60px;
    height: 60px;
}

/* Margin doodle secret */
.margin-doodle {
    position: absolute;
    right: 15px;
    top: 40%;
    font-size: 1.5rem;
    opacity: 0.3;
}
.margin-doodle:hover {
    opacity: 1;
}

/* Overlay Engine */
#overlay-engine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none; /* Let clicks pass through when hidden */
}

#overlay-engine:not(.hidden) {
    pointer-events: auto;
}

.overlay-backdrop {
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

#overlay-engine:not(.hidden) .overlay-backdrop {
    opacity: 1;
}

/* Ribbon Bookmark */
.ribbon-bookmark {
    position: absolute;
    top: -100px;
    right: 150px;
    width: 30px;
    height: 150px;
    background: var(--cover-color);
    box-shadow: 2px 2px 10px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 101;
}

.ribbon-bookmark::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    border-left: 15px solid var(--cover-color);
    border-right: 15px solid var(--cover-color);
    border-bottom: 15px solid transparent;
}

#overlay-engine:not(.hidden) .ribbon-bookmark {
    top: -10px; /* drops down */
}

.ribbon-bookmark:hover {
    top: 0px !important;
}

/* Overlay Content (Parchments, etc) */
#overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
    transition: all 0.4s ease;
}

#overlay-engine:not(.hidden) #overlay-content {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.tactile-surface {
    background: var(--paper-color);
    padding: 40px;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    max-width: 400px;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.05"/></svg>');
    border: 1px solid rgba(0,0,0,0.1);
}

.tactile-surface h3 {
    margin-bottom: 15px;
    font-size: 1.5rem;
    border-bottom: 1px solid var(--text-faded);
    padding-bottom: 5px;
}

.hidden {
    visibility: hidden;
}
