/* ==========================================================================
   THE CHRONICLES OF TANJIRO - PORTFOLIO STYLESHEET
   ========================================================================== */

/* --- Custom Variables & Theme Configurations --- */
:root {
  /* Desktop wooden desk background */
  --bg-desk-color: #1a0f08;
  --bg-desk: radial-gradient(circle, #2d1b10 0%, #130a05 100%);
  
  /* Light Parchment Theme Variables */
  --bg-paper: #F5F0E8;
  --text-ink: #0D0D0D;
  --text-ink-secondary: #2C2C2C;
  --accent-gold: #cfa772;
  --accent-red: #8b0000;
  --accent-red-hover: #b22222;
  --border-paper: rgba(0, 0, 0, 0.08);
  --line-color: rgba(66, 85, 255, 0.04); /* rule lines blue-tint */
  --margin-line-color: rgba(255, 0, 0, 0.15); /* rule margin line red */
  
  /* Sound & Candlelight Controls Colors */
  --btn-bg: rgba(245, 240, 232, 0.95);
  --btn-border: #cfa772;
  --btn-text: #0D0D0D;
  
  /* Shadowing */
  --book-shadow: 0 30px 70px rgba(0, 0, 0, 0.75);
  --page-curl-shadow: rgba(0, 0, 0, 0.15);
  --candle-color: rgba(253, 160, 19, 0.12);
  
  /* Transitions */
  --theme-transition: background 1s ease, color 1s ease, border-color 1s ease, box-shadow 1s ease;
}

/* Candlelight (Dark Parchment) Mode */
body.candlelight-mode {
  --bg-desk-color: #0f0804;
  --bg-desk: radial-gradient(circle, #1a0f08 0%, #080402 100%);
  
  --bg-paper: #2C2416;
  --text-ink: #E8D5A3;
  --text-ink-secondary: #cfa772;
  --accent-gold: #a67c4e;
  --accent-red: #b22222;
  --accent-red-hover: #ff3333;
  --border-paper: rgba(255, 255, 255, 0.06);
  --line-color: rgba(232, 213, 163, 0.04);
  --margin-line-color: rgba(232, 110, 110, 0.1);
  
  --btn-bg: rgba(44, 36, 22, 0.95);
  --btn-border: #a67c4e;
  --btn-text: #E8D5A3;
  
  --book-shadow: 0 40px 90px rgba(0, 0, 0, 0.9);
  --candle-color: rgba(253, 110, 19, 0.28);
}

/* --- Global Elements & Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Lora', 'EB Garamond', serif;
  background: var(--bg-desk-color);
  background-image: var(--bg-desk);
  color: var(--text-ink);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: var(--theme-transition);
}

/* --- Wooden Desk Grain Background Overlay --- */
.desk-surface {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Simulated Wood Planks Overlay */
.desk-surface::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(90deg, rgba(0,0,0,0.15) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 180px 100%, 100% 8px;
  opacity: 0.65;
}

/* Flickering Candle Light Glow */
.candle-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, var(--candle-color) 0%, transparent 80%);
  z-index: 2;
  mix-blend-mode: color-burn;
  animation: flicker 3s infinite alternate;
}

/* Candle Flicker Keyframes */
@keyframes flicker {
  0% { opacity: 0.92; transform: scale(1); }
  30% { opacity: 0.96; transform: scale(1.02) translate(1px, -1px); }
  60% { opacity: 0.88; transform: scale(0.98) translate(-1px, 1px); }
  100% { opacity: 0.94; transform: scale(1.01) translate(0px, 0px); }
}

/* --- Ambient Floating Dust Particles --- */
.dust-particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
}
#dust-particles {
  width: 100%;
  height: 100%;
}

/* --- Interactive Control Panel --- */
.controls-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 12px;
  z-index: 1000;
}
.control-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  color: var(--btn-text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, var(--theme-transition);
}
.control-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}
.control-btn:active {
  transform: scale(0.95);
}

/* --- Red Satin Bookmark Ribbon --- */
.bookmark-ribbon {
  position: fixed;
  top: -10px;
  right: 6%;
  width: 32px;
  height: 160px;
  background: #8b0000;
  box-shadow: 4px 5px 12px rgba(0,0,0,0.45), inset -3px 0 10px rgba(0,0,0,0.3);
  z-index: 900;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  transform-origin: top center;
}
.bookmark-ribbon:hover {
  transform: translateY(15px);
}
.bookmark-ribbon::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 4px 100%;
}
.bookmark-ribbon .ribbon-tail {
  position: absolute;
  bottom: -15px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 16px solid #8b0000;
  border-right: 16px solid #8b0000;
  border-bottom: 15px solid transparent;
}

/* --- 3D BOOK ENGINE GRAPHICS --- */
.book-viewport {
  position: relative;
  width: 100%;
  height: 780px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* StPageFlip manages its own container sizing via JS */
.book-container {
  display: none;
}

/* When Book is Closed (Loader Entrance State) */
.book-container.closed-book {
  transform: rotateX(25deg) rotateY(0deg) rotateZ(0deg);
  cursor: pointer;
}

/* When Book is Flat-Open on the table */
.book-container.open-book {
  transform: rotateX(15deg) rotateY(0deg) rotateZ(0deg);
}

/* Center spine/gutter shadow vertical line */
.book-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 100%;
  background: linear-gradient(90deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.15) 30%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.15) 70%, rgba(0,0,0,0.45) 100%);
  transform: translateX(-50%);
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.5s;
}
.book-container.open-book::after {
  opacity: 1;
}

