/* =========================================
   KELIBATMU V2
   MOBILE LYRICS OVERLAY SYSTEM - VISUAL POLISH
   
   READING MODE: Simple manuscript experience
   SYNCED MODE: 3-row player interface with cinematic spotlight
   
   Architecture stable - Visual refinement only.
   ========================================= */

/* =========================================
OVERLAY CONTAINER
========================================= */

.lyrics-overlay {
  position: fixed;
  inset: 0;

  width: 100vw;
  height: 100dvh;

  z-index: var(--z-fullscreen, 850);

  overflow: hidden;

  visibility: hidden;
  opacity: 0;

  transition:
    opacity 0.28s ease,
    visibility 0.28s ease;
}

.lyrics-overlay[data-overlay-active="true"] {
  visibility: visible;
  opacity: 1;
}

/* =========================================
BACKDROP
========================================= */

.lyrics-overlay-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  opacity: 0;
  transition: opacity 0.28s ease;
}

.lyrics-overlay[data-overlay-active="true"]
.lyrics-overlay-backdrop {
  opacity: 1;
}

/* =========================================
SHEET
========================================= */

.lyrics-overlay-sheet {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;

  background: linear-gradient(
    180deg,
    rgba(10,10,12,0.98) 0%,
    rgba(5,5,8,0.98) 100%
  );

  overflow: hidden;

  transform: translateY(100%);
  transition: transform 0.34s cubic-bezier(0.2, 0.9, 0.32, 1);

  display: flex;
  flex-direction: column;
}

.lyrics-overlay-sheet[style*="display: none"] {
  display: none !important;
}

.lyrics-overlay[data-overlay-active="true"]
.lyrics-overlay-sheet {
  transform: translateY(0);
}

/* =========================================
MODE RADIUS STYLES
========================================= */

.lyrics-overlay-sheet[data-lyrics-mode="reading"],
.lyrics-overlay-sheet[data-lyrics-mode="synced"] {
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* =========================================
HANDLE (Shared)
========================================= */

.lyrics-overlay-handle-wrapper {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.lyrics-overlay-handle {
  width: 52px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
}

/* =========================================
HEADER (Shared)
========================================= */

.lyrics-overlay-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  z-index: 20;
  flex-shrink: 0;
}

.lyrics-overlay-track-meta {
  flex: 1;
  min-width: 0;
}

.lyrics-overlay-label {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.46);
  margin-bottom: 8px;
}

.lyrics-overlay-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: rgba(255,255,255,0.96);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lyrics-overlay-artist {
  margin-top: 6px;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.58);
}

/* =========================================
CLOSE BUTTON - Soft Crimson Glass Refinement
========================================= */

