/* Song detail page. Loads after base.css.
   Hero (cover + facts + actions) → chart player → difficulties | downloads → direct file links. */

/* ---------- Loading / error ---------- */
.loading-state { padding-top: 24px; }
.song-skeleton { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.song-skeleton .sk-cover { aspect-ratio: 1; border-radius: 16px; background: var(--surface-2); }
.song-skeleton .sk-lines { display: flex; flex-direction: column; gap: 14px; padding-top: 24px; }
.song-skeleton .sk-lines span { height: 14px; border-radius: 6px; background: var(--surface-2); }
.song-skeleton .sk-lines span:nth-child(1) { width: 70%; height: 30px; }
.song-skeleton .sk-lines span:nth-child(2) { width: 40%; }
.song-skeleton .sk-lines span:nth-child(3) { width: 85%; height: 120px; margin-top: 12px; border-radius: 12px; }
.song-skeleton { position: relative; overflow: hidden; }
.song-skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface) 60%, transparent) 50%, transparent 70%); transform: translateX(-100%); animation: sweep 1.3s ease-in-out infinite; }
@keyframes sweep { to { transform: translateX(100%); } }
.error-state { flex-direction: column; align-items: center; gap: 10px; padding: 72px 16px; text-align: center; color: var(--muted); }
.error-state h2 { color: var(--text); font-size: 20px; }
.error-state .btn { margin-top: 8px; }
.seo-song-static { padding-top: 24px; color: var(--muted); }
.seo-song-static .seo-song-heading { margin-bottom: 12px; color: var(--text); font-size: 22px; }
.seo-song-static ul { margin: 0 0 12px; padding-left: 1.1em; line-height: 1.8; }
.seo-song-static a { color: var(--accent); }