/* --- THE STATE-OF-THE-ART PAGE-FLIP CONTAINER --- */
.flip-book-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.flip-book {
  box-shadow: var(--book-shadow);
  background: transparent;
}
.my-page {
  background-color: var(--bg-paper);
  overflow: hidden;
  width: 100%;
  height: 100%;
}

/* Margin and Spine Padding Overrides for flat pages */
.page-left-padding {
  padding: 35px 45px 35px 35px !important;
}
.page-right-padding {
  padding: 35px 35px 35px 45px !important;
}

/* Ruled margin red line swaps based on left/right padding (Hidden globally) */
.page-left-padding .page-ruled-lines::after {
  display: none;
}
.page-right-padding .page-ruled-lines::after {
  display: none;
}

/* Torn Edge positioning swaps based on left/right padding */
.page-left-padding .torn-edge {
  left: -5px;
  border-right: 1px solid var(--border-paper);
  right: auto;
}
.page-right-padding .torn-edge {
  right: -5px;
  border-left: 1px solid var(--border-paper);
  left: auto;
}

/* Volumetric Gutter Spine shadow overrides mapped dynamically */
.page-right-padding::after {
  content: "";
  position: absolute;
  top: 0; 
  left: 0; 
  width: 30px; 
  height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.08) 30%, rgba(0,0,0,0) 100%);
  pointer-events: none;
  z-index: 50;
}
.page-left-padding::after {
  content: "";
  position: absolute;
  top: 0; 
  right: 0; 
  width: 30px; 
  height: 100%;
  background: linear-gradient(to left, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.08) 30%, rgba(0,0,0,0) 100%);
  pointer-events: none;
  z-index: 50;
}

/* --- THE REALISTIC LEATHER BINDING (COVERS) --- */
.cover-front, .cover-back {
  background: #1e110a;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8);
  border: 1px solid #000;
}
.cover-back {
  border-radius: 10px 4px 4px 10px;
}

/* Premium Leather Texture Gradient Overlay */
.leather-texture {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(#2d1b10 15%, transparent 20%),
    radial-gradient(#1f120a 15%, transparent 20%),
    linear-gradient(45deg, rgba(0,0,0,0.3) 0%, transparent 100%);
  background-size: 8px 8px, 6px 6px, 100% 100%;
  background-position: 0 0, 4px 4px, 0 0;
  opacity: 0.75;
}

/* Gold Embossing Styling */
.gold-embossed-border {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  bottom: 24px;
  border: 3px double #d4af37;
  border-radius: 4px;
  box-shadow: 0 0 5px rgba(212, 175, 55, 0.4), inset 0 0 10px rgba(212, 175, 55, 0.3);
  pointer-events: none;
}
.cover-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  text-align: center;
  z-index: 10;
}
.book-subtitle {
  font-family: 'Cormorant Garamond', serif;
  color: #d4af37;
  font-size: 1.4rem;
  letter-spacing: 5px;
  text-shadow: 1px 1px 1px #000;
  margin-bottom: 5px;
}
.book-title {
  font-family: 'Playfair Display', serif;
  color: #e5c158;
  font-size: 3.4rem;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 20px;
  text-shadow: 2px 2px 2px #000, 0 0 10px rgba(212, 175, 55, 0.5);
  border-bottom: 1px solid #d4af37;
  padding-bottom: 10px;
  width: 80%;
}
.cover-ornament {
  font-size: 2.2rem;
  color: #d4af37;
  margin-bottom: 20px;
  text-shadow: 1px 1px 1px #000;
}
.book-author {
  font-family: 'Cormorant Garamond', serif;
  color: #fff;
  font-size: 1.1rem;
  letter-spacing: 3px;
  margin-bottom: 5px;
  text-shadow: 1px 1px 2px #000;
}
.gold-embossed-footer {
  font-family: 'Cormorant Garamond', serif;
  color: #d4af37;
  font-size: 0.9rem;
  letter-spacing: 2px;
  margin-top: auto;
  text-shadow: 1px 1px 1px #000;
}
.cover-clasp {
  position: absolute;
  top: 50%;
  right: -5px;
  width: 30px;
  height: 50px;
  background: linear-gradient(to right, #8a7322, #d4af37, #5c4e17);
  border: 1px solid #3d330c;
  border-radius: 4px 0 0 4px;
  transform: translateY(-50%);
  box-shadow: 3px 3px 8px rgba(0,0,0,0.5);
  z-index: 20;
}
.gold-back-ornament {
  font-size: 4rem;
  color: #d4af37;
  text-shadow: 2px 2px 2px #000;
}

/* --- MARBLED ENDPAPER BACKING --- */
.endpaper-texture {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #8b7d6b;
  background-image: 
    radial-gradient(circle at 10% 20%, #4a3e35 10%, transparent 20%),
    radial-gradient(circle at 90% 80%, #6e5f52 20%, transparent 40%),
    radial-gradient(circle at 50% 50%, #2f2520 30%, transparent 60%);
  opacity: 0.35;
  mix-blend-mode: overlay;
}

/* --- THE PAPER CONTAINER SYSTEM (StPageFlip flat layout) --- */
.page-paper {
  /* Fill the entire flat page card from StPageFlip */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-paper);
  border: none;
  padding: 35px 35px 35px 45px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--theme-transition);
  box-sizing: border-box;
  /* SVG grain texture overlay */
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100' height='100' filter='url(%23n)' opacity='0.022'/></svg>");
}

/* Ruled Writing Line grids */
.page-ruled-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(var(--line-color) 1px, transparent 1px);
  background-size: 100% 24px;
  pointer-events: none;
  z-index: 1;
}

/* Red Margin Line — default right-side (left-hand pages) - Hidden globally */
.page-ruled-lines::after {
  display: none;
}

/* TORN/DECKLED OUTER EDGES — default outer right side */
.torn-edge {
  position: absolute;
  top: 0;
  right: -5px;
  width: 12px;
  height: 100%;
  background-color: var(--bg-paper);
  z-index: 10;
  pointer-events: none;
  filter: url(#torn-edge-filter);
  transition: var(--theme-transition);
  border-left: 1px solid var(--border-paper);
}

/* StPageFlip draws its own shadows — no old pseudo-element spine overlays needed */
/* Corner curl is now handled natively by the StPageFlip canvas renderer */

/* --- TYPOGRAPHY & DECORATIONS --- */
.running-header {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--text-ink-secondary);
  text-transform: uppercase;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-paper);
  padding-bottom: 6px;
  z-index: 5;
  display: block;
}
.page-left-padding .running-header {
  text-align: right;
}

.page-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  z-index: 5;
}

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

