/* ==========================================================================
   Signal Lab 941 — WebGL Oscilloscope Audio Visualizer
   Mid-century modern test equipment aesthetic (Tektronix/HP inspired)
   Ported from introl.com oscilloscope component
   ========================================================================== */

/* Geist Pixel Font - Vercel's pixel font family */
@font-face {
  font-family: "Geist Pixel";
  src: url("/static/fonts/GeistPixel-Square.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Device Container - Braun-inspired */
.oscilloscope-device {
  --device-bg: #2a2a2a;
  --bezel-color: #1a1a1a;
  --screen-bg: #0a0a0a;
  --phosphor: #00ff00;
  --indicator-off: #2a2a2a;
  --indicator-on: #00ff00;
  --knob-metallic: linear-gradient(
    135deg,
    #555 0%,
    #777 30%,
    #444 70%,
    #333 100%
  );
  --label-color: #888;
  --orange: #e07020;
  --orange-dark: #a85518;

  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  background: var(--device-bg);
  border-radius: 8px;
  padding: 20px;
  padding-top: 48px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
  font-family: "Geist Pixel", "VT323", monospace;
}

/* Subtle texture overlay */
.oscilloscope-device::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 2px,
    rgba(255, 255, 255, 0.01) 2px,
    rgba(255, 255, 255, 0.01) 4px
  );
  border-radius: 8px;
  pointer-events: none;
  z-index: 0;
}

/* Brand nameplate */
.oscilloscope-brand {
  position: absolute;
  top: 14px;
  left: 20px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  z-index: 10;
}

.oscilloscope-brand .brand-logo {
  font-size: 14px;
  font-weight: 600;
  color: #ccc;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.oscilloscope-brand .model-number {
  font-size: 10px;
  font-weight: 400;
  color: #666;
  letter-spacing: 1px;
}

/* ==========================================================================
   CRT Screen Section (Left Side)
   ========================================================================== */

.oscilloscope-screen-section {
  flex: 1;
  position: relative;
  z-index: 1;
  padding-bottom: 30px;
}

/* CRT Bezel - the physical frame around the screen */
.crt-bezel {
  background: #1a1a1a;
  border-radius: 6px;
  padding: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -2px 4px rgba(0, 0, 0, 0.6);
}

/* CRT Screen Container - holds the canvas and effects */
.crt-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
}

/* Opaque background behind canvas */
.crt-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000000;
  z-index: 0;
}

/* WebGL Canvas */
.crt-screen canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
}

/* CRT Bulge Effect - DISABLED: now handled by barrel distortion in shader */
.crt-bulge {
  display: none;
}

/* Glass reflection highlight */
.crt-reflection {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      ellipse at 25% 25%,
      rgba(255, 255, 255, 0.15) 0%,
      transparent 40%
    ),
    radial-gradient(
      ellipse at 75% 75%,
      rgba(255, 255, 255, 0.05) 0%,
      transparent 30%
    );
  border-radius: 6px;
  pointer-events: none;
  z-index: 11;
}

/* Scanlines overlay - DISABLED: now handled by Gaussian scanlines in shader */
.crt-scanlines {
  display: none;
}

/* CRT flicker animation */
@keyframes crtFlicker {
  0%,
  100% {
    opacity: 1;
  }
  92% {
    opacity: 1;
  }
  93% {
    opacity: 0.98;
  }
  94% {
    opacity: 1;
  }
}

.crt-screen.powered-on {
  animation: crtFlicker 5s infinite;
}

/* Screen off state */
.crt-screen.powered-off canvas {
  opacity: 0.1;
  filter: grayscale(1);
}

/* ==========================================================================
   Control Panel Section (Right Side)
   ========================================================================== */

.oscilloscope-controls {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 0;
  position: relative;
  z-index: 1;
}

