/* ============================================
   Simple Knob - High-End Audio Equipment Style
   ============================================ */

:root {
  /* Base colors */
  --bg-deep: #0a0a0c;
  --bg-surface: #111114;
  --bg-elevated: #18181c;

  /* Metal colors */
  --metal-dark: #1a1a1e;
  --metal-mid: #2a2a30;
  --metal-light: #3a3a42;
  --metal-highlight: #4a4a55;

  /* Accent - Warm brass/gold */
  --accent-primary: #c9a962;
  --accent-bright: #e5c77a;
  --accent-glow: rgba(201, 169, 98, 0.4);
  --accent-dim: #8a7444;

  /* Text */
  --text-primary: #e8e8ec;
  --text-secondary: #8a8a96;
  --text-muted: #5a5a66;

  /* Fonts */
  --font-display: 'Instrument Sans', -apple-system, sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* Shadows */
  --shadow-deep: 0 20px 60px rgba(0, 0, 0, 0.8);
  --shadow-knob:
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-display);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Texture overlay for depth */
.texture-overlay {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 1000;
}

/* Ambient glow effect */
.ambient-glow {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* Header */
.header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent-primary);
}

.back-link svg {
  transition: transform 0.2s;
}

.back-link:hover svg {
  transform: translateX(-3px);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  background: rgba(201, 169, 98, 0.1);
  color: var(--accent-primary);
  border-radius: 4px;
  border: 1px solid rgba(201, 169, 98, 0.2);
}

/* Main */
.main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 24px 100px;
}

/* Demo Section */
.demo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  margin-bottom: 80px;
}

/* Knob Container */
.knob-container {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 60px;
}

/* Tick Ring */
.tick-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tick {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 12px;
  background: var(--metal-light);
  transform-origin: center 140px;
  border-radius: 1px;
}

.tick.major {
  height: 16px;
  width: 3px;
  background: var(--accent-dim);
}

.tick.active {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Main Knob */
.knob {
  position: relative;
  width: 160px;
  height: 160px;
  cursor: grab;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.knob:active {
  cursor: grabbing;
}

.knob:focus-visible .knob-cap {
  box-shadow:
    inset 0 -4px 12px rgba(0, 0, 0, 0.5),
    inset 0 4px 8px rgba(255, 255, 255, 0.05),
    0 0 0 3px var(--accent-primary);
}

.knob-body {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 0.05s ease-out;
}

.knob-cap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 80% 40% at 30% 20%, rgba(255, 255, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 30% at 70% 80%, rgba(0, 0, 0, 0.3), transparent),
    linear-gradient(160deg, var(--metal-mid) 0%, var(--metal-dark) 100%);
  box-shadow:
    inset 0 -4px 12px rgba(0, 0, 0, 0.5),
    inset 0 4px 8px rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

/* Metallic ring effect */
.knob-cap::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    radial-gradient(ellipse 70% 35% at 35% 25%, rgba(255, 255, 255, 0.06), transparent),
    linear-gradient(170deg, var(--metal-mid) 0%, var(--metal-dark) 100%);
}

/* Knob center ring */
.knob-cap::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 40%, var(--metal-highlight), var(--metal-dark));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Indicator line */
.knob-indicator {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, var(--accent-bright) 0%, var(--accent-primary) 100%);
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow:
    0 0 12px var(--accent-glow),
    0 0 4px var(--accent-primary);
  z-index: 10;
}

/* Grip texture */
.knob-grip {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 4deg,
    rgba(0, 0, 0, 0.15) 4deg 8deg
  );
  pointer-events: none;
}

/* Knob shadow */
.knob-shadow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.4) 30%, transparent 70%);
  transform: translateY(20px);
  filter: blur(20px);
  z-index: -1;
}

/* Hover/Active states */
.knob:hover .knob-indicator {
  box-shadow:
    0 0 20px var(--accent-glow),
    0 0 8px var(--accent-primary);
}

.knob.dragging .knob-cap {
  box-shadow:
    inset 0 -4px 12px rgba(0, 0, 0, 0.5),
    inset 0 4px 8px rgba(255, 255, 255, 0.05),
    0 0 0 2px rgba(201, 169, 98, 0.3);
}