.lyrics-overlay-close {
  position: absolute;
  top: 54px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(139, 44, 44, 0.25);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(139, 44, 44, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
  opacity: 1;
  visibility: visible;
}

.lyrics-overlay-close[data-inactive="true"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lyrics-overlay-close:hover {
  transform: scale(1.05);
  background: rgba(139, 44, 44, 0.4);
  border-color: rgba(139, 44, 44, 0.5);
  box-shadow: 0 0 20px rgba(139, 44, 44, 0.2);
}

.lyrics-overlay-close:active {
  transform: scale(0.96);
}

.lyrics-overlay-close svg {
  width: 18px;
  height: 18px;
  stroke: rgba(255, 245, 235, 0.85);
  stroke-width: 1.5;
}

/* =========================================
READING MODE - Simple Manuscript Experience
========================================= */

.lyrics-reading-mode,
.lyrics-synced-mode {
  display: none;
}

.lyrics-overlay-sheet[data-lyrics-mode="reading"]
.lyrics-reading-mode {
  display: flex;
  flex: 1;
  min-height: 0;
}

.reading-scroll-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 24px 120px;
}

.reading-lyrics-content {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.lyrics-reading-line {
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.85;
  color: rgba(255,255,255,0.84);
}

/* =========================================
SYNCED MODE - 3-Row Player Interface
Row 1: Header (shared above)
Row 2: Active lyric display (cinematic spotlight)
Row 3: Scrollable synced lyrics list

ONLY Row 3 scrolls.
========================================= */

.lyrics-overlay-sheet[data-lyrics-mode="synced"]
.lyrics-synced-mode {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Row 2: Active Lyric Display - Cinematic Spotlight Area */
.synced-active-area {
  flex-shrink: 0;
  
  padding: 20px 24px 20px;
  
  background: radial-gradient(
    ellipse 80% 100% at 50% 0%,
    rgba(245, 235, 220, 0.04) 0%,
    rgba(245, 235, 220, 0) 70%
  );
  
  border-bottom: 1px solid rgba(255,255,255,0.03);
  margin-bottom: 4px;
}

.synced-active-line {
  text-align: center;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

/* Cinematic Spotlight Lyric - Hero Focus */
.synced-active-text {
  position: relative;
  font-size: 1.24rem;
  line-height: 1.48;
  font-weight: 620;
  letter-spacing: 0;
  color: var(--kv2-lyric-active, rgba(243, 245, 247, 0.94));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  
  transition: 
    opacity 0.35s ease, 
    color 0.35s ease, 
    text-shadow 0.35s ease,
    letter-spacing 0.2s ease;
}

.synced-active-text:not(.syncing-state) {
  background:
    linear-gradient(
      90deg,
      var(--kv2-lyric-fill-start, #8FE8B5) 0%,
      var(--kv2-lyric-fill-end, #D8C6FF) calc(var(--kv2-lyrics-progress, 0) * 100%),
      var(--kv2-lyric-active, #F3F5F7) calc(var(--kv2-lyrics-progress, 0) * 100%),
      var(--kv2-lyric-active, #F3F5F7) 100%
    );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.synced-active-text.is-upcoming:not(.syncing-state) {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: var(--kv2-lyric-inactive, rgba(154, 154, 165, 0.58));
  text-shadow: none;
}

.synced-active-text::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: min(180px, 70vw);
  height: 1px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  opacity: 0;
  transform: translateX(-50%);
}

.synced-active-text::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--kv2-lyric-fill-end, #D8C6FF);
  box-shadow: 0 0 8px rgba(216, 198, 255, 0.32);
  opacity: 0;
  transform: translateX(calc(-90px + (180px * var(--kv2-lyrics-progress, 0))));
}

.mobile-lyrics-sheet[data-lyrics-source="advanced"] .synced-active-text::after {
  opacity: 0.14;
}

.mobile-lyrics-sheet[data-lyrics-source="advanced"] .synced-active-text::before {
  opacity: 0;
}

/* Syncing State - Soft breathing anticipation */
.synced-active-text.syncing-state {
  color: rgba(210, 210, 225, 0.68);
  letter-spacing: 0.2px;
  text-shadow: 
    0 0 8px rgba(141, 245, 143, 0.12),
    0 0 20px rgba(141, 245, 143, 0.05);
  animation: syncingBreath 2.8s ease-in-out infinite;
}

@keyframes syncingBreath {
  0% { opacity: 0.48; text-shadow: 0 0 6px rgba(141, 245, 143, 0.08); }
  50% { opacity: 0.82; text-shadow: 0 0 16px rgba(141, 245, 143, 0.15); }
  100% { opacity: 0.48; text-shadow: 0 0 6px rgba(141, 245, 143, 0.08); }
}

/* Fade animations for line transitions */
.synced-active-line.fade-out {
  opacity: 0;
  transform: translateY(8px);
}

.synced-active-line.fade-in {
  opacity: 1;
  transform: translateY(0);
}

/* Row 3: Scrollable Lyrics List - ONLY THIS ROW SCROLLS */
.synced-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px 20px 32px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  position: relative;
  z-index: 50;
}

/* Subtle elegant scrollbar */
.synced-scroll-area::-webkit-scrollbar {
  width: 3px;
}

.synced-scroll-area::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}

.synced-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(200, 170, 140, 0.25);
  border-radius: 10px;
}

.synced-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(200, 170, 140, 0.4);
}

/* Lyrics Wrapper - Tighter spacing for elegance */
.synced-lines-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* =========================================
SYNCED LYRIC LINE - Default state
========================================= */

.overlay-lyric-line {
  text-align: center;
  cursor: pointer;
  position: relative;
  opacity: 0.38;
  transition: opacity 0.28s ease, transform 0.25s ease;
  padding: 6px 0;
  border-radius: 12px;
}

.overlay-lyric-line .kv2-lyrics-line__progress {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: min(180px, 70%);
  height: 1px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      var(--kv2-lyric-fill-start, rgba(143, 232, 181, 0.72)) calc(var(--kv2-lyrics-progress, 0) * 100%),
      rgba(255, 255, 255, 0.08) 0
    );
  opacity: 0;
  transform: translateX(-50%);
}

.overlay-lyric-line.kv2-lyrics-line--sticky-hidden {
  visibility: hidden;
  pointer-events: none;
}

.overlay-lyric-text {
  font-size: 0.94rem;
  line-height: 1.62;
  font-weight: 480;
  color: var(--kv2-lyric-inactive, rgba(154, 154, 165, 0.58));
  transition: 
    font-size 0.22s ease, 
    font-weight 0.22s ease, 
    color 0.22s ease,
    letter-spacing 0.15s ease;
}

/* =========================================
ACTIVE LINE HIGHLIGHT - Elegant Secondary Emphasis
Secondary to top cinematic lyric - Navigation indicator only
========================================= */

.overlay-lyric-line.active {
  opacity: 0.74 !important;
}

.overlay-lyric-line.active .overlay-lyric-text {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: rgba(226, 230, 235, 0.8) !important;
  font-weight: 540 !important;
  font-size: 0.96rem !important;
  letter-spacing: 0;
  text-shadow: none;
}

/* Previous Line - Gentle fade state */
.overlay-lyric-line.prev-active {
  opacity: 0.62;
}

.overlay-lyric-line.prev-active .overlay-lyric-text {
  color: rgba(200, 190, 175, 0.68);
}

/* Touch Feedback - Subtle */
.overlay-lyric-line:active {
  opacity: 0.5;
  transform: scale(0.99);
  transition: opacity 0.05s ease, transform 0.05s ease;
}

.overlay-lyric-line.active:active {
  opacity: 0.88;
}

/* =========================================
EMPTY STATE
========================================= */

.lyrics-empty-state {
  text-align: center;
  color: rgba(255,255,255,0.42);
  font-size: 0.95rem;
  padding: 48px 20px;
}

/* =========================================
MOBILE LYRICS TRIGGER - Soft Glass with Warm Glow
========================================= */

.mobile-lyrics-trigger.refined {
  position: fixed;
  bottom: 178px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  
  /* Warm amber glass foundation */
  background: rgba(30, 25, 22, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  
  border: 1px solid rgba(245, 215, 170, 0.25);
  
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  z-index: calc(var(--z-player) + 5);
  
  transition: 
    all 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.1);
  
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(245, 215, 170, 0.05),
    0 0 20px rgba(245, 185, 100, 0.08);
}

.mobile-lyrics-trigger.refined .trigger-icon {
  font-size: 1.25rem;
  opacity: 0.92;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15));
  transition: all 0.3s ease;
  color: rgba(245, 225, 185, 0.9);
}

