/* ─── Shared Lyrics Result Card Styles ───────────────────────────────────────
 * Used by index.html and me.html. Do not add page-specific rules here.
 * ─────────────────────────────────────────────────────────────────────────── */

.result {
  display: none;
  max-width: 680px;
  margin: 0 auto 32px;
  background: #181818;
  border-radius: 8px;
  overflow: hidden;
}
.result.show { display: block; }
.result.show.bg-playing { position: fixed !important; top: -200vh; visibility: hidden; pointer-events: none; }

.result-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 28px 0;
}
.result-art {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  background: #282828;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.result-art img {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: cover;
}
.result-art svg { color: #535353; }
.result-info { flex: 1; min-width: 0; }
.result-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-artist {
  font-size: 14px;
  color: #b3b3b3;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Lyrics Box ── */
.lyrics-box {
  position: relative;
  padding: 32px 28px;
  max-height: 70vh;
  overflow-y: auto;
  text-align: center;
}
.lyrics-box::-webkit-scrollbar { width: 8px; }
.lyrics-box::-webkit-scrollbar-track { background: transparent; }
.lyrics-box::-webkit-scrollbar-thumb { background: #535353; border-radius: 4px; }
.lyrics-line {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.6;
  color: #fff;
  padding: 6px 0;
}
/* Lyrics group: flex column for order switching */
.lyrics-group { display: flex; flex-direction: column; }
.lyrics-group > .lyrics-line { order: 0; }
.lyrics-group > .lyrics-roman { order: 1; }
.lyrics-group > .lyrics-translation { order: 2; }

.lyrics-roman {
  font-size: var(--roman-size, 13px);
  font-weight: 400;
  line-height: 1.4;
  color: #727272;
  padding: 0 0 4px;
  display: none;
}
.show-roman .lyrics-roman { display: block; }
.lyrics-line.empty { height: 20px; }

/* ── YouTube Sync Highlight ── */
.lyrics-box.yt-syncing .lyrics-line {
  color: #535353;
  transition: color 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}
.lyrics-box.yt-syncing .lyrics-line:hover {
  color: #aaa;
}
.lyrics-box.yt-syncing .lyrics-line.active {
  color: #fff;
  transform: scale(1.05);
}
.lyrics-box.yt-syncing .lyrics-line.active:hover {
  color: #fff;
}
.lyrics-box.yt-syncing .lyrics-line.past {
  color: #888;
}

/* ── Karaoke Word Wipe (AMLL-style: oversized gradient + background-position slide) ── */
.lyrics-line.karaoke .kw {
  display: inline;
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  background-image: linear-gradient(to right, #fff 45%, #535353 55%);
  background-size: 220% 100%;
  background-position: 100% 0;
  white-space: pre-wrap;
  font-variant-ligatures: none;
}

/* In sync mode */
.lyrics-box.yt-syncing .lyrics-line.karaoke {
  color: transparent;
}
.lyrics-box.yt-syncing .lyrics-line.karaoke .kw {
  background-image: linear-gradient(to right, #fff 45%, #535353 55%);
  background-size: 220% 100%;
  background-position: 100% 0; /* fully dim */
}
.lyrics-box.yt-syncing .lyrics-line.karaoke:hover .kw {
  background-image: linear-gradient(to right, #fff 45%, #666 55%);
}

/* Wiping word: animate background-position from right (dim) to left (bright) */
.lyrics-box.yt-syncing .lyrics-line.karaoke .kw.wiping {
  /* animation applied via JS inline style */
}

@keyframes karaoke-wipe {
  from { background-position: 100% 0; }
  to   { background-position: 0% 0; }
}

/* Finished word: fully bright */
.lyrics-box.yt-syncing .lyrics-line.karaoke .kw.sung {
  background-position: 0% 0;
  animation: none !important;
}

/* Active karaoke line: scale up */
.lyrics-box.yt-syncing .lyrics-line.karaoke.active {
  transform: scale(1.05);
  color: transparent;
}
.lyrics-box.yt-syncing .lyrics-line.karaoke.active:hover {
  color: transparent;
}

/* Past karaoke line: all words medium brightness */
.lyrics-box.yt-syncing .lyrics-line.karaoke.past .kw {
  background-image: linear-gradient(to right, #888 45%, #535353 55%);
  background-position: 0% 0;
  animation: none !important;
}

/* ── Sync Calibration Mode ── */
@keyframes calibPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.lyrics-box.calibration-mode {
  outline: 2px solid #1db954;
  outline-offset: -2px;
  border-radius: 8px;
}
.lyrics-box.calibration-mode .lyrics-line[data-time] {
  cursor: crosshair !important;
  transition: background-color 0.15s ease;
  border-radius: 4px;
}
.lyrics-box.calibration-mode .lyrics-line[data-time]:hover {
  background-color: rgba(29, 185, 84, 0.15) !important;
}

.lyrics-translation {
  font-size: var(--trans-size, 13px);
  color: #a78bfa;
  margin-top: 2px;
  line-height: 1.4;
}
.lyrics-box:not(.show-translation) .lyrics-translation { display: none; }

/* ── Toggle ── */
.lyrics-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #b3b3b3;
  user-select: none;
}
.lyrics-toggle input {
  accent-color: #1db954;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.lyrics-toggle:hover { color: #fff; }

/* ── Translation Controls (legacy, hidden) ── */
.translation-select {
  background: #282828;
  color: #b3b3b3;
  border: 1px solid #333;
  border-radius: 500px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.translation-select:focus { border-color: #535353; }
.translation-provider {
  font-size: 11px;
  color: #535353;
  margin-top: 8px;
  padding: 0 28px;
  text-align: right;
}

/* ── Spinner (used by LyricsResult.show) ── */
@keyframes lr-spin { to { transform: rotate(360deg); } }

/* ── AI Translation Generate ── */
.translation-generate {
  margin-top: 8px;
  padding: 0 28px;
  display: none;
}
.translation-generate.show { display: block; }
.translation-generate-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 12px;
  color: #777;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  user-select: none;
}
.translation-generate-toggle:hover { background: #1a1a1a; border-color: #444; color: #999; }
.translation-generate-toggle .chevron {
  font-size: 8px;
  transition: transform .2s;
  display: inline-block;
}
.translation-generate-toggle.open .chevron { transform: rotate(180deg); }
.translation-generate-body {
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #141414;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.22,1,.36,1), opacity .25s ease, padding .3s ease, border-color .3s ease;
}
.translation-generate-body.open {
  max-height: 200px;
  opacity: 1;
  padding: 10px 12px;
  border-color: #272727;
}
.translation-generate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #b3b3b3;
}
.translation-generate-title {
  font-weight: 600;
  color: #fff;
}
.translation-generate-form {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 8px;
}
.translation-generate-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  grid-column: 1 / -1;
}
.translation-generate-input,
.translation-generate-select {
  width: 100%;
  background: #1f1f1f;
  color: #fff;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.translation-generate-input:focus,
.translation-generate-select:focus {
  border-color: #535353;
}
.translation-generate-btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 16px;
  transition: transform 0.1s, background 0.15s;
}
.translation-generate-btn:hover { transform: scale(1.01); background: #f0f0f0; }
.translation-generate-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.translation-generate-msg {
  min-height: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: #8f8f8f;
}
.translation-generate-msg.error { color: #f15e6c; }
.translation-generate-msg.ok { color: #1db954; }

/* ── Auto-scroll return button (sibling above lyrics-box, overlaps via negative margin) ── */
.autoscroll-return {
  display: none;
  position: relative;
  z-index: 10;
  margin: 0 28px -28px auto;
  width: fit-content;
  padding: 6px 14px;
  background: rgba(29, 185, 84, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  border: none;
  border-radius: 500px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  white-space: nowrap;
}
.autoscroll-return:hover { transform: scale(1.05); }
.autoscroll-return:active { transform: scale(1); }
.autoscroll-return.show { display: block; }
.autoscroll-return svg {
  vertical-align: middle;
  margin-right: 3px;
}

/* ── YouTube MV Player ── */
#mvContainer { transition: opacity 0.3s ease; }
#mvPlayerWrap { max-width: 100%; }
#mvPlayer iframe { border-radius: 12px; width: 100%; height: 100%; }
#mvControls { padding: 0 4px; }
#mvSubmitBtn:hover { background: #333 !important; color: #fff !important; }
#mvSubmitForm input:focus { outline: none; border-color: #1db954; }
.mv-adj-btn {
  padding: 3px 8px;
  border-radius: 6px;
  background: #282828;
  color: #b3b3b3;
  border: 1px solid #333;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.mv-adj-btn:hover { background: #333; color: #fff; }
.mv-adj-btn:active { background: #444; }
.mv-type-pill { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 500px; border: 1px solid #444; background: #222; color: #888; font-size: 12px; cursor: pointer; transition: all 0.15s; }
.mv-type-pill.active { border-color: #8b5cf6; color: #fff; background: rgba(139,92,246,0.15); }

/* ── Artwork Carousel (fade) ── */
.result-art-wrap {
  position: relative;
  flex-shrink: 0;
}
.result-art.carousel {
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.result-art.carousel .art-slide {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.result-art.carousel .art-slide.active {
  opacity: 1;
  pointer-events: auto;
}
.result-art.carousel .art-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
/* Tap bounce */
.result-art.carousel.pressing {
  transform: scale(0.92);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.result-art.carousel.bounce-back {
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.art-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 6px;
}
.art-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background 0.2s, transform 0.2s;
}
.art-dot.active {
  background: #fff;
  transform: scale(1.3);
}
/* Fullscreen artwork preview */
.art-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}
.art-preview-overlay.show { opacity: 1; }
.art-preview-overlay img {
  max-width: min(90vw, 600px);
  max-height: min(80vh, 600px);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transform: scale(0.85);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  -webkit-user-drag: none;
}
.art-preview-overlay.show img {
  transform: scale(1);
}
.art-preview-album {
  margin-top: 16px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  text-align: center;
}
.art-preview-dots {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.art-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}
.art-preview-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* ── Danmaku Lyrics Overlay ── */
.danmaku-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.danmaku-line {
  position: absolute;
  white-space: nowrap;
  font-weight: 700;
  line-height: 1.3;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.8), -1px -1px 3px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5);
  will-change: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.danmaku-line.dm-original { color: #fff; font-size: 22px; }
.danmaku-line.dm-roman { color: #a5f3fc; font-size: 17px; }
.danmaku-line.dm-translation { color: #fde68a; font-size: 17px; }
@media (max-width: 600px) {
  .danmaku-line.dm-original { font-size: 16px; }
  .danmaku-line.dm-roman { font-size: 13px; }
  .danmaku-line.dm-translation { font-size: 13px; }
}

/* ── MV Fullscreen Button ── */
.mv-fullscreen-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 5;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mvPlayerWrap:hover .mv-fullscreen-btn { opacity: 1; }
#mvPlayerWrap:fullscreen { border-radius: 0; }
#mvPlayerWrap:fullscreen .mv-fullscreen-btn { opacity: 1; }
#mvPlayerWrap:-webkit-full-screen { border-radius: 0; }

/* ── Fullscreen Lyrics ── */
.fs-lyrics-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: #000; display: flex; flex-direction: column;
  opacity: 0; transition: opacity 0.3s ease;
}
.fs-lyrics-overlay.show { opacity: 1; }
.fs-lyrics-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(40px) brightness(0.3); transform: scale(1.2);
}
.fs-lyrics-header {
  position: relative; z-index: 1; text-align: center;
  padding: 48px 24px 16px;
}
.fs-lyrics-title { font-size: 28px; font-weight: 800; color: #fff; }
.fs-lyrics-artist { font-size: 16px; color: rgba(255,255,255,0.6); margin-top: 8px; }
.fs-lyrics-body {
  position: relative; z-index: 1; flex: 1; overflow-y: auto;
  padding: 16px 48px 120px; text-align: center;
  font-size: 24px; line-height: 2; color: rgba(255,255,255,0.85);
}
.fs-lyrics-body .lyrics-line { font-size: 24px; }
.fs-lyrics-body .lyrics-roman { display: none; }
.fs-lyrics-body .lyrics-translation { display: none; }
.fs-lyrics-body.show-roman .lyrics-roman { display: block; }
.fs-lyrics-body.show-translation .lyrics-translation { display: block; }
.fs-lyrics-body.main-roman:not(.main-translation) .lyrics-group > .lyrics-roman { font-size: 24px; opacity: 1; }
.fs-lyrics-body.main-roman:not(.main-translation) .lyrics-group > .lyrics-line { font-size: 14px; opacity: 0.5; }
.fs-lyrics-body.main-translation:not(.main-roman) .lyrics-group > .lyrics-translation { font-size: 24px; opacity: 1; }
.fs-lyrics-body.main-translation:not(.main-roman) .lyrics-group > .lyrics-line { font-size: 14px; opacity: 0.5; }
.fs-lyrics-close {
  position: absolute; top: 16px; right: 20px; z-index: 2;
  background: none; border: none; color: rgba(255,255,255,0.6);
  font-size: 32px; cursor: pointer; padding: 8px;
  transition: color 0.15s;
}
.fs-lyrics-close:hover { color: #fff; }

/* ── Lyrics Search Bar ── */
.lyrics-search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 28px; background: #1a1a1a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.lyrics-search-bar input {
  flex: 1; background: #282828; border: 1px solid #444;
  border-radius: 6px; padding: 6px 12px; color: #fff;
  font-size: 14px; outline: none;
}
.lyrics-search-bar input:focus { border-color: #8b5cf6; }
#lyricsSearchCount { font-size: 12px; color: #888; white-space: nowrap; }
#lyricsSearchClose {
  background: none; border: none; color: #888; font-size: 20px;
  cursor: pointer; padding: 4px 8px;
}
#lyricsSearchClose:hover { color: #fff; }
.lyrics-search-hit { background: rgba(139,92,246,0.15) !important; border-radius: 4px; }
.lyrics-search-current { background: rgba(139,92,246,0.35) !important; }

/* ── Shortcuts Help ── */
.shortcuts-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s ease;
}
.shortcuts-overlay.show { opacity: 1; }
.shortcuts-panel {
  background: #1e1e1e; border-radius: 16px; padding: 28px 32px;
  max-width: 420px; width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.shortcuts-panel h3 { margin: 0 0 20px; font-size: 18px; color: #fff; font-weight: 700; }
.shortcuts-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 16px;
  align-items: center;
}
.shortcuts-grid kbd {
  background: #333; color: #fff; padding: 3px 10px; border-radius: 6px;
  font-size: 13px; font-family: inherit; border: 1px solid #555;
  text-align: center; min-width: 40px;
}
.shortcuts-grid span { font-size: 14px; color: #b3b3b3; }
.shortcuts-close {
  display: block; margin: 20px auto 0; padding: 8px 32px;
  background: #8b5cf6; color: #fff; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.shortcuts-close:hover { background: #7c3aed; }

/* ── Lyrics font size via CSS var ── */
#lyrics { font-size: var(--lyrics-size, 16px); }

/* ── Mobile ── */
@media (max-width: 600px) {
  .result-art { width: 64px; height: 64px; }
  .lyrics-search-bar { padding: 8px 16px; }
  .fs-lyrics-body { padding: 16px 24px 100px; font-size: 20px; }
  .fs-lyrics-body .lyrics-line { font-size: 20px; }
  .result-title { font-size: 16px; }
  .lyrics-toolbar { padding: 0 16px; }
  .lt-chip { font-size: 12px; padding: 4px 10px; }
  .lt-aa-btn { font-size: 12px; padding: 3px 8px; }
  .lt-font-btn { font-size: 10px; padding: 2px 6px; }
  .mode-pill { font-size: 11px; padding: 2px 9px; }
  .translation-generate-form {
    grid-template-columns: 1fr;
  }
  .translation-generate-row {
    grid-template-columns: 1fr;
  }
  #mvContainer { padding: 0 16px 10px !important; }
}
