/**
 * FoxyTales Dual-Mode Webcomic & Visual Novel Reader Engine Styles
 * Location: apps/public/wp-themes/foxytales-theme/assets/css/reader-core.css
 * @package FoxyTales
 */

:root {
  /* Canvas & Structural Obsidian Surfaces */
  --clr-obsidian: #0A0E17;
  --clr-obsidian-surface: #121826;
  --clr-obsidian-elevated: #161F30;
  --clr-obsidian-border: #1E293B;

  /* Brand Accents */
  --clr-quantum-violet: #8B5CF6;
  --clr-quantum-violet-glow: rgba(139, 92, 246, 0.4);
  --clr-neon-mint: #10B981;
  --clr-neon-mint-glow: rgba(16, 185, 129, 0.4);
  --clr-cyber-coral: #F97316;
  --clr-cyber-coral-glow: rgba(249, 115, 22, 0.4);

  /* Glassmorphism Specs */
  --glass-bg: rgba(18, 24, 38, 0.82);
  --glass-border: rgba(139, 92, 246, 0.25);
  --glass-border-subtle: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(14px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.55);

  /* Typography */
  --font-display: 'Syne', 'Oswald', sans-serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body: var(--font-ui);

  /* Sizing & Constants */
  --reader-max-width: 800px;
  --header-height: 64px;
  --hud-height: 56px;
  --mobile-dock-height: 58px;
}

/* ==========================================================================
   1. READING PROGRESS BAR
   ========================================================================== */
#ft-read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--clr-quantum-violet, #8B5CF6), var(--clr-neon-mint, #10B981), var(--clr-cyber-coral, #F97316));
  box-shadow: 0 0 12px var(--clr-quantum-violet-glow, rgba(139, 92, 246, 0.6));
  z-index: 1000;
  transition: width 0.15s ease-out;
  pointer-events: none;
}

/* ==========================================================================
   2. STICKY TOP CONTROLS HUD
   ========================================================================== */
.ft-reader-hud {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(10, 14, 23, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
  z-index: 900;
  display: flex;
  align-items: center;
}

.ft-hud-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ft-hud-cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ft-hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #E2E8F0;
  background: rgba(22, 31, 48, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ft-hud-btn:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.4);
  color: #FFFFFF;
}

