/**
 * hardware-controls.css
 * Skeuomorphic hardware controls for sheep-viz
 *
 * Components:
 * - .hardware-bar: Container for all controls
 * - .sknob: Rotary knob
 * - .sfader: Vertical fader/slider
 * - .spad: Trigger pad for presets
 *
 * Usage:
 * <link rel="stylesheet" href="../lib/hardware-controls.css">
 */

/* ═══════════════════════════════════════════════════════════════════
   CSS VARIABLES - Override these to theme the controls
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --hw-bg-dark: #0d0d0d;
    --hw-bg-mid: #1a1a1a;
    --hw-bg-light: #252525;
    --hw-border: #333;
    --hw-text: #aaa;
    --hw-text-dim: #777;
    --hw-accent: #00ff88;
    --hw-accent-dim: #00aa55;
}

/* ═══════════════════════════════════════════════════════════════════
   HARDWARE BAR - Main container
   ═══════════════════════════════════════════════════════════════════ */

.hardware-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 180px;
    background: linear-gradient(180deg, var(--hw-bg-mid) 0%, var(--hw-bg-dark) 100%);
    border-top: 2px solid var(--hw-border);
    padding: 12px 20px;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    font-family: 'JetBrains Mono', monospace;
}

.hardware-bar.visible {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Adjust main content when hardware bar is visible */
body.hardware-mode .main-container {
    height: calc(100vh - 180px);
}

body.hardware-mode .sidebar {
    max-height: calc(100vh - 180px);
}

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════ */

.hardware-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hardware-section {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 12px;
    background: linear-gradient(180deg, var(--hw-bg-light) 0%, var(--hw-bg-mid) 100%);
    border-radius: 8px;
    border: 1px solid var(--hw-border);
    position: relative;
}

/* Knobs grid - matches MiniLab 3 physical layout (2 rows x 4 columns) */
.hardware-section.knobs-section {
    flex-wrap: wrap;
    width: 220px;
    justify-content: center;
}

/* Pads grid - matches MiniLab 3 physical layout (2 rows x 4 columns) */
.hardware-section.pads-section {
    flex-wrap: wrap;
    width: 180px;
    justify-content: center;
}

/* Grid containers for 2x4 layout */
.hardware-knob-grid,
.hardware-pad-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hardware-knob-row,
.hardware-pad-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════
   AUDIO SECTION
   ═══════════════════════════════════════════════════════════════════ */

.hardware-section.audio-section {
    min-width: 100px;
}

.hardware-audio-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.hardware-audio-btn {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
    border: 1px solid var(--hw-border);
    color: var(--hw-text);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.hardware-audio-btn:hover {
    border-color: var(--hw-accent-dim);
    color: var(--hw-accent);
}

.hardware-audio-btn.active {
    background: linear-gradient(180deg, var(--hw-accent-dim), var(--hw-accent));
    border-color: var(--hw-accent);
    color: #000;
}

.hardware-audio-status {
    font-size: 8px;
    color: var(--hw-text-dim);
    text-align: center;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hardware-audio-status.active {
    color: var(--hw-accent);
}

/* ═══════════════════════════════════════════════════════════════════
   MIDI SECTION
   ═══════════════════════════════════════════════════════════════════ */

.hardware-section.midi-section {
    min-width: 80px;
}

.hardware-midi-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    color: var(--hw-text-dim);
}

.hardware-midi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hw-border);
    flex-shrink: 0;
}

.hardware-midi-dot.connected {
    background: var(--hw-accent);
    box-shadow: 0 0 6px var(--hw-accent);
}

.hardware-midi-dot.active {
    background: #fff;
    box-shadow: 0 0 10px #fff;
}

.hardware-midi-name {
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hardware-section-label {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--hw-text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.hardware-divider {
    width: 1px;
    height: 100px;
    background: linear-gradient(180deg, transparent, var(--hw-border), transparent);
    margin: 0 10px;
}

/* ═══════════════════════════════════════════════════════════════════
   SKEUOMORPHIC KNOB
   ═══════════════════════════════════════════════════════════════════ */

.sknob {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.sknob-label {
    font-size: 8px;
    color: var(--hw-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    max-width: 50px;
    text-align: center;
    line-height: 1.1;
    height: 18px;
    overflow: hidden;
}

.sknob-outer {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    box-shadow:
        0 4px 8px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.05),
        inset 0 -1px 0 rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.sknob-inner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, #333, #222);
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.5),
        0 1px 0 rgba(255,255,255,0.05);
    position: relative;
    transition: transform 0.05s ease-out;
}

.sknob-indicator {
    position: absolute;
    width: 3px;
    height: 10px;
    background: var(--hw-accent);
    border-radius: 2px;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 6px var(--hw-accent);
}

.sknob-ring {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: #444;
    top: -3px;
    left: -3px;
}

.sknob-value {
    font-size: 9px;
    color: var(--hw-accent);
    font-weight: 500;
}

/* Knob hover state */
.sknob:hover .sknob-outer {
    box-shadow:
        0 4px 8px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.05),
        inset 0 -1px 0 rgba(0,0,0,0.3),
        0 0 10px rgba(0,255,136,0.2);
}

/* Knob active/dragging state */
.sknob.active .sknob-indicator {
    background: #fff;
    box-shadow: 0 0 10px #fff, 0 0 20px var(--hw-accent);
}

/* ═══════════════════════════════════════════════════════════════════
   SKEUOMORPHIC FADER
   ═══════════════════════════════════════════════════════════════════ */

.sfader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    user-select: none;
}

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