.mobile-lyrics-trigger.refined .trigger-text {
  display: none;
}

.mobile-lyrics-trigger.refined:hover {
  transform: scale(1.05);
  background: rgba(45, 38, 32, 0.75);
  border-color: rgba(245, 215, 170, 0.4);
  box-shadow: 
    0 12px 28px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(245, 215, 170, 0.1),
    0 0 28px rgba(245, 185, 100, 0.15);
}

.mobile-lyrics-trigger.refined:hover .trigger-icon {
  opacity: 1;
  color: rgba(255, 235, 200, 0.98);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

.mobile-lyrics-trigger.refined:active {
  transform: scale(0.96);
  transition: transform 0.08s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .lyrics-overlay-sheet[data-lyrics-mode="synced"] {
    background:
      radial-gradient(circle at 50% 24%, rgba(6, 182, 212, 0.1), transparent 34%),
      linear-gradient(180deg, rgba(5, 8, 12, 0.99) 0%, rgba(2, 6, 12, 0.99) 100%);
  }

  .lyrics-synced-mode,
  .mobile-lyrics-panel {
    min-height: 0;
  }

  .synced-active-area {
    padding: 18px 20px 16px;
    margin-bottom: 0;
    background:
      radial-gradient(
        ellipse 82% 100% at 50% 18%,
        rgba(34, 197, 94, 0.12) 0%,
        rgba(6, 182, 212, 0.07) 42%,
        rgba(2, 6, 12, 0) 76%
      );
  }

  .synced-active-line,
  .lyric-line.is-active {
    min-height: 108px;
    padding-bottom: 18px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    transform: scale(1.035);
    transform-origin: center;
  }

  .synced-active-line.fade-out,
  .synced-active-line.fade-in {
    transform: scale(1.035);
  }

  .synced-active-text,
  .lyric-line.is-active {
    max-width: min(92vw, 520px);
    font-size: 1.04rem;
    line-height: 1.52;
    font-weight: 680;
    color: #f8fafc;
    text-shadow:
      0 0 4px rgba(34, 197, 94, 0.05),
      0 0 7px rgba(160, 126, 214, 0.04),
      0 1px 2px rgba(0, 0, 0, 0.5);
  }

  .synced-active-text:not(.syncing-state) {
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    color: #f8fafc;
  }

  .synced-active-text.is-upcoming:not(.syncing-state) {
    color: var(--kv2-lyric-inactive, rgba(154, 154, 165, 0.58));
    text-shadow: none;
  }

  .synced-active-text::before,
  .synced-active-text::after {
    display: none;
  }

  .lyric-char,
  .lyric-word-highlight {
    color: #B7F5D4;
  }

  .lyric-char.is-sung,
  .lyric-word-highlight,
  .lyric-line .lyric-char.is-sung {
    background: linear-gradient(90deg, #eefbf3 0%, #a9eebf 54%, #d8c6ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: #B7F5D4;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 5px rgba(134, 239, 172, 0.06);
  }

  .lyric-char.is-unsung,
  .lyric-line .lyric-char.is-unsung {
    color: rgba(226, 232, 240, 0.62);
    -webkit-text-fill-color: rgba(226, 232, 240, 0.62);
    text-shadow: none;
  }

  .lyric-active-marker {
    position: relative;
    display: block;
    width: min(172px, 66vw);
    height: 12px;
    border-radius: 999px;
    margin-top: 2px;
    margin-bottom: 4px;
    background: transparent;
  }

  .lyric-active-marker[hidden] {
    display: block !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .lyric-active-orb {
    position: absolute;
    left: calc(var(--kv2-lyrics-progress, 0) * 100%);
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(242, 255, 247, 0.96) 0%, rgba(134, 239, 172, 0.88) 58%, rgba(216, 198, 255, 0.72) 100%);
    box-shadow: 0 0 7px rgba(34,197,94,.2);
    transform: translate(-50%, -50%);
  }

  .overlay-lyric-line.is-upcoming .overlay-lyric-text {
    color: rgba(203, 213, 225, 0.72);
    font-weight: 560;
  }

  .lyric-active-marker.is-bumping .lyric-active-orb {
    animation: lyricOrbBump 120ms ease-out;
  }

  @keyframes lyricOrbBump {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.18); }
    100% { transform: translate(-50%, -50%) scale(1); }
  }

  .lyric-interlude-visual {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 1.45em;
    color: rgba(134, 239, 172, .75);
    text-shadow: 0 0 8px rgba(34,197,94,.22);
  }

  .lyric-interlude-note {
    display: inline-block;
    font-size: clamp(22px, 6.4vw, 28px);
    color: rgba(134, 239, 172, .75);
    animation: lyricInterludeNote 1.8s ease-in-out infinite;
    animation-delay: calc(var(--note-index, 0) * 150ms);
  }

  .lyric-interlude-note:nth-child(2) {
    color: rgba(125, 211, 252, .55);
  }

  @keyframes lyricInterludeNote {
    0%, 100% {
      opacity: 0.44;
      transform: translateY(3px);
    }
    50% {
      opacity: 0.92;
      transform: translateY(-5px);
    }
  }

  .synced-scroll-area,
  .lyrics-scroll {
    padding: 16px 18px max(156px, calc(128px + env(safe-area-inset-bottom)));
  }

  .synced-lines-wrapper {
    gap: 30px;
  }

  .overlay-lyric-line,
  .lyric-line {
    opacity: 1;
    padding: 0;
    filter: none;
  }

  .overlay-lyric-text,
  .lyric-line {
    font-size: 0.98rem;
    line-height: 1.58;
    font-weight: 500;
    color: rgba(203, 213, 225, 0.65);
    text-shadow: none;
    filter: none;
  }

  .overlay-lyric-line.active {
    opacity: 1 !important;
  }

  .overlay-lyric-line.active .overlay-lyric-text {
    color: rgba(226, 232, 240, 0.78) !important;
    font-weight: 620 !important;
    font-size: 1rem !important;
    text-shadow:
      0 0 4px rgba(6, 182, 212, 0.04),
      0 1px 2px rgba(0, 0, 0, 0.4);
  }

  .overlay-lyric-line.prev-active,
  .lyric-line.is-past {
    opacity: 1;
  }

  .overlay-lyric-line.prev-active .overlay-lyric-text,
  .lyric-line.is-past,
  .lyric-line.is-upcoming {
    color: rgba(203, 213, 225, 0.65);
    font-weight: 500;
    filter: none;
  }

  .mobile-lyrics-trigger.refined {
    bottom: 168px;
    right: 18px;
    width: 48px;
    height: 48px;
  }
  
  .mobile-lyrics-trigger.refined .trigger-icon {
    font-size: 1.15rem;
  }
}