.chapter-header {
  font-family: 'Playfair Display', serif;
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-ink);
  text-align: center;
  margin-top: 10px;
}
.chapter-subheader {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  font-style: italic;
  color: var(--text-ink-secondary);
  text-align: center;
  letter-spacing: 1px;
}

.ornament-divider {
  text-align: center;
  font-size: 1.3rem;
  color: var(--accent-gold);
  margin: 12px 0 20px;
  letter-spacing: 4px;
}

.chapter-paragraph {
  font-family: 'Lora', 'EB Garamond', serif;
  font-size: 0.98rem;
  line-height: 1.7;
  text-align: justify;
  text-indent: 20px;
  color: var(--text-ink);
  margin-bottom: 12px; /* Slightly reduced for better fit */
}
.chapter-paragraph.small-gap {
  margin-bottom: 10px;
}

/* Handwritten Dropcap */
.drop-cap {
  font-family: 'Playfair Display', serif;
  font-size: 4.2rem;
  float: left;
  line-height: 0.78;
  margin-top: 5px;
  margin-right: 8px;
  color: var(--accent-red);
  font-weight: 700;
  text-shadow: 1px 1px 0 var(--accent-gold);
}

/* Page numbers at footer margins */
.page-number {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-ink-secondary);
  position: absolute;
  bottom: 12px;
  z-index: 5;
}
.page-front .page-number {
  right: 25px;
}
.page-back .page-number {
  left: 25px;
}

/* --- THE MARGIN ANNOTATIONS (PENCIL DOODLES) --- */
.pencil-doodle {
  font-family: 'Caveat', 'La Belle Aurore', cursive;
  color: rgba(110, 110, 110, 0.55);
  font-size: 1.15rem;
  line-height: 1.2;
  pointer-events: none;
  transform: rotate(-2deg);
  transition: color 1s ease;
}
body.candlelight-mode .pencil-doodle {
  color: rgba(232, 213, 163, 0.28);
}
.inline-pencil {
  position: absolute;
  z-index: 10;
}

.margin-pencil-left {
  position: absolute;
  bottom: 8%;
  left: -20px;
  width: 140px;
  transform: rotate(-6deg);
}

/* ==========================================================================
   SPECIFIC PORTFOLIO COMPONENT DESIGNS
   ========================================================================== */

/* --- TABLE OF CONTENTS --- */
.toc-list {
  list-style: none;
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.toc-item {
  display: flex;
  align-items: flex-end;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.12rem;
  cursor: pointer;
  transition: color 0.2s ease;
}
.toc-item:hover {
  color: var(--accent-red);
}
.toc-name {
  font-weight: 600;
  flex-shrink: 0;
}
.toc-leader {
  flex-grow: 1;
  border-bottom: 2px dotted var(--text-ink);
  margin: 0 10px 4px;
  opacity: 0.35;
}
.toc-page {
  font-weight: 700;
}
.owner-plate {
  border: 1px solid var(--accent-gold);
  padding: 30px;
  text-align: center;
  width: 80%;
  margin: 40px auto;
  box-shadow: inset 0 0 15px rgba(207, 167, 114, 0.15);
}
.plate-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-gold);
}
.plate-line {
  width: 40px;
  height: 1px;
  background-color: var(--accent-gold);
  margin: 10px auto;
}
.plate-owner {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-ink);
  letter-spacing: 2px;
}
.plate-sub {
  font-size: 0.85rem;
  margin-top: 10px;
  font-style: italic;
  color: var(--text-ink-secondary);
}
.plate-ornament {
  font-size: 1rem;
  color: var(--accent-gold);
  margin-top: 15px;
}