/* Value Display */
.value-display {
  position: absolute;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.value-number {
  display: block;
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.value-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* Control Info */
.control-info {
  display: flex;
  gap: 32px;
  padding: 16px 24px;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.control-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-primary);
}

/* Variants Section */
.variants-section {
  margin-top: 40px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.variants-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.variant-card {
  background: var(--bg-elevated);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 32px 24px;
  display: flex;
  justify-content: center;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.variant-card:hover {
  border-color: rgba(201, 169, 98, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.mini-knob-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Small knob variant */
.knob.knob-small {
  width: 80px;
  height: 80px;
}

.knob-small .knob-cap::before {
  inset: 4px;
}

.knob-small .knob-cap::after {
  width: 20px;
  height: 20px;
}

.knob-small .knob-indicator {
  top: 8px;
  width: 3px;
  height: 14px;
}

.knob-small .knob-grip {
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 6deg,
    rgba(0, 0, 0, 0.12) 6deg 12deg
  );
}

.variant-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.variant-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.variant-label small {
  font-size: 9px;
  opacity: 0.7;
}

/* ─────────────────────────────────────────────────────────
   Mobile-first responsive enhancements
   ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px;
    text-align: center;
  }

  .header-title {
    order: -1;
  }

  .main {
    padding: 40px 20px 80px;
  }

  .knob-container {
    width: 240px;
    height: 240px;
    margin-bottom: 50px;
  }

  .knob {
    width: 140px;
    height: 140px;
  }

  .tick {
    transform-origin: center 120px;
  }

  .tick.major {
    height: 14px;
  }

  .knob-indicator {
    top: 12px;
    width: 3px;
    height: 20px;
  }

  .value-display {
    bottom: -50px;
  }

  .value-number {
    font-size: 30px;
  }

  .control-info {
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
  }

  .control-hint {
    justify-content: center;
  }

  .variants-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 14px 16px;
    gap: 12px;
  }

  .header-title h1 {
    font-size: 18px;
  }

  .tag {
    font-size: 9px;
    padding: 3px 8px;
  }

  .back-link {
    font-size: 13px;
  }

  .main {
    padding: 32px 16px 60px;
  }

  .demo-section {
    gap: 36px;
    margin-bottom: 60px;
  }

  .knob-container {
    width: 220px;
    height: 220px;
    margin-bottom: 45px;
  }

  .knob {
    width: 130px;
    height: 130px;
  }

  .tick {
    transform-origin: center 110px;
    height: 10px;
  }

  .tick.major {
    height: 12px;
  }

  .knob-cap::after {
    width: 35px;
    height: 35px;
  }

  .knob-indicator {
    top: 10px;
    height: 18px;
  }

  .value-number {
    font-size: 28px;
  }

  .value-label {
    font-size: 10px;
  }

  .control-info {
    padding: 14px 20px;
    gap: 10px;
  }

  .control-hint {
    font-size: 12px;
  }

  kbd {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
  .header {
    padding: 12px 14px;
  }

  .header-title h1 {
    font-size: 16px;
  }

  .main {
    padding: 24px 14px 50px;
  }

  .knob-container {
    width: 200px;
    height: 200px;
    margin-bottom: 40px;
  }

  .knob {
    width: 120px;
    height: 120px;
  }

  .tick {
    transform-origin: center 100px;
    height: 8px;
    width: 1.5px;
  }

  .tick.major {
    height: 10px;
    width: 2px;
  }

  .knob-cap::after {
    width: 30px;
    height: 30px;
  }

  .knob-indicator {
    top: 8px;
    width: 3px;
    height: 16px;
  }

  .value-display {
    bottom: -45px;
  }

  .value-number {
    font-size: 24px;
  }

  .value-label {
    font-size: 9px;
    margin-top: 4px;
  }

  .control-info {
    padding: 12px 16px;
    border-radius: 10px;
  }

  .control-hint {
    font-size: 11px;
    gap: 6px;
  }

  kbd {
    font-size: 9px;
    padding: 2px 5px;
  }

  .ambient-glow {
    width: 300px;
    height: 200px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .knob {
    /* Ensure minimum touch target size */
    min-width: 120px;
    min-height: 120px;
  }

  .knob:active .knob-cap {
    box-shadow:
      inset 0 -4px 12px rgba(0, 0, 0, 0.5),
      inset 0 4px 8px rgba(255, 255, 255, 0.05),
      0 0 0 3px rgba(201, 169, 98, 0.4);
  }

  .knob:active .knob-indicator {
    box-shadow:
      0 0 24px var(--accent-glow),
      0 0 12px var(--accent-primary);
  }

  /* Hide scroll hint on touch devices */
  .control-hint:nth-child(2) {
    display: none;
  }
}

/* Animation for value change */
@keyframes valuePulse {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
  100% { transform: translateX(-50%) scale(1); }
}

.value-display.pulse {
  animation: valuePulse 0.15s ease-out;
}
