/* CSS Variables */
:root {
  --font-family: 'Inter', sans-serif;
  --bg-dark: #0f0f0f;
  --bg-deep: #0f0f0f;
  --bg-panel: rgba(18, 18, 20, 0.82);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  --text-primary: #e8e8ec;
  --text-secondary: #6e6e78;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --grid-line: rgba(80, 80, 88, 0.12);
  --light-glow: rgba(40, 42, 48, 0.2);
  --error: #ff4d6a;
  --input-bg: rgba(0, 0, 0, 0.5);
  --input-border: rgba(255, 255, 255, 0.08);
  --input-focus: rgba(0, 212, 170, 0.4);
  --platform-spotify: #1db954;
  --platform-apple: #fa243c;
  --platform-youtube: #ff0000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Animated retro background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    /* Secondary glow - bottom left */
    radial-gradient(
      ellipse 60% 50% at 15% 85%,
      rgba(18, 18, 20, 0.06) 0%,
      transparent 45%
    ),
    /* Base */
    linear-gradient(
      165deg,
      var(--bg-dark) 0%,
      #121212 25%,
      var(--bg-deep) 50%,
      #0d0d0d 100%
    );
  animation: bgShift 14s ease-in-out infinite alternate;
}

/* Cursor-following light source */
.light-source {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(
    ellipse 80% 55% at var(--light-x, 85%) var(--light-y, 15%),
    rgba(45, 48, 54, 0.28) 0%,
    rgba(28, 30, 36, 0.12) 40%,
    transparent 65%
  );
  transition: opacity 0.3s;
  will-change: background;
}

@keyframes bgShift {
  0% { opacity: 1; filter: brightness(0.98); }
  100% { opacity: 0.95; filter: brightness(1.02); }
}

/* Subtle scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
}

/* Grid overlay – base lines */
.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.grid-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridPulse 8s ease-in-out infinite;
}

/* Light source reveals grid subtly near cursor */
.grid-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(100, 100, 110, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 100, 110, 0.15) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(
    ellipse 35% 35% at var(--light-x, 85%) var(--light-y, 15%),
    black 0%,
    transparent 70%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 35% 35% at var(--light-x, 85%) var(--light-y, 15%),
    black 0%,
    transparent 70%
  );
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Centered container */
.container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Page load: animate header and input in */
.header {
  text-align: center;
  margin-bottom: 40px;
  animation: loadIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.input-section {
  animation: loadIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.1s backwards;
}

@keyframes loadIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-transform: lowercase;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tagline {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Input section */
.input-section {
  width: 100%;
  margin-bottom: 32px;
}

.input-wrapper {
  background: var(--input-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--input-border);
  padding: 0;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 1px var(--input-focus);
}

#url-input {
  width: 100%;
  padding: 16px 18px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 1rem;
  outline: none;
}

#url-input::placeholder {
  color: var(--text-secondary);
}

/* Glassy results panel */
#results[hidden] {
  display: none !important;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  overflow: hidden;
}

.results {
  width: 100%;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.results.results--visible {
  opacity: 1;
  transform: translateY(0);
}

.track-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.track-art {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 0px;
  object-fit: cover;
  border: 1px solid var(--glass-border);
}

.track-info-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.close-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-family: var(--font-family);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.close-btn:hover {
  color: var(--error);
  border-color: rgba(255, 77, 106, 0.3);
  background: rgba(255, 77, 106, 0.08);
}

.close-btn svg {
  width: 16px;
  height: 16px;
}

.platform-list {
  list-style: none;
  width: 100%;
}

.platform-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.15s;
}

.platform-item:last-child {
  border-bottom: none;
}

.platform-item:hover {
  background: var(--glass-highlight);
}

.platform-item:hover .platform-link {
  color: var(--accent);
}

.platform-item:hover .copy-btn:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-dim);
}

.platform-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
}

.platform-link--share {
  cursor: inherit;
}

.platform-icon-img {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.platform-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-url {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .platform-url {
    display: none;
  }
}

.copy-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-family: var(--font-family);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-dim);
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

/* Loading */
.loading {
  width: 100%;
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.loading-text {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Error */
.error {
  padding: 16px 20px;
  color: var(--error);
  font-size: 0.9rem;
  background: rgba(255, 77, 106, 0.08);
  border-top: 1px solid rgba(255, 77, 106, 0.2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
