/* 
   THE COVERT DISCOVERY - ARCHITECTURE STYLES
   Focus: Pure Reader illusion on the surface. Hidden interactions beneath.
*/

:root {
    /* Pure Book Colors */
    --book-bg: #eaddc5;
    --page-bg: #fdfaf6;
    --text-main: #2b2824;
    --text-muted: #68635b;
    --ink-accent: #8b2626; /* Used very sparingly, looks like dried ink */
    
    /* Typography */
    --font-prose: 'Crimson Text', serif;
    --font-heading: 'Cinzel', serif;
    --font-handwriting: 'Caveat', cursive;
    
    /* Dimensions */
    --book-width: 900px;
    --book-height: 600px;
    
    /* Polymorphic Surface */
    --surface-overlay: rgba(10, 8, 5, 0.7);
    --card-bg: #f4ebd8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* Remove mobile tap highlight */
}

body {
    background-color: var(--book-bg);
    /* Subtle texture for the desk/background */
    background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png');
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: var(--font-prose);
    color: var(--text-main);
    overflow: hidden;
}

/* ==========================================================================
   THE SURFACE LAYER (PURE BOOK)
   ========================================================================== */

.book-container {
    position: relative;
    /* Drop shadow to make the book feel physical */
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 10px rgba(0,0,0,0.2);
    border-radius: 4px;
}

.flip-book {
    width: var(--book-width);
    height: var(--book-height);
    display: none; /* Managed by stpageflip */
}

/* Page Structure */
.page {
    background-color: var(--page-bg);
    background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png');
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05); /* Vignette for paper depth */
    overflow: hidden;
    position: relative;
}

/* Cover Styling */
.page-cover {
    background-color: #2c1e16; /* Dark leather look */
    background-image: url('https://www.transparenttextures.com/patterns/leather.png');
    color: #d4af37; /* Gold foil */
}

.page-cover-top {
    border-radius: 4px 12px 12px 4px;
    box-shadow: inset -5px 0 20px rgba(0,0,0,0.4);
}

.page-cover-top .page-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
    border: 2px solid rgba(212, 175, 55, 0.3); /* Gold border */
    margin: 20px;
}

.page-cover-top h1 {
    font-family: var(--font-heading);
    font-size: 3rem;
    letter-spacing: 0.1em;
    margin: 1rem 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.page-cover-top h2, .page-cover-top h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    opacity: 0.8;
}

/* Internal Pages */
.page-content {
    padding: 40px 50px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

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

.title-page-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.title-page-author {
    font-size: 1.2rem;
    font-style: italic;
    color: var(--text-muted);
}

/* Typography & Prose */
.text-content {
    font-size: 1.15rem;
    line-height: 1.7;
}

.chapter-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0.5rem;
    margin-top: 2rem;
}

.chapter-subtitle {
    text-align: center;
    font-style: italic;
    font-weight: normal;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.prose {
    margin-bottom: 1.2rem;
    text-indent: 2rem; /* Classic book indent */
    text-align: justify;
}

.prose:first-of-type {
    text-indent: 0; /* No indent on first paragraph */
}

/* Footnotes */
.footnotes {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footnotes hr {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.1);
    width: 30%;
    margin-bottom: 0.5rem;
}

.page-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Illustrations */
.illustration-container {
    margin: 1.5rem 0;
    position: relative;
}

.placeholder-illustration {
    width: 100%;
    height: 200px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 2px;
}

.caption {
    text-align: center;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Marginalia (Hidden triggers camouflaged as doodles) */
.marginalia {
    position: absolute;
    right: 15px;
    top: 50%;
    width: 40px;
    font-family: var(--font-handwriting);
    font-size: 1rem;
    color: var(--ink-accent);
    opacity: 0.6;
    transform: rotate(5deg);
    cursor: pointer;
    transition: opacity 0.3s;
}

.marginalia:hover {
    opacity: 1;
}

/* ==========================================================================
   THE SUBMERGED LAYER (HIDDEN WORLD)
   ========================================================================== */

/* Triggers - MUST BE INVISIBLE OR SEAMLESS */
.secret-trigger {
    cursor: pointer;
}

.text-trigger {
    /* Looks like normal text, maybe a tiny bit off if you look closely, but usually invisible until hovered/clicked */
    position: relative;
}

/* Subtle hint on hover for those looking closely */
.text-trigger:hover::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--ink-accent);
    opacity: 0.5;
}

/* Overlay System */
.submerged-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--surface-overlay);
    backdrop-filter: blur(4px); /* Requires modern browser */
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none; /* Let clicks pass through when hidden */
}

.submerged-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* The Tactile Polymorphic Card */
.tactile-card {
    background-color: var(--card-bg);
    background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png');
    padding: 2.5rem;
    border-radius: 4px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    max-width: 500px;
    width: 90%;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: var(--font-handwriting);
    font-size: 1.4rem;
    line-height: 1.5;
    color: #3a2c20;
    border: 1px solid rgba(0,0,0,0.1);
}

.submerged-overlay.active .tactile-card {
    transform: translateY(0) scale(1);
}

.tactile-image {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    margin-bottom: 1rem;
}

/* ==========================================================================
   THE RETURN ANCHOR (RIBBON BOOKMARK)
   ========================================================================== */

.ribbon {
    position: fixed;
    top: 0;
    right: 15%;
    width: 35px;
    height: 120px;
    background-color: var(--ink-accent);
    z-index: 200; /* Always on top of everything */
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    cursor: pointer;
    transform-origin: top;
    transition: transform 0.3s ease, height 0.4s ease;
    
    /* Ribbon tail cut */
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 15px), 0 100%);
}

.ribbon.hidden {
    transform: translateY(-100%);
}

.ribbon.active {
    transform: translateY(0);
}

.ribbon:hover {
    height: 130px;
}