/* --- CHAPTER I: POLAROID SHIELDS --- */
.polaroid-wrapper {
  position: relative;
  transform: rotate(2.5deg);
  transition: transform 0.5s ease;
  z-index: 10;
}
.polaroid-wrapper:hover {
  transform: rotate(-1deg) scale(1.02);
}
.polaroid-card {
  background: #fff;
  padding: 12px 12px 25px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);
  border: 1px solid rgba(0,0,0,0.06);
  width: 240px;
}
body.candlelight-mode .polaroid-card {
  background: #dbcca9;
  border-color: rgba(0,0,0,0.15);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.polaroid-photo {
  width: 216px;
  height: 210px;
  overflow: hidden;
  background: #eaeaea;
  border: 1px solid rgba(0,0,0,0.08);
}
.polaroid-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.3) contrast(0.95);
}
.polaroid-caption {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: #333;
  text-align: center;
  margin-top: 12px;
}
body.candlelight-mode .polaroid-caption {
  color: #1e110a;
}
/* Translucent Tape SVGs overlaying corners */
.tape-svg {
  position: absolute;
  width: 90px;
  height: 26px;
  background: rgba(244, 237, 211, 0.5);
  backdrop-filter: blur(1px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  z-index: 20;
}
.tape-top {
  top: -15px;
  left: -20px;
  transform: rotate(-25deg);
}
.tape-bottom {
  bottom: -10px;
  right: -25px;
  transform: rotate(-15deg);
}

/* --- CHAPTER II: ANNOTATED GLOSSARY & INK PROGRESS --- */
.glossary-list dt {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--text-ink);
  margin-top: 15px;
}
.glossary-list dd {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-ink-secondary);
  padding-left: 15px;
  margin-bottom: 8px;
  border-left: 2px solid var(--accent-gold);
}
.glossary-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  margin-top: 5px;
}
.glossary-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-style: italic;
  text-align: center;
  color: var(--text-ink-secondary);
  margin-bottom: 20px;
}
.skills-ink-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 10px;
}
.ink-skill-item {
  width: 100%;
}
.ink-skill-label {
  display: flex;
  justify-content: space-between;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 4px;
}
/* Hand drawn quill outlines */
.ink-bar-outline {
  width: 100%;
  height: 18px;
  border: 2px solid var(--text-ink);
  border-radius: 8px 4px 6px 8px;
  padding: 1px;
  position: relative;
  overflow: visible;
}
.ink-fill-bar {
  width: 0%;
  height: 100%;
  background: var(--text-ink);
  border-radius: 4px;
  /* Animates like ink seeping */
  transition: width 1.8s cubic-bezier(0.1, 0.8, 0.25, 1);
}
/* When book flips/loads, we trigger progress bar fills */
.book-container.open-book .ink-fill-bar {
  width: var(--target-width);
}
/* Realistic hand drawn ink drips */
.ink-drip {
  position: absolute;
  top: 12px;
  width: 4px;
  height: 0px;
  background-color: var(--text-ink);
  border-radius: 0 0 2px 2px;
  transition: height 1s 1.8s ease;
  pointer-events: none;
}
.book-container.open-book .ink-drip {
  height: 6px;
}
.ink-splatter-svg {
  position: absolute;
  bottom: 12%;
  left: 5%;
  width: 120px;
  height: 120px;
  pointer-events: none;
}

/* --- CHAPTER III: NEWS CLIPPINGS (EDITORIAL) --- */
.newspaper-card {
  border: 1px solid rgba(0,0,0,0.12);
  padding: 15px;
  box-shadow: 3px 5px 12px rgba(0,0,0,0.06);
  margin-bottom: 15px;
  position: relative;
}
.yellowed-paper {
  background-color: #f7eed7;
  transition: var(--theme-transition);
}
body.candlelight-mode .yellowed-paper {
  background-color: #241d12;
  border-color: rgba(255, 255, 255, 0.05);
}
.clipping-header {
  display: flex;
  justify-content: space-between;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.72rem;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(0,0,0,0.18);
  padding-bottom: 2px;
  margin-bottom: 6px;
  color: var(--text-ink-secondary);
}
body.candlelight-mode .clipping-header {
  border-color: rgba(255,255,255,0.12);
}
.clipping-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
  text-align: center;
}
.clipping-columns {
  column-count: 2;
  column-gap: 12px;
  text-align: justify;
}
.clipping-img {
  width: 100%;
  height: auto;
  border: 1px solid rgba(0,0,0,0.15);
  margin-bottom: 6px;
  break-inside: avoid;
}
.clipping-img img {
  width: 100%;
  height: 100%;
  display: block;
}
.clipping-text {
  font-size: 0.74rem;
  line-height: 1.45;
  text-indent: 10px;
  color: var(--text-ink-secondary);
}
.margin-top-clipping {
  margin-top: 15px;
}

/* Coffee Stain Rings */
.coffee-stain {
  position: absolute;
  bottom: 0px;
  right: 15px;
  width: 150px;
  height: 150px;
  pointer-events: none;
  z-index: 50;
  transform: rotate(20deg);
}

/* --- CHAPTER IV: EXPERIENCE TIMELINE --- */
.timeline-spread-left {
  padding-right: 45px;
}
.timeline-spread-right {
  padding-left: 45px;
}
.timeline-main-column {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.timeline-verse {
  border-left: 2px solid var(--accent-gold);
  padding-left: 15px;
  margin-bottom: 5px;
}
.verse-reference {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--accent-red);
  display: block;
  margin-bottom: 2px;
}
.verse-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.verse-text {
  font-size: 0.84rem;
  line-height: 1.6;
  text-align: justify;
  color: var(--text-ink-secondary);
}

/* Marginalia Columns */
.marginalia-container {
  position: absolute;
  width: 110px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  top: 140px;
  z-index: 10;
}
.left-margin-notes {
  left: 12px;
}
.right-margin-notes {
  right: 12px;
}
.marginalia-note {
  font-family: 'Caveat', cursive;
  font-size: 1.02rem;
  color: rgba(100, 100, 100, 0.7);
  line-height: 1.25;
  transform: rotate(-3deg);
  transition: color 1s ease;
}
body.candlelight-mode .marginalia-note {
  color: rgba(232, 213, 163, 0.38);
}
.marginalia-date {
  font-weight: 700;
  display: block;
  font-size: 0.85rem;
  text-decoration: underline;
}

