/* ============================================================
   V7 MASTER-PIECE — Tactile Victorian Manor & Interactive Artifacts
   ============================================================ */

/* 1. DARK ACADEMIA / CANDLELIGHT NIGHT-MODE */
:root {
  --candle-glow: rgba(235, 178, 85, 0.15);
  --leather-wood: #26180c;
  --velvet-maroon: #4d1510;
  --brass-sheen: linear-gradient(135deg, #f7e2a9 0%, #caa156 50%, #876226 100%);
  --brass-rim: 1px solid #b89146;
  --vignette: radial-gradient(ellipse at center, transparent 65%, rgba(20, 14, 8, 0.4) 100%);
}

body.candle-mode {
  --paper: #1f1811;
  --paper-deep: #16100a;
  --card: #281f15;
  --ink: #f0e6d2;
  --ink-soft: #d3c4a8;
  --ink-faint: #9c8a6f;
  --brown: #d8ba82;
  --brown-deep: #0e0905;
  --gold: #dfb259;
  --gold-bright: #ffd47a;
  --line: rgba(223, 178, 89, 0.22);
  --line-soft: rgba(223, 178, 89, 0.12);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.6);
  background-color: var(--paper);
}

body.candle-mode .site-header {
  background: rgba(25, 18, 12, 0.94);
  border-bottom-color: var(--line);
}
body.candle-mode .topbar {
  background: #120c07;
  border-bottom-color: rgba(223, 178, 89, 0.2);
}
body.candle-mode .ticket,
body.candle-mode .postcard,
body.candle-mode .letter-note,
body.candle-mode .clipping,
body.candle-mode .telegram,
body.candle-mode .open-book,
body.candle-mode .lib-card {
  background: #2b2116 !important;
  color: #eeddc3 !important;
  border-color: rgba(223, 178, 89, 0.3) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

/* Vignette border on entire screen for cinematic film look */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1999;
  background: radial-gradient(circle at center, transparent 72%, rgba(26, 17, 8, 0.38) 100%);
}

/* 2. AMBIENT LANTERN / CANDLELIGHT TOGGLE SWITCH */
.ambience-switch {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2500;
  background: #332314;
  border: 2px solid #b89146;
  border-radius: 40px;
  padding: 8px 18px 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.25);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  color: #f7e6c4;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  user-select: none;
}
.ambience-switch:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 25px rgba(219, 163, 67, 0.4);
  border-color: #f7d583;
}
.ambience-switch .lamp-flame {
  width: 14px;
  height: 20px;
  background: radial-gradient(circle at 50% 80%, #ffde6b, #ea781d 70%, transparent);
  border-radius: 50% 50% 35% 35%;
  animation: lamp-flicker 1.8s infinite alternate ease-in-out;
  filter: drop-shadow(0 0 6px #ffbe3b);
}
@keyframes lamp-flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); opacity: 0.95; }
  50% { transform: scale(1.15, 0.9) rotate(2deg); opacity: 1; }
  75% { transform: scale(0.9, 1.1) rotate(-2deg); opacity: 0.88; }
}

/* 3. FLASHLIGHT / CANDLELIGHT RADIAL MOUSE FOLLOWER */
.candle-glow-aura {
  position: fixed;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at center, rgba(245, 195, 105, 0.13) 0%, rgba(230, 150, 60, 0.05) 45%, transparent 70%);
  z-index: 1998;
  mix-blend-mode: screen;
  transition: opacity 0.4s ease;
  opacity: 0;
}
body.candle-mode .candle-glow-aura {
  opacity: 1;
}