/* Control Group Container */
.control-group {
  background: #1a1a1a;
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Level group - no overflow */
.control-group-level {
  flex-shrink: 0;
}

.control-group-power {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.control-group-label {
  font-size: 9px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

/* Display Tuning Knobs Group — 2x2 grid in right panel */
.control-group-display {
  flex-shrink: 0;
}

.knob-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  justify-items: center;
}

.control-group-display .knob {
  width: 36px;
  height: 36px;
}

.control-group-display .knob::before {
  top: 4px;
  height: 8px;
}

.control-group-display .knob::after {
  width: 10px;
  height: 10px;
}

/* ==========================================================================
   Rotary Knobs
   ========================================================================== */

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

.knob {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #555 0%, #3a3a3a 50%, #2a2a2a 100%);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.knob:hover {
  filter: brightness(1.05);
}

.knob:active {
  transform: scale(0.98);
}

/* Knob pointer indicator */
.knob::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 2px;
  height: 10px;
  background: #ccc;
  transform: translateX(-50%);
  border-radius: 1px;
}

/* Center cap */
.knob::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  background: #444;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.knob-label {
  font-size: 9px;
  color: var(--label-color);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Dial markings around knob */
.knob-dial {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
  pointer-events: none;
}

.knob-dial span {
  position: absolute;
  font-size: 7px;
  color: var(--label-color);
}

/* ==========================================================================
   Toggle Switches
   ========================================================================== */

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-track {
  width: 40px;
  height: 20px;
  background: #151515;
  border-radius: 10px;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
  transition: background 0.2s ease;
}

.toggle-track.active {
  background: #003300;
}

.toggle-thumb {
  position: absolute;
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
  background: linear-gradient(135deg, #666 0%, #444 100%);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: left 0.2s ease;
}

.toggle-track.active .toggle-thumb {
  left: 22px;
}

.toggle-label {
  font-size: 9px;
  color: var(--label-color);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==========================================================================
   Pushbuttons
   ========================================================================== */

.pushbutton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pushbutton-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.1),
    inset 0 -2px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.1s ease;
  position: relative;
}

.pushbutton-btn:hover {
  filter: brightness(1.15);
}

.pushbutton-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* LED indicator on button */
.pushbutton-led {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--indicator-off);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.pushbutton-btn.active .pushbutton-led {
  background: radial-gradient(
    circle at 30% 30%,
    #88ff88 0%,
    var(--phosphor) 50%,
    #00aa00 100%
  );
  box-shadow:
    0 0 8px var(--phosphor),
    0 0 16px rgba(0, 255, 0, 0.5);
}

.pushbutton-label {
  font-size: 8px;
  color: var(--label-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Transport Controls (Play/Pause/Stop)
   ========================================================================== */

.transport-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.transport-btn {
  width: 40px;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #404040 0%, #2a2a2a 100%);
  box-shadow:
    0 2px 0 #151515,
    0 3px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  transition: all 0.1s ease;
}

.transport-btn:hover {
  filter: brightness(1.1);
}

.transport-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 0 0 #151515,
    0 1px 3px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.transport-btn.active {
  background: linear-gradient(180deg, #004400 0%, #002800 100%);
  color: var(--phosphor);
  box-shadow:
    0 2px 0 #001500,
    0 3px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(0, 255, 0, 0.1);
}

/* Repeat button - smaller */
#repeat-btn {
  width: 32px;
}

#repeat-btn svg {
  width: 14px;
  height: 14px;
}

.transport-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ==========================================================================
   Volume/Level Slider (Vertical Fader)
   ========================================================================== */

.fader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.fader-track {
  width: 24px;
  height: 100px;
  background: linear-gradient(90deg, #0a0a0a 0%, #1a1a1a 50%, #0a0a0a 100%);
  border-radius: 4px;
  position: relative;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Fader tick marks */
.fader-track::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 8px,
    rgba(255, 255, 255, 0.1) 8px,
    rgba(255, 255, 255, 0.1) 10px
  );
  transform: translateX(-50%);
}

.fader-thumb {
  position: absolute;
  width: 100%;
  height: 16px;
  left: 0;
  bottom: 50%;
  background: var(--knob-metallic);
  border-radius: 3px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
  cursor: grab;
}

.fader-thumb::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 8px;
  background: #fff;
  transform: translate(-50%, -50%);
  border-radius: 1px;
}

.fader-label {
  font-size: 9px;
  color: var(--label-color);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==========================================================================
   VU Meter - LED Bar style
   ========================================================================== */

.vu-meter-container {
  margin-bottom: 12px;
}

.vu-meter {
  width: 100%;
  background: #080808;
  border-radius: 3px;
  padding: 8px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.vu-scale {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: #555;
  margin-bottom: 4px;
  padding: 0 2px;
}

.vu-scale span:nth-child(4),
.vu-scale span:nth-child(5) {
  color: #664444;
}

.vu-needle-container {
  display: flex;
  gap: 2px;
  height: 12px;
}

.vu-segment {
  flex: 1;
  background: #1a1a1a;
  border-radius: 1px;
  transition: background 0.05s ease;
}

/* Green segments (first 8) */
.vu-segment.active {
  background: var(--phosphor);
  box-shadow: 0 0 4px rgba(0, 255, 0, 0.6);
}

/* Yellow segments (9-10) */
.vu-segment:nth-child(9).active,
.vu-segment:nth-child(10).active {
  background: #ffcc00;
  box-shadow: 0 0 4px rgba(255, 204, 0, 0.6);
}

/* Red segments (11-12) */
.vu-segment:nth-child(11).active,
.vu-segment:nth-child(12).active {
  background: #ff4444;
  box-shadow: 0 0 4px rgba(255, 68, 68, 0.6);
}

.vu-label {
  text-align: center;
  font-size: 8px;
  color: #444;
  margin-top: 4px;
  letter-spacing: 2px;
}

/* ==========================================================================
   Fullscreen Button - Gray, matches transport style
   ========================================================================== */

.fullscreen-btn {
  width: 100%;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #404040 0%, #2a2a2a 100%);
  box-shadow:
    0 2px 0 #151515,
    0 3px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #888;
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.1s ease;
  margin-bottom: 12px;
}

.fullscreen-btn:hover {
  filter: brightness(1.1);
  color: #aaa;
}

.fullscreen-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 0 0 #151515,
    0 1px 3px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.fullscreen-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
}

/* ==========================================================================
   Fullscreen Mode
   ========================================================================== */

/* Fullscreen backdrop - covers entire page */
.oscilloscope-fullscreen-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0a0a0a;
  z-index: 99998;
}

.oscilloscope-device.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  border-radius: 0;
  z-index: 99999;
  padding: 40px;
  margin: 0;
  box-sizing: border-box;
  background: #0a0a0a;
}