/* Pressed Dried Flower Tuckin */
.pressed-flower-container {
  position: absolute;
  bottom: -4px;
  right: -5px;
  width: 60px;
  height: 160px;
  z-index: 80;
  transform: rotate(5deg);
  pointer-events: none;
}
.pressed-flower-container svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(-2px 4px 6px rgba(0,0,0,0.18));
}

/* --- CHAPTER V: CONTACT & WAX SEAL --- */
.elegant-links-list {
  list-style: none;
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.elegant-links-list li {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
}
.ink-link {
  color: var(--accent-red);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px dashed var(--accent-red);
  transition: color 0.2s ease, border-color 0.2s;
}
.ink-link:hover {
  color: var(--accent-red-hover);
  border-bottom-style: solid;
}
.scroll-form {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-ink);
}
.form-input {
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--accent-gold);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  color: var(--text-ink);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s;
}
body.candlelight-mode .form-input {
  background: rgba(0, 0, 0, 0.2);
}
.form-input:focus {
  border-color: var(--accent-red);
  background: rgba(255,255,255,0.8);
}
body.candlelight-mode .form-input:focus {
  background: rgba(0,0,0,0.4);
}
.form-textarea {
  min-height: 75px;
  resize: none;
}

/* Wax Seal Button Graphics */
.wax-seal-container {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
.wax-seal-btn {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.wax-seal-stamp {
  position: relative;
  width: 48px;
  height: 48px;
  background: radial-gradient(circle, #b22222 20%, #8b0000 80%);
  border-radius: 50%;
  box-shadow: 
    3px 4px 10px rgba(0,0,0,0.35), 
    inset -2px -2px 8px rgba(0,0,0,0.4),
    inset 2px 2px 8px rgba(255,255,255,0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease, filter 0.2s;
}
.wax-seal-stamp::after {
  content: "";
  position: absolute;
  top: -3px; left: -3px; right: -3px; bottom: -3px;
  border: 4px solid #8b0000;
  border-radius: 53%;
  opacity: 0.85;
}
.seal-inner {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 1.6rem;
  color: #500000;
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.15), -1px -1px 1px rgba(0,0,0,0.5);
  transform: rotate(-10deg);
}
.wax-seal-label {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent-red);
  border-bottom: 2px dashed var(--accent-red);
  padding-bottom: 2px;
  transition: color 0.2s;
}
.wax-seal-btn:hover .wax-seal-stamp {
  transform: scale(1.08) rotate(5deg);
  filter: brightness(1.1);
}
.wax-seal-btn:hover .wax-seal-label {
  color: var(--accent-red-hover);
}
.wax-seal-btn:active .wax-seal-stamp {
  transform: scale(0.95);
}

/* Success Toast */
.form-success-message {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--accent-red);
  margin-top: 15px;
  transition: opacity 0.5s ease, max-height 0.5s ease;
}
.form-success-message.show-toast {
  opacity: 1;
  max-height: 40px;
}
.toast-ornament {
  color: var(--accent-gold);
}

.colophon-plate {
  border: 1px solid var(--accent-gold);
  padding: 24px;
  text-align: center;
  width: 85%;
  box-shadow: inset 0 0 15px rgba(207, 167, 114, 0.1);
}
.colophon-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  letter-spacing: 3px;
  color: var(--accent-gold);
  margin-bottom: 8px;
}
.colophon-text {
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-ink-secondary);
  margin-bottom: 10px;
}
.finis-label {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--accent-gold);
  text-shadow: 1px 1px 1px #000;
}

/* ==========================================================================
   MOBILE DEVICE VIEWPORT RESPONSIVENESS
   ========================================================================== */

/* Navigation overlay for mobile devices */
.mobile-nav-panel {
  display: none;
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  padding: 10px 20px;
  border-radius: 30px;
  align-items: center;
  gap: 25px;
  z-index: 1000;
  transition: var(--theme-transition);
}
.mobile-nav-btn {
  background: transparent;
  border: none;
  color: var(--btn-text);
  font-size: 1.5rem;
  cursor: pointer;
  outline: none;
}
.mobile-pages-indicator {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--btn-text);
}