/* 4. INTERACTIVE 3D FLIPPABLE LEDGER (BOOK OF RECORDS) */
.open-book {
  perspective: 1200px;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.open-book:hover {
  transform: translateY(-5px) rotateX(2deg);
}
.open-book .ob-page {
  transition: background-color 0.3s ease, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.open-book .ob-page:first-child {
  border-right: 1px solid rgba(0,0,0,0.15);
  transform-origin: right center;
}
.open-book .ob-page:last-child {
  transform-origin: left center;
}
.open-book:active .ob-page:first-child {
  transform: rotateY(8deg);
}
.open-book:active .ob-page:last-child {
  transform: rotateY(-8deg);
}
.book-spine-crest {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: 32px;
  height: 32px;
  background: radial-gradient(circle, #f7e09e, #a87e31);
  border-radius: 50%;
  border: 2px solid #573f1c;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: bold;
  color: #38240c;
  pointer-events: none;
}

/* 5. INTERACTIVE TYPEWRITER WITH MECHANICAL KEYS & SOUND FX */
.typewriter {
  background: linear-gradient(180deg, #3d2f21, #1e150d);
  border: 4px solid #5c4328;
  border-radius: 12px 12px 28px 28px;
  padding: 24px;
  box-shadow: 0 25px 50px rgba(18, 12, 6, 0.6), inset 0 2px 4px rgba(255,255,255,0.15);
  position: relative;
}
.typewriter::before {
  content: "UNDERWOOD No. 5 — STANDARD";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "IM Fell English SC", serif;
  font-size: 0.68rem;
  letter-spacing: 0.35em;
  color: #b89146;
  opacity: 0.8;
}
.tw-keys {
  perspective: 600px;
  gap: 7px;
  padding: 12px 8px;
  background: #130d08;
  border-radius: 8px;
  border-top: 2px solid #2e1e12;
  box-shadow: inset 0 8px 12px rgba(0,0,0,0.8);
}
.tw-key {
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at 35% 30%, #fffbf0 0%, #d8c29d 60%, #997b4d 100%) !important;
  border: 2px solid #543f25 !important;
  box-shadow: 0 5px 0 #281c0f, 0 7px 10px rgba(0,0,0,0.6) !important;
  font-family: "Special Elite", monospace !important;
  font-size: 0.72rem !important;
  font-weight: bold !important;
  color: #2e1d0f !important;
  cursor: pointer;
  transition: all 0.08s ease !important;
  user-select: none;
}
.tw-key:hover {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #ebd7b5 60%, #af8f5c 100%) !important;
  transform: translateY(-1px);
}
.tw-key:active, .tw-key.pressed {
  transform: translateY(4px) !important;
  box-shadow: 0 1px 0 #281c0f, 0 3px 5px rgba(0,0,0,0.7) !important;
  color: #a82e22 !important;
}
.tw-paper {
  border-left: 2px solid rgba(138, 90, 42, 0.4);
  border-right: 2px solid rgba(138, 90, 42, 0.4);
  background-image: repeating-linear-gradient(180deg, transparent, transparent 27px, rgba(160, 120, 70, 0.12) 28px) !important;
  box-shadow: 0 8px 25px rgba(0,0,0,0.25) !important;
  position: relative;
  overflow: hidden;
}
.tw-paper::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 45px;
  width: 1px;
  background: rgba(184, 62, 50, 0.28);
}
.tw-roller {
  background: repeating-linear-gradient(90deg, #1f160e 0 15px, #3a2b1c 15px 18px) !important;
  border-top: 3px solid #70532e;
  border-bottom: 3px solid #140d07;
}

/* 6. WAX SEAL STAMP WITH INTERACTIVE POP / CRACKLE EFFECT */
.seal, .mini-seal {
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.25s ease;
  position: relative;
}
.seal:hover, .mini-seal:hover {
  transform: scale(1.12) rotate(4deg);
  filter: drop-shadow(0 6px 14px rgba(113, 48, 39, 0.65));
}
.seal:active, .mini-seal:active {
  transform: scale(0.94);
}
.wax-splatter {
  position: absolute;
  inset: -6px;
  border-radius: 46% 54% 48% 52% / 54% 46% 54% 46%;
  background: radial-gradient(circle at 35% 30%, #ab4235, #713027 65%, #461913);
  z-index: -1;
  box-shadow: 0 4px 12px rgba(45, 14, 10, 0.5);
}

/* 7. HIGH-CLASS VINTAGE MAGNIFIER (INSPECTOR LOUPE) */
.magnifier-lens {
  position: fixed;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 7px solid #cca452;
  box-shadow: 0 12px 35px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.25), inset 0 0 0 3px #543b17;
  pointer-events: none;
  z-index: 2600;
  display: none;
  transform: translate(-50%, -50%);
  background-repeat: no-repeat;
  backdrop-filter: brightness(1.08) contrast(1.12);
  overflow: hidden;
}
.magnifier-lens::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.45) 0%, transparent 45%);
}
.magnifier-handle {
  position: absolute;
  width: 18px;
  height: 80px;
  background: linear-gradient(90deg, #2b180d, #52341e 50%, #1a0e07);
  bottom: -70px;
  right: 15px;
  transform: rotate(-45deg);
  transform-origin: top center;
  border-radius: 4px 4px 10px 10px;
  border: 2px solid #8c6a2e;
  box-shadow: 0 6px 12px rgba(0,0,0,0.5);
}

/* 8. INTERACTIVE BOOKSHELF 3D PULL-OUT */
.shelf .book {
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  transform-origin: bottom center;
}
.shelf .book:hover {
  transform: translateY(-24px) scale(1.05);
  box-shadow: 0 22px 30px -8px rgba(25, 16, 9, 0.65), 0 0 15px rgba(223, 178, 89, 0.3);
  z-index: 10;
}
.shelf .book::after {
  content: "Lật xem";
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: #fff2d1;
  background: #4a341f;
  border: 1px solid #b89146;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.shelf .book:hover::after {
  opacity: 1;
}

/* 9. MODAL READING ROOM (POP-UP BOOK READING PREVIEW) */
.manor-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 11, 7, 0.85);
  backdrop-filter: blur(5px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.manor-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.manor-modal-book {
  width: 90%;
  max-width: 760px;
  background: #fbf5e6;
  border: 12px solid #3c2a19;
  outline: 2px solid #c8a355;
  box-shadow: 0 30px 70px rgba(0,0,0,0.8), inset 0 0 60px rgba(120, 80, 40, 0.18);
  border-radius: 4px;
  padding: 44px 50px;
  position: relative;
  transform: scale(0.92) rotate(-1deg);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.manor-modal-overlay.active .manor-modal-book {
  transform: scale(1) rotate(0deg);
}
.manor-modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: 1px solid #9e7a3f;
  color: #5a3c1e;
  font-family: var(--font-display);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}
.manor-modal-close:hover {
  background: #713027;
  color: #fff;
  border-color: #713027;
}
.modal-book-header {
  border-bottom: 2px double #b89146;
  padding-bottom: 16px;
  margin-bottom: 24px;
  text-align: center;
}
.modal-book-cat {
  font-family: "IM Fell English SC", serif;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  color: #713027;
  display: block;
}
.modal-book-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  color: #2c1e11;
  margin: 6px 0;
}
.modal-book-author {
  font-family: var(--font-script);
  font-size: 1.5rem;
  color: #8c6a2e;
}
.modal-book-content {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.85;
  color: #291d13;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0 10px;
}
.modal-book-content p {
  margin-bottom: 1.2em;
  text-indent: 1.8em;
}
.modal-book-content p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.2rem;
  float: left;
  line-height: 0.85;
  padding-right: 10px;
  color: #713027;
}

