/* ============================================================================
 * AudioMark — Dark Studio Console & Editorial Light Theme Stylesheet
 * Audited & Upgraded via Leonxlnx/taste-skill (redesign-existing-projects)
 * Default Theme: Dark Studio Console (data-theme="dark")
 * ============================================================================ */

:root,
[data-theme="dark"] {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Dark Studio Console Palette (Warm Obsidian & Luminous Amber) */
  --surface-canvas: #11100E;
  --surface-header: rgba(17, 16, 14, 0.88);
  --surface-card: #1A1816;
  --surface-subtle: #151311;
  --surface-inset: #25221F;
  --surface-inset-hover: #302C28;
  --surface-active-row: rgba(217, 119, 6, 0.12);
  --surface-modal-backdrop: rgba(8, 7, 6, 0.78);

  --ink-primary: #F5F1E9;
  --ink-secondary: #A8A093;
  --ink-muted: #756D60;
  --logo-audio-fill: #F5F1E9;
  --logo-mark-fill: #F59E0B;

  --border-hairline: #2B2723;
  --border-strong: #3D3731;

  --accent-amber: #D97706;
  --accent-amber-hover: #F59E0B;
  --accent-gold: #FBBF24;
  --accent-soft-bg: rgba(245, 158, 11, 0.15);
  --accent-soft-text: #FCD34D;

  --slider-track: #2E2A25;
  --slider-thumb-bg: #F5F1E9;
  --slider-thumb-border: #1A1816;

  --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-console: 0 16px 36px -12px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
  /* Editorial Warm Archival Paper Palette */
  --surface-canvas: #F5F1E9;
  --surface-header: rgba(245, 241, 233, 0.9);
  --surface-card: #FFFFFF;
  --surface-subtle: #FAF8F3;
  --surface-inset: #ECE6DA;
  --surface-inset-hover: #E2DACB;
  --surface-active-row: #FDF9F0;
  --surface-modal-backdrop: rgba(23, 21, 19, 0.6);

  --ink-primary: #171513;
  --ink-secondary: #575148;
  --ink-muted: #877F72;
  --logo-audio-fill: #171513;
  --logo-mark-fill: #B45309;

  --border-hairline: #E4DDD0;
  --border-strong: #D3C9B8;

  --accent-amber: #B45309;
  --accent-amber-hover: #92400E;
  --accent-gold: #D97706;
  --accent-soft-bg: #FEF3C7;
  --accent-soft-text: #92400E;

  --slider-track: #E2DBD0;
  --slider-thumb-bg: #171513;
  --slider-thumb-border: #FAF7F2;

  --shadow-console: 0 10px 30px -10px rgba(23, 21, 19, 0.06), 0 2px 6px -1px rgba(23, 21, 19, 0.04);
}

html {
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body {
  font-family: var(--font-sans);
  background-color: var(--surface-canvas);
  color: var(--ink-primary);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.22s var(--ease-out-expo), color 0.22s var(--ease-out-expo);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Semantic Theme Classes */
.theme-header {
  background-color: var(--surface-header);
  border-bottom: 1px solid var(--border-hairline);
}

.console-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-console);
}

.utility-panel {
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
}

.surface-subtle {
  background-color: var(--surface-subtle);
}

.surface-inset {
  background-color: var(--surface-inset);
}

.surface-card {
  background-color: var(--surface-card);
}

.border-seam {
  border-color: var(--border-hairline);
}

.border-strong {
  border-color: var(--border-strong);
}

.text-ink-primary {
  color: var(--ink-primary);
}

.text-ink-secondary {
  color: var(--ink-secondary);
}

.text-ink-muted {
  color: var(--ink-muted);
}

.text-accent {
  color: var(--accent-gold);
}

.logo-audio-group {
  fill: var(--logo-audio-fill);
  transition: fill 0.2s var(--ease-out-expo);
}

.logo-mark-group {
  fill: var(--logo-mark-fill);
  transition: fill 0.2s var(--ease-out-expo);
}

.console-input {
  background-color: var(--surface-card);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  transition: border-color 0.16s var(--ease-out-expo), background-color 0.16s var(--ease-out-expo);
}

[data-theme="dark"] .console-input {
  background-color: #141210;
}

.console-input::placeholder {
  color: var(--ink-muted);
}

.console-input:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.console-btn-secondary {
  background-color: var(--surface-inset);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
}

.console-btn-secondary:hover {
  background-color: var(--surface-inset-hover);
}

.console-btn-primary {
  background-color: var(--accent-amber);
  color: #FAF7F2;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.console-btn-primary:hover {
  background-color: var(--accent-amber-hover);
}

