/* ==========================================================================
   THE SECRET OF FOXGLOVE MANOR: A COZY SOLO MYSTERY GAME
   High-Interactivity, Audiovisual & Print Perfection Stylesheet
   Theme: Cozy Dark Academia / Botanical Cottagecore / Vintage Aged Paper
   ========================================================================== */

:root {
  --bg-night: #0e1712;
  --bg-forest: #14231a;
  --bg-card: #18271e;
  --bg-card-hover: #1f3327;
  --bg-parchment: #f6efe6;
  --bg-parchment-aged: #f4ecda;
  --gold-primary: #e6c280;
  --gold-bright: #ffda85;
  --gold-dim: #c5a059;
  --gold-glow: rgba(230, 194, 128, 0.3);
  --burnt-orange: #b34e12;
  --burnt-orange-bright: #d9621a;
  --dried-rose: #c47b7b;
  --text-cream: #f4efea;
  --text-sage: #9bb0a5;
  --text-ink: #1c150e;
  --border-gold: rgba(197, 160, 89, 0.3);
  --border-gold-bright: rgba(230, 194, 128, 0.75);

  /* 2025-2026 jewel-tone accents layered onto the existing dark academia palette */
  --plum-noir: #4b2067;
  --deep-burgundy: #6b1e2d;
  --dusty-gold: #c9a84c;
}

/* Base Body Styles */
body {
  background-color: var(--bg-night);
  color: var(--text-cream);
  font-family: 'Lora', Georgia, serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  selection-background-color: var(--gold-dim);
  selection-color: var(--bg-night);
}

/* Ambient Candlelight Glow Overlay */
.candlelight-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(circle at 50% 15%, rgba(230, 194, 128, 0.05) 0%, transparent 75%);
  animation: candleFlicker 7s infinite alternate ease-in-out;
}

@keyframes candleFlicker {
  0% { opacity: 0.85; transform: scale(1); }
  25% { opacity: 0.7; transform: scale(0.99); }
  50% { opacity: 0.95; transform: scale(1.02); }
  75% { opacity: 0.8; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1.01); }
}

/* Botanical Vignette Border */
.botanical-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.9), inset 0 0 45px rgba(14, 23, 18, 0.95);
}

/* Subtle Floating Spores */
.spore {
  position: fixed;
  width: 3px;
  height: 3px;
  background: var(--gold-primary);
  border-radius: 50%;
  opacity: 0.2;
  pointer-events: none;
  animation: floatUp 16s infinite linear;
  z-index: 3;
}

@keyframes floatUp {
  0% { transform: translateY(105vh) translateX(0); opacity: 0; }
  15% { opacity: 0.45; }
  85% { opacity: 0.35; }
  100% { transform: translateY(-5vh) translateX(50px); opacity: 0; }
}

/* Fonts */
.font-cinzel { font-family: 'Cinzel', serif; }
.font-playfair { font-family: 'Playfair Display', serif; }
.font-lora { font-family: 'Lora', serif; }
.font-handwriting { font-family: 'Caveat', cursive; }
.font-typewriter { font-family: 'Special Elite', monospace; }

/* Parchment Card Textures */
.parchment-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.7), 0 0 15px var(--gold-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.parchment-panel:hover {
  border-color: var(--border-gold-bright);
}

/* Physical Paper Aesthetic */
.paper-sheet {
  background: #f5eedf;
  color: var(--text-ink);
  box-shadow: 2px 4px 15px rgba(0, 0, 0, 0.4), inset 0 0 40px rgba(180, 150, 100, 0.25);
  border-radius: 6px;
  position: relative;
}

.tea-stain {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid rgba(139, 90, 43, 0.15);
  box-shadow: inset 0 0 15px rgba(139, 90, 43, 0.1);
  pointer-events: none;
}

/* Washi Tape Accent */
.washi-tape {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-1.5deg);
  width: 90px;
  height: 22px;
  background: rgba(197, 160, 89, 0.55);
  backdrop-filter: blur(2px);
  border-left: 2px dashed rgba(255, 255, 255, 0.45);
  border-right: 2px dashed rgba(255, 255, 255, 0.45);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.washi-tape-rose {
  background: rgba(196, 123, 123, 0.55);
}

/* Polaroid Card Style */
.polaroid-card {
  background: #fbf9f4;
  padding: 10px 10px 20px 10px;
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  position: relative;
}

.polaroid-card:hover {
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.7), 0 0 15px var(--gold-glow);
}