.ft-hud-btn.is-active {
  background: var(--clr-quantum-violet, #8B5CF6);
  border-color: var(--clr-quantum-violet, #8B5CF6);
  color: #FFFFFF;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.ft-hud-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ft-hud-series-title {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 1rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.5px;
}

.ft-hud-scene-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--clr-neon-mint, #10B981);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Dual Mode Switcher */
.ft-mode-switcher {
  display: inline-flex;
  padding: 3px;
  background: rgba(14, 20, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.ft-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #94A3B8;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ft-mode-btn.is-active {
  background: var(--clr-quantum-violet, #8B5CF6);
  color: #FFFFFF;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.35);
}

/* Animated Soundwave Equalizer */
.ft-soundwave-wrap {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.ft-wave-bar {
  width: 2.5px;
  background: #94A3B8;
  border-radius: 1px;
  height: 4px;
  transition: height 0.2s ease;
}

#ft-audio-toggle.is-playing .ft-wave-bar {
  background: var(--clr-neon-mint, #10B981);
  animation: soundwave 1s infinite ease-in-out alternate;
}

#ft-audio-toggle.is-playing .bar-1 { animation-delay: 0.1s; height: 12px; }
#ft-audio-toggle.is-playing .bar-2 { animation-delay: 0.3s; height: 8px; }
#ft-audio-toggle.is-playing .bar-3 { animation-delay: 0.2s; height: 14px; }
#ft-audio-toggle.is-playing .bar-4 { animation-delay: 0.4s; height: 6px; }

@keyframes soundwave {
  0%   { height: 3px; }
  50%  { height: 14px; }
  100% { height: 5px; }
}

/* ==========================================================================
   3. WEBTOON CONTINUOUS VERTICAL SCROLL MODE
   ========================================================================== */
.ft-webtoon-strip {
  max-width: 800px;
  margin: 1.5rem auto 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0 1rem;
}

.ft-webtoon-panel {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--clr-obsidian-surface, #121826);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.ft-panel-header {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.ft-panel-act-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 0.75rem;
  font-weight: 700;
  color: #FFFFFF;
}

.ft-act-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.ft-panel-counter {
  padding: 0.3rem 0.6rem;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94A3B8;
}

.ft-panel-media-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 1200;
  background: #0D131F;
}

.ft-webtoon-panel-img {
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 1200;
  display: block;
  object-fit: cover;
}

.ft-webtoon-dialogue-pill {
  margin: -1rem 1rem 1.25rem;
  position: relative;
  z-index: 5;
  padding: 0.85rem 1.25rem;
}

.ft-dialogue-speaker {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 0.25rem;
}

.ft-dialogue-body {
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 0.95rem;
  line-height: 1.5;
  color: #E2E8F0;
  margin: 0;
}

/* ==========================================================================
   4. VISUAL NOVEL CINEMA STAGE MODE
   ========================================================================== */
.ft-vn-stage {
  max-width: 900px;
  margin: 1.5rem auto 4rem;
  padding: 0 1rem;
}

.ft-vn-cinema-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 1100;
  border-radius: 16px;
  overflow: hidden;
  background: #000000;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

.ft-vn-slides-deck {
  position: relative;
  width: 100%;
  height: 100%;
}

.ft-vn-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.ft-vn-slide.is-active {
  opacity: 1;
  visibility: visible;
}

.ft-vn-scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ft-vn-slide-badge {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.ft-vn-act-name {
  padding: 0.35rem 0.85rem;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 9999px;
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 0.8125rem;
  font-weight: 700;
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.ft-vn-scene-num {
  padding: 0.35rem 0.75rem;
  background: rgba(139, 92, 246, 0.25);
  backdrop-filter: blur(8px);
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--clr-quantum-violet, #8B5CF6);
  border: 1px solid rgba(139, 92, 246, 0.4);
}

/* CRT Scanlines */
.ft-vn-scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
  z-index: 4;
}

/* In-Stage Stepper Buttons */
.ft-vn-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(10, 14, 23, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s ease;
}

.ft-vn-nav-btn:hover:not(:disabled) {
  background: var(--clr-quantum-violet, #8B5CF6);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.ft-vn-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.ft-vn-btn-prev { left: 1rem; }
.ft-vn-btn-next { right: 1rem; }

/* Interactive Tap Zones */
.ft-vn-tapzone {
  position: absolute;
  top: 0;
  bottom: 120px;
  width: 50%;
  z-index: 15;
  cursor: pointer;
}
.ft-vn-tapzone-prev { left: 0; }
.ft-vn-tapzone-next { right: 0; }

/* Layered Dialogue Box */
.ft-vn-dialogue-box {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 25;
  padding: 1rem 1.25rem;
}

.ft-vn-dialogue-speaker-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.ft-vn-speaker {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.ft-vn-live-indicator {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--clr-neon-mint, #10B981);
}

.ft-vn-dialogue-body-wrap {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.ft-vn-avatar-container {
  flex-shrink: 0;
}

.ft-vn-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--clr-quantum-violet, #8B5CF6);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}

.ft-vn-text-wrap {
  flex-grow: 1;
}

.ft-vn-text {
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 1rem;
  line-height: 1.5;
  color: #F8FAFC;
  margin: 0;
}

.ft-vn-advance-cue {
  align-self: flex-end;
  color: var(--clr-quantum-violet, #8B5CF6);
  font-size: 1rem;
  animation: cueBlink 0.8s infinite alternate;
}

@keyframes cueBlink {
  from { opacity: 0.2; transform: translateY(0); }
  to   { opacity: 1; transform: translateY(-2px); }
}

/* VN Timeline Cyber-Pills */
.ft-vn-stage-footer {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ft-vn-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: #94A3B8;
}

.ft-vn-kbd-hints kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #E2E8F0;
}

.ft-vn-timeline-track {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.ft-vn-pill {
  flex: 1;
  max-width: 60px;
  height: 32px;
  border-radius: 6px;
  background: rgba(22, 31, 48, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ft-vn-pill.is-active {
  background: var(--clr-quantum-violet, #8B5CF6);
  border-color: var(--clr-quantum-violet, #8B5CF6);
  color: #FFFFFF;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}

/* ==========================================================================
   5. OFF-CANVAS DRAWERS (CHAPTERS & CLASSIFIED INTEL)
   ========================================================================== */
.ft-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: -100%;
  width: 100%;
  max-width: 480px;
  z-index: 1100;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
}

.ft-drawer.is-open {
  right: 0;
}

.ft-drawer-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-left: 1px solid rgba(139, 92, 246, 0.3);
  border-top: none;
  border-bottom: none;
  border-right: none;
  background: rgba(10, 14, 23, 0.95);
}

.ft-drawer-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ft-drawer-kicker {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--clr-quantum-violet, #8B5CF6);
  letter-spacing: 1px;
}

.ft-drawer-title {
  margin: 0;
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 1.25rem;
  color: #FFFFFF;
}

.ft-drawer-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #FFFFFF;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ft-drawer-close:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #EF4444;
}

.ft-drawer-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.ft-drawer-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ft-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ft-drawer-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

body.ft-drawer-open {
  overflow: hidden;
}

/* Character Dossiers Cards */
.ft-dossier-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ft-character-card {
  padding: 1.25rem;
}

.ft-char-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.ft-char-avatar-frame {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.ft-dossier-avatar {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--clr-quantum-violet, #8B5CF6);
}

.ft-char-name {
  margin: 0 0 0.25rem;
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 1.1rem;
  color: #FFFFFF;
}

.ft-char-badges {
  font-size: 0.75rem;
  color: #94A3B8;
  display: flex;
  gap: 0.5rem;
}

.ft-char-role {
  color: var(--clr-neon-mint, #10B981);
  font-weight: 600;
}

.ft-char-bio {
  font-size: 0.875rem;
  line-height: 1.5;
  color: #CBD5E1;
  margin: 0 0 1rem;
}

.ft-stats-heading {
  font-size: 0.6875rem;
  letter-spacing: 1px;
  color: #64748B;
  margin: 0 0 0.5rem;
}

.ft-stats-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ft-stat-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

.ft-stat-name { color: #94A3B8; }
.ft-stat-number { color: #FFFFFF; font-weight: 600; }

.ft-stat-meter-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
}

.ft-stat-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-quantum-violet, #8B5CF6), var(--clr-neon-mint, #10B981));
  border-radius: 9999px;
}

/* Chapter Items List */
.ft-chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ft-chapter-item {
  display: flex;
  gap: 1rem;
  padding: 0.85rem;
  background: rgba(22, 31, 48, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: all 0.2s ease;
}

.ft-chapter-item:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
}

.ft-chapter-thumb-wrap {
  position: relative;
  width: 70px;
  height: 95px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}

.ft-chapter-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ft-chapter-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #FFFFFF;
}

.ft-chapter-details {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ft-chapter-act-tag {
  font-size: 0.6875rem;
  color: var(--clr-neon-mint, #10B981);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.ft-chapter-act-title {
  margin: 0.15rem 0;
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 0.95rem;
  color: #FFFFFF;
}

.ft-chapter-snippet {
  font-size: 0.75rem;
  color: #94A3B8;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.ft-chapter-jump-btn {
  align-self: flex-start;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #FFFFFF;
  cursor: pointer;
}

/* ==========================================================================
   6. VIEW TRANSITIONS API
   ========================================================================== */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.3s;
}

/* Pseudo-Fullscreen Fallback for iOS Safari */
.ft-pseudo-fullscreen-active {
  overflow: hidden !important;
}

.ft-reader-main.ft-pseudo-fullscreen,
.ft-reader-wrapper.is-fullscreen-fallback,
.ft-reader-wrapper.is-fullscreen,
.ft-reader-wrapper:fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  z-index: 99999 !important;
  background: var(--clr-obsidian, #0A0E17) !important;
  overflow-y: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================================================
   7. MOBILE BOTTOM DOCK SYNERGY & FULLSCREEN ADAPTATION
   ========================================================================== */
:fullscreen #ft-mobile-dock,
:-webkit-full-screen #ft-mobile-dock,
.ft-reader-wrapper.is-fullscreen ~ #ft-mobile-dock,
.ft-reader-wrapper.is-fullscreen-fallback ~ #ft-mobile-dock,
body.ft-fullscreen-active #ft-mobile-dock {
  display: none !important;
  transform: translateY(100%) !important;
  pointer-events: none !important;
}

@media (max-width: 767px) {
  body.ft-reader-active {
    padding-bottom: 0 !important;
  }
}