@media (max-width: 1024px) {
  /* On screen sizes less than 1024px, collapse the book into a single-page view */
  .book-viewport {
    height: 600px;
    padding: 0 10px;
  }
  .book-container {
    width: 480px;
    height: 570px;
  }
  .book-container::after {
    /* Hide center spine overlay on mobile */
    display: none;
  }
  .book-sheet {
    /* Each sheet takes up 100% of the book area in mobile */
    width: 100%;
    /* Keep origin on left side for standard flips, but stack them directly */
    transform-origin: left center;
  }
  /* Show mobile indicators */
  .mobile-nav-panel {
    display: flex;
  }
  
  /* Readjust page padding for smaller sheet cards */
  .page-paper {
    padding: 25px 25px 25px 35px;
  }
  .page-back .page-paper {
    padding: 25px 35px 25px 25px;
  }
  .chapter-header {
    font-size: 1.75rem;
  }
  .chapter-paragraph {
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 12px;
  }
  .drop-cap {
    font-size: 3.2rem;
    line-height: 0.8;
  }
  .polaroid-card {
    width: 190px;
    padding: 10px 10px 20px;
  }
  .polaroid-photo {
    width: 168px;
    height: 160px;
  }
  .polaroid-caption {
    font-size: 1.15rem;
    margin-top: 8px;
  }
  .marginalia-container {
    display: none; /* Hide marginalia notes on mobile, keeping text clean */
  }
  .timeline-spread-left {
    padding-right: 0px;
  }
  .timeline-spread-right {
    padding-left: 0px;
  }
  .clipping-columns {
    column-count: 1; /* Single column on mobile */
  }
  .clipping-img {
    display: none; /* Hide clipping image in newspaper card for space saving */
  }
  .newspaper-card {
    padding: 10px;
    margin-bottom: 8px;
  }
  .clipping-title {
    font-size: 0.85rem;
    margin-bottom: 4px;
  }
  .clipping-text {
    font-size: 0.7rem;
  }
  .pressed-flower-container {
    width: 45px;
    height: 120px;
  }
  .owner-plate {
    padding: 15px;
    margin: 20px auto;
  }
  .plate-owner {
    font-size: 1.6rem;
  }
  .skills-ink-container {
    gap: 10px;
  }
  .form-textarea {
    min-height: 55px;
  }
  .bookmark-ribbon {
    right: 4%;
    width: 24px;
    height: 110px;
  }
  .bookmark-ribbon .ribbon-tail {
    border-left-width: 12px;
    border-right-width: 12px;
    border-bottom-width: 12px;
  }
}

@media (max-width: 480px) {
  .book-viewport {
    height: 520px;
  }
  .book-container {
    width: 320px;
    height: 490px;
  }
  .page-paper {
    padding: 20px 15px 20px 25px;
  }
  .page-back .page-paper {
    padding: 20px 25px 20px 15px;
  }
  .running-header {
    margin-bottom: 10px;
  }
  .chapter-header {
    font-size: 1.45rem;
  }
  .chapter-paragraph {
    font-size: 0.78rem;
    line-height: 1.5;
    margin-bottom: 8px;
    text-indent: 10px;
  }
  .drop-cap {
    font-size: 2.6rem;
  }
  .polaroid-wrapper {
    transform: none !important;
  }
  .polaroid-card {
    width: 160px;
  }
  .polaroid-photo {
    width: 138px;
    height: 130px;
  }
  .toc-item {
    font-size: 0.95rem;
  }
  .form-input {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
  .form-group {
    gap: 2px;
  }
  .form-textarea {
    min-height: 45px;
  }
  .wax-seal-stamp {
    width: 38px;
    height: 38px;
  }
  .seal-inner {
    font-size: 1.2rem;
  }
  .wax-seal-label {
    font-size: 0.95rem;
  }
}

/* ==========================================================================
   ULTRA-PREMIUM ADDITIONAL ANIMATIONS & LOADER STYLING
   ========================================================================== */

/* --- CINEMATIC 3D BOOK LOADER --- */
.premium-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #080402;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
}
.loader-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(#1c0f08 10%, transparent 15%),
    radial-gradient(#080402 30%, transparent 50%);
  background-size: 8px 8px, 100% 100%;
  opacity: 0.3;
  pointer-events: none;
}
.loader-ambient-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(253, 140, 19, 0.15) 0%, transparent 60%);
  mix-blend-mode: screen;
  animation: loader-glow 4s infinite alternate;
  pointer-events: none;
}
@keyframes loader-glow {
  0% { opacity: 0.75; }
  100% { opacity: 1.05; }
}
.loader-book-viewport {
  perspective: 800px;
  margin-bottom: 40px;
  transform-style: preserve-3d;
}
.loader-book {
  position: relative;
  width: 160px;
  height: 110px;
  transform-style: preserve-3d;
  transform: rotateX(28deg) rotateY(-22deg) rotateZ(-6deg);
  animation: loader-book-float 3s infinite ease-in-out alternate;
}
@keyframes loader-book-float {
  0% { transform: rotateX(28deg) rotateY(-22deg) rotateZ(-6deg) translateY(0px); }
  100% { transform: rotateX(30deg) rotateY(-18deg) rotateZ(-4deg) translateY(-12px); }
}
.loader-cover {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #1a0a03;
  border: 1px solid #d4af37;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 5px 15px rgba(0,0,0,0.5);
  transform-style: preserve-3d;
  z-index: 10;
}
.cover-left {
  left: 0;
  border-radius: 4px 0 0 4px;
  transform-origin: right center;
  transform: rotateY(-180deg); /* Lays open left */
  animation: loader-left-cover-open 2.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.cover-right {
  right: 0;
  border-radius: 0 4px 4px 0;
  transform-origin: left center;
}
@keyframes loader-left-cover-open {
  0% { transform: rotateY(0deg); }
  35% { transform: rotateY(-180deg); }
  100% { transform: rotateY(-180deg); }
}
.loader-sheet {
  position: absolute;
  top: 2px;
  right: 0;
  width: 49%;
  height: calc(100% - 4px);
  background-color: #f5f0e8;
  border: 1px solid rgba(0,0,0,0.08);
  transform-origin: left center;
  transform-style: preserve-3d;
  z-index: 5;
  animation: rapid-page-flip 1.8s infinite ease-in-out;
  animation-delay: calc(var(--i) * 0.15s + 0.7s); /* Staggered flips starting after cover opens */
  opacity: 0;
}
@keyframes rapid-page-flip {
  0% { transform: rotateY(0deg); opacity: 0; }
  4% { opacity: 1; }
  40% { transform: rotateY(-180deg); opacity: 1; }
  90% { opacity: 1; }
  100% { transform: rotateY(-180deg); opacity: 0; }
}
.loader-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 20;
}
.loader-ornament {
  font-size: 1.5rem;
  color: #d4af37;
  animation: loader-spin 4s infinite linear;
}
@keyframes loader-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.loader-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: #d4af37;
  letter-spacing: 3px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.loader-progress-bar {
  width: 240px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
.loader-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #d4af37, #8b0000);
  box-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
}