/* Brass Tack Pin */
.brass-tack {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2a3 10%, #c5a059 60%, #523b11 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.8);
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
}

/* Wax Seal Elements */
.wax-seal {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #c73838 20%, #7d1515 80%, #4a0b0b 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 170, 170, 0.35);
  border: 2px solid #5a1010;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffd8d8;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  user-select: none;
}

.wax-seal:hover {
  transform: scale(1.1) rotate(-3deg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.8), inset 0 2px 5px rgba(255, 200, 200, 0.5);
}

.wax-seal-gold {
  background: radial-gradient(circle at 40% 40%, #ffdf88 20%, #b88a32 80%, #5c4110 100%);
  border-color: #785312;
  color: #3d2b07;
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 170, 170, 0.35), 0 0 0 3px rgba(75, 32, 103, 0.35);
}

/* 3D Clue Card Flip */
.flip-card {
  perspective: 1200px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 12px;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* First-Visit Map Tutorial Hint (tapping hand + callout, shown once) */
.map-tutorial-hint {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 40;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: tutorialFadeIn 0.5s ease-out;
}

.map-tutorial-hint.fading-out {
  animation: tutorialFadeOut 0.5s ease-in forwards;
}

.map-tutorial-bubble {
  background: rgba(14, 23, 18, 0.95);
  border: 1px solid var(--border-gold-bright);
  color: var(--gold-bright);
  font-family: 'Cinzel', serif;
  font-size: 11px;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.map-tutorial-hand {
  font-size: 30px;
  filter: drop-shadow(0 0 8px rgba(230, 194, 128, 0.8));
  animation: tutorialTap 1.1s infinite ease-in-out;
}

@keyframes tutorialTap {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(10px) scale(0.92); }
  55% { transform: translateY(0) scale(1.05); }
}

@keyframes tutorialFadeIn {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

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

/* Interactive Map Hotspot Pins */
.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 20;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.map-pin:hover {
  transform: translate(-50%, -50%) scale(1.22);
}

.pin-beacon {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--gold-bright);
  animation: pulseBeacon 2s infinite ease-out;
  pointer-events: none;
}

@keyframes pulseBeacon {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Portrait Zoom Modal & Optical Loupe */
.inspect-hotspot {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(230, 194, 128, 0.4);
  border: 2px solid var(--gold-bright);
  box-shadow: 0 0 12px var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  animation: hotspotGlow 2.5s infinite alternate;
  z-index: 30;
  transition: transform 0.2s ease;
}

.inspect-hotspot:hover {
  transform: scale(1.3);
  background: rgba(230, 194, 128, 0.8);
}

@keyframes hotspotGlow {
  0% { box-shadow: 0 0 6px var(--gold-primary); }
  100% { box-shadow: 0 0 20px var(--gold-bright), 0 0 30px rgba(230, 194, 128, 0.5); }
}

/* Deduction Corkboard & Golden String */
.corkboard {
  background-color: #2b1f16;
  background-image: 
    radial-gradient(#3a291d 15%, transparent 16%), 
    radial-gradient(#221811 15%, transparent 16%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  border: 8px solid #5a3d24;
  border-radius: 12px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8), 0 10px 25px rgba(0, 0, 0, 0.7);
  position: relative;
}

.golden-thread-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.golden-yarn {
  stroke: #ffda73;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(255, 218, 115, 0.75));
  stroke-dasharray: 6 3;
  animation: threadGleam 20s infinite linear;
}

.plum-yarn {
  stroke: #b479d9;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(180, 121, 217, 0.75));
  stroke-dasharray: 6 3;
  animation: threadGleam 20s infinite linear;
}

@keyframes threadGleam {
  to { stroke-dashoffset: 200; }
}

/* 3D Dice Simulation */
.dice-container {
  perspective: 600px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.dice-cube {
  width: 54px;
  height: 54px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

.dice-rolling {
  animation: diceRollAnimation 0.8s ease-out;
}

@keyframes diceRollAnimation {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) translateY(0); }
  30% { transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg) translateY(-25px); }
  70% { transform: rotateX(720deg) rotateY(540deg) rotateZ(270deg) translateY(-10px); }
  100% { transform: rotateX(1080deg) rotateY(720deg) rotateZ(360deg) translateY(0); }
}

/* Bound Book Lateral Tabs */
.book-tab {
  background: #1b2d22;
  border: 1px solid var(--border-gold);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text-sage);
  transition: all 0.2s ease;
  cursor: pointer;
}

.book-tab:hover, .book-tab.active-tab {
  background: linear-gradient(135deg, #2a4735 0%, #2a4735 55%, #3a2050 100%);
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  transform: translateX(-4px);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.4), 0 0 14px rgba(75, 32, 103, 0.3);
}

/* Jewel-Toned Panel Accent (readiness meter, case report) */
.jewel-panel {
  border-color: rgba(75, 32, 103, 0.4) !important;
  box-shadow: inset 0 0 22px rgba(75, 32, 103, 0.14), inset 0 0 10px rgba(107, 30, 45, 0.1);
}

/* Brand Logo Ring — amber line with a plum halo for a richer, jewel-toned mark */
.brand-ring {
  box-shadow: 0 0 0 2px rgba(230, 194, 128, 0.55), 0 0 14px rgba(75, 32, 103, 0.5);
}

/* Corkboard Pin "Settle" Micro-Interaction */
@keyframes corkPinSettle {
  0% { transform: scale(1.08) rotate(-1deg); }
  55% { transform: scale(0.96) rotate(0.5deg); }
  100% { transform: scale(1) rotate(0); }
}

.cork-slot.just-pinned {
  animation: corkPinSettle 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Neo-Skeuomorphic Tactile Press (subtle pressed-paper feedback over the flat UI) */
button:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #0e1712;
}
::-webkit-scrollbar-thumb {
  background: #1f3327;
  border-radius: 4px;
  border: 1px solid rgba(197, 160, 89, 0.25);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #c5a059, #4b2067);
}

/* ==========================================================================
   PRINT ENGINE (EXACT 1-PAGE CERTIFICATE & FULL COZY CASEBOOK WITH 1 SUSPECT PER PAGE)
   ========================================================================== */

@media print {
  
  /* -------------------------------------------------------------
     MODE 1: CERTIFICATE ONLY (Strictly 1 Single Clean Page!)
     ------------------------------------------------------------- */
  body.print-certificate-only {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.print-certificate-only * {
    visibility: hidden !important;
  }

  body.print-certificate-only #certificate-modal,
  body.print-certificate-only #certificate-modal * {
    visibility: visible !important;
  }

  body.print-certificate-only #certificate-modal {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }

  body.print-certificate-only #printable-certificate-modal {
    width: 90% !important;
    max-width: 800px !important;
    margin: auto !important;
    background: #f7f2e4 !important;
    color: #14100c !important;
    box-shadow: none !important;
    border: 8px double #8b6e37 !important;
    border-radius: 12px !important;
    padding: 2.5rem !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.print-certificate-only .no-print {
    display: none !important;
  }

  /* -------------------------------------------------------------
     MODE 2: 7-DAY CASEBOOK (Cozy Aged Paper, 1 Suspect Per Page, High Contrast)
     ------------------------------------------------------------- */
  body.print-casebook-only {
    background-color: #f5eedc !important; /* Cozy warm vintage aged paper */
    color: #16120e !important; /* Rich deep antique black ink */
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.print-casebook-only .no-print,
  body.print-casebook-only .candlelight-overlay,
  body.print-casebook-only .botanical-vignette,
  body.print-casebook-only header,
  body.print-casebook-only nav,
  body.print-casebook-only #certificate-modal,
  body.print-casebook-only #portrait-inspect-modal,
  body.print-casebook-only #narrative-modal,
  body.print-casebook-only #cozy-toast,
  body.print-casebook-only button {
    display: none !important;
  }

  /* Unhide all tab panes in book order */
  body.print-casebook-only .tab-pane {
    display: block !important;
    opacity: 1 !important;
    page-break-after: always !important;
    break-after: page !important;
    margin-bottom: 2rem !important;
    background: transparent !important;
  }

  /* Cozy Vintage Paper Styling for All Containers */
  body.print-casebook-only .parchment-panel {
    background: #fbf6ec !important;
    color: #16120e !important;
    border: 2px solid #8c6e33 !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    padding: 1.8rem !important;
  }

  body.print-casebook-only h1,
  body.print-casebook-only h2,
  body.print-casebook-only h3,
  body.print-casebook-only h4 {
    color: #a6450e !important; /* Warm rich burnt orange / dark sienna */
    font-weight: bold !important;
  }

  body.print-casebook-only p,
  body.print-casebook-only span,
  body.print-casebook-only div,
  body.print-casebook-only strong {
    color: #16120e !important; /* High contrast dark ink */
  }

  body.print-casebook-only .text-sage,
  body.print-casebook-only .text-stone-400 {
    color: #3b2e24 !important; /* Readable dark brown */
  }

  /* MAP PAGE (Page 2): Fully Visible Without Cutoffs */
  body.print-casebook-only #tab-map img {
    max-height: 480px !important;
    width: 100% !important;
    object-fit: contain !important;
    border: 2px solid #8c6e33 !important;
    border-radius: 8px !important;
    margin-bottom: 1rem !important;
    background: #f5eedc !important;
  }

  /* SUSPECTS PAGES (Pages 3, 4, 5, 6): EXACTLY 1 SUSPECT PER PAGE! */
  body.print-casebook-only #suspects-grid {
    display: block !important;
  }

  body.print-casebook-only .print-suspect-card {
    display: block !important;
    page-break-after: always !important;
    break-after: page !important;
    min-height: 90vh !important;
    margin-bottom: 3rem !important;
    background: #fbf6ec !important;
    border: 2px solid #8c6e33 !important;
    border-radius: 8px !important;
    padding: 2rem !important;
  }

  /* COMPLETE, UNCUT SUSPECT PORTRAIT */
  body.print-casebook-only .print-suspect-photo {
    max-height: 310px !important;
    width: auto !important;
    max-width: 100% !important;
    object-fit: contain !important;
    margin: 0 auto 1.2rem auto !important;
    display: block !important;
    border: 2px solid #8c6e33 !important;
    border-radius: 6px !important;
    background: #f4ecd8 !important;
  }

  /* Polaroid frame in print */
  body.print-casebook-only .polaroid-card {
    background: #f4ecd8 !important;
    border: 2px solid #8c6e33 !important;
    box-shadow: none !important;
    padding: 12px !important;
    margin-bottom: 1.5rem !important;
  }

  /* Clues grid in print: Clean 2 columns */
  body.print-casebook-only #clues-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }

  body.print-casebook-only .flip-card {
    height: auto !important;
    min-height: 240px !important;
  }

  body.print-casebook-only .flip-card-inner {
    transform: none !important;
  }

  body.print-casebook-only .flip-card-front {
    display: none !important;
  }

  body.print-casebook-only .flip-card-back {
    position: static !important;
    transform: none !important;
    display: block !important;
    background: #fbf6ec !important;
    border: 2px solid #8c6e33 !important;
    color: #16120e !important;
  }

  /* 7-Day Journal in print */
  body.print-casebook-only #tab-journal {
    page-break-after: always !important;
    break-after: page !important;
  }

  body.print-casebook-only .print-journal-day {
    page-break-after: always !important;
    break-after: page !important;
    min-height: 85vh !important;
    background: #fbf6ec !important;
    border: 2px solid #8c6e33 !important;
    padding: 2rem !important;
    margin-bottom: 2rem !important;
  }

  body.print-casebook-only textarea {
    border: 1px solid #8c6e33 !important;
    background: transparent !important;
    color: #16120e !important;
    font-size: 11pt !important;
    line-height: 1.6 !important;
  }
}