.sfader-track {
    width: 30px;
    height: 80px;
    background: linear-gradient(90deg, var(--hw-bg-mid), var(--hw-bg-light), var(--hw-bg-mid));
    border-radius: 4px;
    position: relative;
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.5),
        0 1px 0 rgba(255,255,255,0.03);
    cursor: pointer;
}

.sfader-slot {
    position: absolute;
    width: 4px;
    height: 70px;
    background: #111;
    left: 50%;
    top: 5px;
    transform: translateX(-50%);
    border-radius: 2px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
}

.sfader-fill {
    position: absolute;
    width: 4px;
    left: 50%;
    bottom: 5px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, var(--hw-accent), var(--hw-accent-dim));
    border-radius: 2px;
    box-shadow: 0 0 8px var(--hw-accent);
    transition: height 0.05s ease-out;
    max-height: 70px; /* Constrain to slot height */
}

.sfader-handle {
    position: absolute;
    width: 26px;
    height: 16px;
    background: linear-gradient(180deg, #444, #333, #222);
    left: 2px;
    border-radius: 3px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.1);
    cursor: grab;
    transition: bottom 0.05s ease-out;
}

.sfader-handle::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 2px;
    background: #555;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1px;
}

.sfader-handle:active {
    cursor: grabbing;
}

.sfader-value {
    font-size: 9px;
    color: var(--hw-accent);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════
   SKEUOMORPHIC PAD
   ═══════════════════════════════════════════════════════════════════ */

.spad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    user-select: none;
}

.spad-btn {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
    border: 1px solid var(--hw-border);
    box-shadow:
        0 3px 6px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.05);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    transition: all 0.1s;
}

.spad-btn:hover {
    background: linear-gradient(180deg, #333, #252525);
}

.spad-btn:active,
.spad-btn.active {
    background: linear-gradient(180deg, var(--hw-accent-dim), var(--hw-accent));
    color: #000;
    box-shadow:
        0 1px 2px rgba(0,0,0,0.3),
        0 0 15px var(--hw-accent),
        inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(1px);
}

/* Pad has saved preset */
.spad-btn.filled {
    border-color: var(--hw-accent-dim);
    color: var(--hw-accent);
}

.spad-label {
    font-size: 7px;
    color: var(--hw-text-dim);
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════════
   TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════════ */

.hardware-toggle {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 1001;
    padding: 6px 12px;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    background: var(--hw-bg-mid);
    border: 1px solid var(--hw-border);
    border-radius: 4px;
    color: var(--hw-text);
    cursor: pointer;
    transition: all 0.2s;
}

.hardware-toggle:hover {
    border-color: var(--hw-accent-dim);
    color: var(--hw-accent);
}

/* Move toggle up when bar is visible */
.hardware-bar.visible ~ .hardware-toggle {
    bottom: 190px;
}

/* ═══════════════════════════════════════════════════════════════════
   WATERMARK / LOGO
   Fixed position bottom-right, always visible
   ═══════════════════════════════════════════════════════════════════ */

.sheep-watermark {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    text-transform: lowercase;
    letter-spacing: 1px;
    pointer-events: none;
    user-select: none;
}

.sheep-watermark img {
    max-height: 40px;
    max-width: 120px;
    opacity: 0.5;
    filter: grayscale(30%);
}

/* Move watermark up when hardware bar is visible */
.hardware-bar.visible ~ .sheep-watermark {
    bottom: 200px;
}

/* Hide watermark in projection mode (optional - can show in fullscreen) */
.projection-mode .sheep-watermark {
    bottom: 20px;
    opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════════
   POPOUT WINDOW STYLES
   These are injected into the popout window
   ═══════════════════════════════════════════════════════════════════ */

/* See hardware-controls.js for popout styles */