/* 10. REALISTIC TICKETS HOVER & STUB TEAR EFFECT */
.ticket {
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.3s ease;
}
.ticket:hover {
  transform: translateY(-8px) rotate(0deg) scale(1.02) !important;
  box-shadow: 0 16px 35px rgba(45, 30, 15, 0.35) !important;
}
.ticket:active .ticket-stub {
  transform: translateX(4px) rotate(2deg);
}

/* 11. GOLD ENGRAVING GILT FRAMES SHIMMER */
.frame.gilt {
  position: relative;
  overflow: hidden;
}
.frame.gilt::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent 40%, rgba(255, 235, 170, 0.22) 50%, transparent 60%);
  transform: rotate(25deg);
  animation: gilt-shimmer 7s infinite ease-in-out;
  pointer-events: none;
  z-index: 10;
}
@keyframes gilt-shimmer {
  0% { transform: translateY(-100%) rotate(25deg); }
  35%, 100% { transform: translateY(100%) rotate(25deg); }
}

/* 12. POCKET WATCH TICKING ANIMATION */
.pw-hand.min {
  animation: tick-min 60s steps(60) infinite;
  transform-origin: bottom center;
}
@keyframes tick-min {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}

/* 13. SOUND CONTROLLER BADGE */
.audio-hint {
  font-size: 0.72rem;
  opacity: 0.8;
  letter-spacing: 0.05em;
}