@media (max-width: 480px) {
  .mobile-lyrics-trigger.refined {
    bottom: 158px;
    right: 14px;
    width: 44px;
    height: 44px;
  }
  
  .mobile-lyrics-trigger.refined .trigger-icon {
    font-size: 1.05rem;
  }
  .synced-active-text {
    font-size: 1.02rem;
  }
  
  .synced-active-area {
    padding: 16px 18px 14px;
  }

  .synced-active-line,
  .lyric-line.is-active {
    min-height: 112px;
  }
  
  .synced-scroll-area {
    padding: 14px 16px max(164px, calc(136px + env(safe-area-inset-bottom)));
  }
  
  .synced-lines-wrapper {
    gap: 28px;
  }
  
  .overlay-lyric-text {
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lyric-active-orb,
  .lyric-active-marker.is-bumping .lyric-active-orb,
  .lyric-interlude-note {
    animation: none;
    transition: none;
  }
}

/* =========================================
DESKTOP OFF
========================================= */

@media (min-width: 769px) {
  .lyrics-overlay,
  .mobile-lyrics-trigger.refined {
    display: none !important;
  }
  
  .lyrics-overlay-close {
    display: none !important;
  }
}

.mobile-lyrics-sheet[data-lyrics-source="advanced"] .overlay-lyric-line.active .kv2-lyrics-line__progress {
  opacity: 0;
}