/* --- ULTRA-REALISTIC FLEXIBLE PAGE FLIP ANIMATIONS --- */
.sheet-flipping-forward {
  animation: page-flip-forward 1.4s cubic-bezier(0.35, 0, 0.25, 1) forwards;
}
.sheet-flipping-backward {
  animation: page-flip-backward 1.4s cubic-bezier(0.35, 0, 0.25, 1) forwards;
}

@keyframes page-flip-forward {
  0% {
    transform: rotateY(0deg) translateZ(0px) skewY(0deg) rotateZ(0deg);
  }
  35% {
    /* Lift up off screen, skew vertically to simulate paper bending, twist Z axis */
    transform: rotateY(-60deg) translateZ(65px) skewY(-5.5deg) rotateZ(-3.5deg);
  }
  65% {
    transform: rotateY(-120deg) translateZ(65px) skewY(-4.5deg) rotateZ(-3.5deg);
  }
  100% {
    transform: rotateY(-180deg) translateZ(0px) skewY(0deg) rotateZ(0deg);
  }
}

@keyframes page-flip-backward {
  0% {
    transform: rotateY(-180deg) translateZ(0px) skewY(0deg) rotateZ(0deg);
  }
  35% {
    transform: rotateY(-120deg) translateZ(65px) skewY(5.5deg) rotateZ(3.5deg);
  }
  65% {
    transform: rotateY(-60deg) translateZ(65px) skewY(4.5deg) rotateZ(3.5deg);
  }
  100% {
    transform: rotateY(0deg) translateZ(0px) skewY(0deg) rotateZ(0deg);
  }
}

/* --- INTERACTIVE PENCIL SCRIBBLES REVEALS (HANDWRITING EFFECTS) --- */
.pencil-doodle {
  opacity: 0;
  transform: rotate(-2deg) scale(0.95) translateY(5px);
  transition: 
    opacity 1.4s ease 0.6s, 
    transform 1.4s cubic-bezier(0.1, 0.8, 0.25, 1) 0.6s, 
    color 1s ease;
}
/* When sheet is flipped, reveal pencil notes on left page (back side) */
.book-sheet.flipped .page-back .pencil-doodle {
  opacity: 0.65;
  transform: rotate(-2deg) scale(1) translateY(0);
}
/* When next sheet is UNflipped, reveal pencil notes on right page (front side) */
.book-sheet:not(.flipped) .page-front .pencil-doodle {
  opacity: 0.65;
  transform: rotate(-2deg) scale(1) translateY(0);
}
body.candlelight-mode .book-sheet.flipped .page-back .pencil-doodle,
body.candlelight-mode .book-sheet:not(.flipped) .page-front .pencil-doodle {
  opacity: 0.38;
}

/* --- LIQUID INK SEEPING RIPPLES --- */
.ink-fill-bar {
  background-image: linear-gradient(
    90deg, 
    var(--text-ink) 0%, 
    rgba(255,255,255,0.07) 25%, 
    var(--text-ink) 50%,
    rgba(255,255,255,0.07) 75%,
    var(--text-ink) 100%
  );
  background-size: 200% 100%;
  animation: ink-ripple-anim 3.5s infinite linear;
}
@keyframes ink-ripple-anim {
  0% { background-position: 200% 0; }
  100% { background-position: 0% 0; }
}

/* --- INTERACTIVE POLAROID 3D TILT TETHERS --- */
.polaroid-wrapper {
  transform-style: preserve-3d;
  perspective: 600px;
}
.polaroid-card {
  transform-style: preserve-3d;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 1s ease;
}

/* --- 3D TILT WAX SEALMonogram BUTTON --- */
.wax-seal-btn {
  transform-style: preserve-3d;
  perspective: 400px;
}
.wax-seal-stamp {
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), filter 0.2s, box-shadow 0.2s;
}
.wax-seal-btn:active .wax-seal-stamp {
  transform: scale(0.92) translateZ(-12px);
  box-shadow: 
    1px 1px 4px rgba(0,0,0,0.5),
    inset -1px -1px 4px rgba(0,0,0,0.6);
}

/* ==========================================================================
   STPAGEFLIP INTEGRATION OVERRIDES & FINAL POLISH
   ========================================================================== */

/* --- StPageFlip canvas layer sits behind our content --- */
.flip-book canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* --- Cover pages use leather background directly on .my-page --- */
.my-page.cover-front,
.my-page.cover-back {
  background: #1a0a03 !important;
  position: relative;
}

/* --- Inside cover / endpaper pages need relative positioning --- */
.my-page.inside-cover-left,
.my-page.inside-cover-right {
  position: relative;
  background: #6b5a4e !important;
}

/* Endpaper marbling effect full bleed */
.my-page .endpaper-texture {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: 0.6;
  mix-blend-mode: multiply;
}

/* Page paper sits on top of endpaper */
.my-page .page-paper {
  z-index: 1;
}