/* ---------- Hero ---------- */
.song-content { padding-bottom: 24px; }
.song-hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: center; gap: 36px;
  margin-top: 16px; padding: 28px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  animation: rise 360ms var(--ease) backwards;
}
/* Ambient backdrop: a tiny copy of the cover, blurred into a wash of its colours. */
.song-hero::before {
  content: ""; position: absolute; inset: -60px; z-index: -1;
  background: var(--cover, none) center / cover no-repeat;
  filter: blur(56px) saturate(1.5);
  opacity: 0.42;
}
html[data-theme="dark"] .song-hero::before { opacity: 0.32; }
.song-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, transparent 25%, var(--surface) 95%); opacity: 0.55; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.song-cover-wrapper { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 16px; background: var(--surface-2); box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--line) 60%, transparent); }
.song-cover { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 320ms ease; view-transition-name: song-cover; }
.song-cover.is-loaded { opacity: 1; }
.cover-badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; }
.chart-type-badge { padding: 3px 9px; border-radius: 7px; color: #fff; font: 800 12px/1.5 var(--display); letter-spacing: 0.04em; background: rgb(15 17 19 / 70%); }
.chart-type-badge.dx { background: linear-gradient(135deg, #ff6aa8, #ffad47); }
.chart-type-badge.st { background: linear-gradient(135deg, #3c86ff, #3fcbe6); }
.chart-type-badge.utg { background: linear-gradient(135deg, #b25cff, #ff5ab4); }
.oc-badge { padding: 3px 9px; border-radius: 7px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; }
.song-info { min-width: 0; }
.eyebrow { margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; }
.song-title { font-size: clamp(26px, 3vw, 38px); font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.song-artist { margin-top: 8px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.meta-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px 0 20px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 82%, transparent);
}
.meta-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 16px; border-left: 1px solid var(--line); }
.meta-grid > div:nth-child(3n + 1) { border-left: 0; }
.meta-grid > div:nth-child(n + 4) { border-top: 1px solid var(--line); }
.meta-grid span { color: var(--muted); font-size: 11px; }
.meta-grid strong { overflow: hidden; font-size: 15px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.archive-song-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Sections ---------- */
.song-section { margin-top: 40px; scroll-margin-top: calc(var(--header-h) + 16px); }
.archive-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.archive-section-heading h2 { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; }
.archive-section-heading > span { color: var(--muted); font-size: 12px; }
.archive-detail-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }

/* Difficulties */
.preview-diff-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.preview-diff-row { display: grid; grid-template-columns: 104px 56px minmax(0, 1fr); align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.preview-diff-name { color: var(--muted); font-size: 12px; font-weight: 600; }
.preview-diff-level { padding: 4px 6px; border-radius: 7px; background: var(--c, var(--faint)); color: var(--c-text, #fff); font-size: 13px; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.preview-diff-designer { overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.preview-empty-line { padding: 16px; color: var(--muted); font-size: 13px; }

/* Downloads */
.archive-download-hint { margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.archive-download-hint .archive-astrodx-link { color: var(--accent); font-weight: 600; white-space: nowrap; }
.archive-download-hint .archive-astrodx-link:hover { text-decoration: underline; }
.download-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.archive-format-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.archive-format-group h3 { font-family: var(--display); font-size: 14px; font-weight: 800; letter-spacing: 0.02em; }
.download-btn {
  width: 100%; min-height: 46px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  font-size: 13px; font-weight: 600; line-height: 1.4;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms var(--ease);
}
.download-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.download-btn:active:not(:disabled) { transform: scale(0.98); }
.download-btn.primary { border-color: var(--text); background: var(--text); color: var(--bg); }
.download-btn.primary:hover:not(:disabled) { border-color: var(--text); background: var(--text); color: var(--bg); opacity: 0.88; }
.download-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Direct file links */
.files-hint { margin-bottom: 12px; color: var(--muted); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.files-hint code, .song-files code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.file-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.file-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 10px 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.file-name { min-width: 0; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-size { margin-left: auto; flex: none; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.file-get, .file-copy { flex: none; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 12px; font-weight: 600; transition: border-color 160ms ease, color 160ms ease; }
.file-get:hover, .file-copy:hover { border-color: var(--accent); color: var(--accent); }
.file-copy.done { border-color: var(--ok); color: var(--ok); }

/* ---------- Chart player (DOM from chart-player.js) ---------- */
.chart-player-host { min-width: 0; }
.preview-fallback { padding: 40px 16px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); font-size: 13px; text-align: center; }
.chart-player { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.chart-player-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chart-player-head h3 { font-size: 15px; font-weight: 700; }
.chart-player-status { margin-top: 2px; color: var(--muted); font-size: 12px; }
.chart-player-difficulties { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chart-player-difficulty {
  min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px;
  background: var(--c, var(--faint)); color: var(--c-text, #fff);
  font-size: 12px; font-weight: 750; opacity: 0.45;
  transition: opacity 160ms ease, transform 160ms var(--ease), box-shadow 160ms ease;
}
.chart-player-difficulty:hover { opacity: 0.8; }
.chart-player-difficulty.is-active { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.chart-player-stage-grid { display: grid; grid-template-columns: minmax(340px, 0.9fr) minmax(300px, 1.1fr); background: #0b0d10; }
.chart-player-canvas-wrap { position: relative; min-width: 0; aspect-ratio: 1; overflow: hidden; background: #050607; }
.chart-player-canvas { display: block; width: 100%; height: 100%; }
.chart-player-loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: #0b0d10; color: #d6dde3; font-size: 13px; text-align: center; }
.chart-player-statements { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid #23282e; background: #121519; color: #e3e7eb; }
.chart-player-statements-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #23282e; }
.chart-player-statements-head strong { font-size: 13px; }
.chart-player-statements-head span { color: #8a929b; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-player-statement-list { display: flex; flex: 1 1 auto; flex-direction: column; gap: 4px; min-height: 0; overflow: auto; padding: 10px; scrollbar-width: thin; scrollbar-color: #2c3238 transparent; }
.chart-player-statement-row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: start; gap: 8px;
  width: 100%; min-height: 38px; padding: 8px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: #a6aeb6; text-align: left;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chart-player-statement-row:hover { background: #1a1e23; color: #e3e7eb; }
.chart-player-statement-row.is-active { border-color: #33476d; background: #1a2436; color: #fff; }
.chart-player-statement-beat { color: #6c757e; font-variant-numeric: tabular-nums; }
.chart-player-statement-chunks { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.chart-player-statement-chunks span { padding: 1px 3px; border-radius: 4px; }
.chart-player-statement-chunks .is-current { background: var(--d7); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--d7) 35%, transparent); }
.chart-player-controls {
  display: grid; grid-template-columns: auto 40px minmax(140px, 1fr) 40px minmax(104px, 0.35fr) auto auto;
  align-items: center; gap: 10px; min-height: 60px; padding: 10px 14px; border-top: 1px solid var(--line);
}
.chart-player-play, .chart-player-fullscreen, .chart-player-speed {
  min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 12px; font-weight: 700;
}
.chart-player-play, .chart-player-fullscreen { padding: 0 14px; transition: background 160ms ease, border-color 160ms ease, transform 160ms var(--ease); }
.chart-player-play { min-width: 72px; border-color: var(--text); background: var(--text); color: var(--bg); }
.chart-player-play:hover:not(:disabled) { opacity: 0.88; }
.chart-player-play:active:not(:disabled), .chart-player-fullscreen:active { transform: scale(0.96); }
.chart-player-play:disabled { opacity: 0.45; cursor: wait; }
.chart-player-fullscreen:hover { border-color: var(--accent); color: var(--accent); }
.chart-player-progress, .chart-player-volume input { width: 100%; accent-color: var(--accent); }
.chart-player-time { color: var(--muted); font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.chart-player-volume { display: grid; grid-template-columns: auto minmax(56px, 1fr); align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.chart-player-speed { padding: 0 8px; }
.chart-player > audio, .chart-player > video { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.chart-player:fullscreen { display: flex; flex-direction: column; width: 100vw; height: 100vh; border: 0; border-radius: 0; background: #0b0d10; }
.chart-player:fullscreen .chart-player-stage-grid { flex: 1 1 auto; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(340px, 0.62fr); }
.chart-player:fullscreen .chart-player-canvas-wrap { width: auto; height: 100%; max-height: calc(100vh - 130px); margin: 0 auto; }

/* ---------- Responsive ---------- */
@media (max-width: 999px) {
  .song-hero, .song-skeleton { grid-template-columns: 200px minmax(0, 1fr); gap: 24px; padding: 22px; }
  .archive-detail-bottom { grid-template-columns: minmax(0, 1fr); }
  .file-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .chart-player-head { flex-direction: column; align-items: flex-start; padding: 12px; }
  .chart-player-difficulties { justify-content: flex-start; }
  .chart-player-stage-grid { grid-template-columns: minmax(0, 1fr); }
  .chart-player-statements { min-height: 240px; max-height: 320px; border-top: 1px solid #23282e; border-left: 0; }
  .chart-player-controls { grid-template-columns: auto 36px minmax(80px, 1fr) 36px; gap: 8px; padding: 10px; }
  .chart-player-volume { grid-column: 1 / 5; grid-row: 2; }
  .chart-player-speed { grid-column: 1 / 3; grid-row: 3; }
  .chart-player-fullscreen { grid-column: 3 / 5; grid-row: 3; }
}
@media (max-width: 560px) {
  .song-hero, .song-skeleton { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 16px; border-radius: 18px; }
  .song-cover-wrapper, .song-skeleton .sk-cover { width: 168px; }
  .song-title { font-size: 24px; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-grid > div { padding: 10px 12px; }
  .meta-grid > div:nth-child(3n + 1) { border-left: 1px solid var(--line); }
  .meta-grid > div:nth-child(2n + 1) { border-left: 0; }
  .meta-grid > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .archive-song-actions .btn { flex: 1 1 calc(50% - 4px); }
  .song-section { margin-top: 32px; }
  .preview-diff-row { grid-template-columns: 84px 48px minmax(0, 1fr); gap: 8px; padding: 10px; }
  .download-buttons { grid-template-columns: minmax(0, 1fr); }
  .file-row { flex-wrap: wrap; }
}