/* Numeric & Typographic Discipline */
.font-mono-tabular,
#currentTimeLabel,
#durationLabel,
#coverTrackNum,
#speedLabel,
#sleepLabel,
#libraryCountBadge,
#bookmarkCount,
#overallProgressLabel,
#idbStorageBadge {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.heading-tight {
  letter-spacing: -0.024em;
}

.micro-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

/* Custom Minimal Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-amber);
}

/* Dynamic Filled Range Sliders (Seek & Volume) */
input[type="range"].seek-slider {
  --slider-pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 9999px;
  background: linear-gradient(
    to right,
    var(--accent-amber) 0%,
    var(--accent-gold) var(--slider-pct),
    var(--slider-track) var(--slider-pct),
    var(--slider-track) 100%
  );
  outline: none;
  cursor: pointer;
  transition: height 0.18s var(--ease-out-expo), box-shadow 0.18s var(--ease-out-expo);
}

input[type="range"].seek-slider:hover {
  height: 8px;
}

input[type="range"].seek-slider:focus-visible {
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}

input[type="range"].seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--slider-thumb-bg);
  border: 2.5px solid var(--slider-thumb-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.18s var(--ease-out-expo), background-color 0.18s var(--ease-out-expo), box-shadow 0.18s var(--ease-out-expo);
}

input[type="range"].seek-slider:hover::-webkit-slider-thumb {
  transform: scale(1.18);
  background: var(--accent-gold);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2), 0 2px 5px rgba(0, 0, 0, 0.4);
}

input[type="range"].seek-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--slider-thumb-bg);
  border: 2.5px solid var(--slider-thumb-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.18s var(--ease-out-expo), background-color 0.18s var(--ease-out-expo);
}

input[type="range"].seek-slider:hover::-moz-range-thumb {
  transform: scale(1.18);
  background: var(--accent-gold);
}

/* Tactile Console Buttons & Hover Physics */
.btn-tactile {
  transition: transform 0.18s var(--ease-out-expo), background-color 0.18s var(--ease-out-expo), border-color 0.18s var(--ease-out-expo), color 0.18s var(--ease-out-expo), box-shadow 0.18s var(--ease-out-expo);
}

.btn-tactile:hover {
  transform: translateY(-1px);
}

.btn-tactile:active {
  transform: translateY(0px) scale(0.97);
}

.btn-tactile:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* Tactile Vinyl / Audiobook Disc Sleeve */
.disc-sleeve {
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.disc-groove {
  position: absolute;
  inset: 7px;
  border-radius: 9999px;
  border: 1px dashed rgba(250, 247, 242, 0.16);
  pointer-events: none;
}

@keyframes slowSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

body.is-playing .disc-groove {
  animation: slowSpin 14s linear infinite;
  border-color: rgba(245, 158, 11, 0.4);
}

/* Track List Row States & Mini Playing Equalizer */
.track-item {
  position: relative;
  transition: background-color 0.16s var(--ease-out-expo);
}

.track-item:hover {
  background-color: var(--surface-inset);
}

.track-item.is-active {
  background-color: var(--surface-active-row);
}

.track-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3.5px;
  border-radius: 0 4px 4px 0;
  background-color: var(--accent-gold);
}

/* Mini Equalizer Bars inside active track row */
.mini-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.mini-eq span {
  width: 2.2px;
  background-color: currentColor;
  border-radius: 1px;
  height: 4px;
}

body.is-playing .mini-eq span:nth-child(1) {
  animation: eqBounce 0.7s ease-in-out infinite;
}
body.is-playing .mini-eq span:nth-child(2) {
  animation: eqBounce 0.55s ease-in-out 0.15s infinite;
}
body.is-playing .mini-eq span:nth-child(3) {
  animation: eqBounce 0.8s ease-in-out 0.3s infinite;
}

@keyframes eqBounce {
  0%, 100% {
    height: 3px;
  }
  50% {
    height: 12px;
  }
}

.modal-backdrop {
  background-color: var(--surface-modal-backdrop);
}

/* Toast animation */
#toast {
  transition: opacity 0.2s var(--ease-out-expo), transform 0.2s var(--ease-out-expo);
}

/* AudioMark Soundwave Wordmark Animation */
.sw-bar {
  transform-box: fill-box;
  transform-origin: center center;
  transition: transform 0.25s var(--ease-out-expo);
}

@keyframes soundwavePulse {
  0%, 100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.55);
  }
}

body.is-playing .sw-1,
.audiomark-wave-logo:hover .sw-1 {
  animation: soundwavePulse 0.9s ease-in-out infinite;
}

body.is-playing .sw-2,
.audiomark-wave-logo:hover .sw-2 {
  animation: soundwavePulse 0.75s ease-in-out 0.18s infinite;
}

body.is-playing .sw-3,
.audiomark-wave-logo:hover .sw-3 {
  animation: soundwavePulse 1.05s ease-in-out 0.35s infinite;
}