/* --- CANDLELIGHT MODE: flat .my-page and .page-paper theming --- */
body.candlelight-mode .my-page {
  background-color: var(--bg-paper);
}
body.candlelight-mode .page-paper {
  background-color: var(--bg-paper);
  color: var(--text-ink);
}
body.candlelight-mode .yellowed-paper {
  background-color: #241d12;
  border-color: rgba(255,255,255,0.05);
}

/* --- PAGE NUMBERS: always pinned to bottom corners --- */
.page-number {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-ink-secondary);
  position: absolute;
  bottom: 14px;
  z-index: 20;
}
/* Right-hand pages: number at bottom-right */
.page-right-padding .page-number,
.page-right-padding > .page-number {
  right: 22px;
  left: auto;
}
/* Left-hand pages: number at bottom-left */
.page-left-padding .page-number,
.page-left-padding > .page-number {
  left: 22px;
  right: auto;
}

/* --- INK FILL BARS: wait for .start-fill trigger --- */
.ink-fill-bar {
  width: 0%;
  transition: width 2s cubic-bezier(0.1, 0.8, 0.25, 1) 0.3s;
}
.skills-ink-container.start-fill .ink-fill-bar {
  width: var(--target-width);
}

/* Ink drips only appear after fill */
.ink-drip {
  position: absolute;
  top: 14px;
  width: 4px;
  height: 0px;
  background-color: var(--text-ink);
  border-radius: 0 0 2px 2px;
  transition: height 0.8s 2.2s ease;
  pointer-events: none;
}
.skills-ink-container.start-fill .ink-drip {
  height: 7px;
}

/* Liquid ink seeping shimmer on fill bars */
.skills-ink-container.start-fill .ink-fill-bar {
  background-image: linear-gradient(
    90deg,
    var(--text-ink) 0%,
    rgba(255,255,255,0.07) 25%,
    var(--text-ink) 50%,
    rgba(255,255,255,0.07) 75%,
    var(--text-ink) 100%
  );
  background-size: 200% 100%;
  animation: ink-ripple-anim 3.5s infinite linear;
}
@keyframes ink-ripple-anim {
  0%   { background-position: 200% 0; }
  100% { background-position: 0% 0; }
}

/* --- PENCIL DOODLE REVEALS on page open --- */
.pencil-doodle {
  opacity: 0;
  transform: rotate(-2deg) scale(0.95) translateY(6px);
  transition: opacity 1.2s ease 0.5s, transform 1.2s cubic-bezier(0.1,0.8,0.25,1) 0.5s, color 1s ease;
}
/* Trigger reveal when StPageFlip makes the page visible (use JS class) */
.my-page.page-visible .pencil-doodle {
  opacity: 0.65;
  transform: rotate(-2deg) scale(1) translateY(0);
}
body.candlelight-mode .my-page.page-visible .pencil-doodle {
  opacity: 0.35;
}

/* --- StPageFlip shadow canvas z-ordering --- */
.stf__item {
  overflow: visible !important;
}
.stf__block {
  overflow: visible !important;
}

/* --- MOBILE RESPONSIVE overrides for StPageFlip --- */
@media (max-width: 1024px) {
  .book-viewport {
    height: 620px;
    padding: 0 8px;
  }
  .mobile-nav-panel {
    display: flex;
  }
  .chapter-header { font-size: 1.7rem; }
  .chapter-paragraph { font-size: 0.86rem; line-height: 1.55; margin-bottom: 10px; }
  .drop-cap { font-size: 3rem; line-height: 0.8; }
  .polaroid-card { width: 180px; padding: 10px 10px 20px; }
  .polaroid-photo { width: 158px; height: 150px; }
  .marginalia-container { display: none; }
  .timeline-spread-left,
  .timeline-spread-right { padding: 0; }
  .clipping-columns { column-count: 1; }
  .clipping-img { display: none; }
  .newspaper-card { padding: 10px; margin-bottom: 8px; }
  .pressed-flower-container { width: 42px; height: 110px; }
  .owner-plate { padding: 14px; margin: 18px auto; }
  .plate-owner { font-size: 1.5rem; }
  .skills-ink-container { gap: 10px; }
  .form-textarea { min-height: 52px; }
  .bookmark-ribbon { right: 4%; width: 24px; height: 110px; }
  .bookmark-ribbon .ribbon-tail {
    border-left-width: 12px;
    border-right-width: 12px;
    border-bottom-width: 12px;
  }
}

@media (max-width: 480px) {
  .book-viewport { height: 540px; }
  .chapter-header { font-size: 1.4rem; }
  .chapter-paragraph { font-size: 0.76rem; line-height: 1.5; text-indent: 10px; }
  .drop-cap { font-size: 2.5rem; }
  .polaroid-card { width: 150px; }
  .polaroid-photo { width: 128px; height: 122px; }
  .toc-item { font-size: 0.88rem; }
  .page-paper { padding: 18px 14px 18px 22px; }
  .page-left-padding { padding: 18px 22px 18px 14px !important; }
  .page-right-padding { padding: 18px 14px 18px 22px !important; }
  .form-input { padding: 5px 8px; font-size: 0.74rem; }
  .form-textarea { min-height: 44px; }
  .wax-seal-stamp { width: 36px; height: 36px; }
  .seal-inner { font-size: 1.15rem; }
  .wax-seal-label { font-size: 0.9rem; }
}

/* --- CINEMATIC FADE TO BLACK TRANSITION OVERLAY --- */
.cinematic-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #050403;
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}
.cinematic-transition-overlay.active {
  opacity: 1;
  pointer-events: all;
}