.oscilloscope-device.fullscreen .oscilloscope-screen-section {
  flex: 1;
  height: calc(100vh - 80px);
  min-height: 0;
}

.oscilloscope-device.fullscreen .crt-bezel {
  height: 100%;
}

.oscilloscope-device.fullscreen .crt-screen {
  aspect-ratio: auto;
  height: 100%;
}

.oscilloscope-device.fullscreen .oscilloscope-controls {
  width: 220px;
  height: calc(100vh - 80px);
  max-height: none;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Exit fullscreen button */
.exit-fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  color: var(--phosphor);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: all 0.2s ease;
}

.oscilloscope-device.fullscreen .exit-fullscreen-btn {
  display: flex;
}

.exit-fullscreen-btn:hover {
  background: rgba(0, 255, 0, 0.2);
}

.exit-fullscreen-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
  .oscilloscope-device {
    flex-direction: column;
    padding: 16px;
  }

  .oscilloscope-controls {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px 0 0;
  }

  .control-group {
    flex: 0 0 auto;
  }

  .knob-row {
    display: flex;
    gap: 12px;
  }

  .oscilloscope-brand {
    position: static;
    margin-bottom: 12px;
    justify-content: center;
  }
}

/* ==========================================================================
   Audio Display - Dot Matrix + Flip Clock
   ========================================================================== */

.audio-info {
  background: #0a0a0a;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #1a1a1a;
  flex-shrink: 0;
}

/* Dot Matrix Display for track name */
.dot-matrix-display {
  background: #010401;
  padding: 12px 10px;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid #1a1a1a;
}

/* Subtle scanline effect */
.dot-matrix-display::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.15) 3px,
    rgba(0, 0, 0, 0.15) 6px
  );
  pointer-events: none;
  z-index: 2;
}

/* Fade edges */
.dot-matrix-display::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    #010401 0%,
    transparent 8%,
    transparent 92%,
    #010401 100%
  );
  pointer-events: none;
  z-index: 3;
}

.dot-matrix-track {
  font-family: "Geist Pixel", "VT323", monospace;
  font-size: 18px;
  color: #22ff22;
  text-shadow:
    0 0 10px rgba(34, 255, 34, 0.9),
    0 0 20px rgba(0, 255, 0, 0.4);
  white-space: nowrap;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.dot-matrix-track.ticker {
  animation: ticker 14s linear 2s infinite;
}

@keyframes ticker {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Odometer/Drum Counter Display */
.flip-clock {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  gap: 0;
  background: #0a0a0a;
}

.flip-group {
  display: flex;
  gap: 1px;
}

.flip-digit {
  width: 18px;
  height: 24px;
  background: linear-gradient(180deg, #1a1a1a 0%, #111 50%, #1a1a1a 100%);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Geist Pixel", "VT323", monospace;
  font-size: 20px;
  font-weight: 400;
  color: #ccc;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Window housing shadow at top */
.flip-digit::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
  pointer-events: none;
  z-index: 2;
}

/* Window housing shadow at bottom */
.flip-digit::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
  pointer-events: none;
  z-index: 2;
}

/* The digit itself with drum curvature hint */
.flip-digit span {
  position: relative;
  z-index: 1;
}

.flip-colon {
  font-family: "Geist Pixel", "VT323", monospace;
  font-size: 20px;
  color: #555;
  margin: 0 1px;
}

.flip-separator {
  font-family: "Geist Pixel", "VT323", monospace;
  font-size: 16px;
  color: #444;
  margin: 0 4px;
}

/* Drum roll animation */
@keyframes drumRoll {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
  100% {
    transform: translateY(0);
  }
}

.flip-digit.rolling {
  animation: drumRoll 0.15s ease-out;
}

/* ==========================================================================
   Power Indicator
   ========================================================================== */

.power-indicator {
  position: absolute;
  bottom: 12px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  transition: all 0.3s ease;
}

.power-led.on {
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor);
}

.power-label {
  font-size: 8px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}
