/**
 * SAND // PARTICLES — Bespoke Monochromatic Design System
 * Zero Slop / Anti-Default / Total Dark & Light Inversion
 * Seamless Responsive Layout / Zero Ugly Scrollbars
 * 100% Client-Side Pure Particle Physics & Typography
 */

:root[data-theme="dark"] {
  --bg-canvas: #000000;
  --fg-grain: #FFFFFF;
  --surface: rgba(10, 10, 10, 0.85);
  --surface-solid: #0A0A0A;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.38);
  --text-primary: #FFFFFF;
  --text-muted: rgba(255, 255, 255, 0.48);
  --text-subtle: rgba(255, 255, 255, 0.25);
  --accent-fill: #FFFFFF;
  --accent-text: #000000;
  --hover-bg: rgba(255, 255, 255, 0.08);
  --active-bg: rgba(255, 255, 255, 0.16);
  --cursor-ring: rgba(255, 255, 255, 0.35);
  --reticle-border: rgba(255, 255, 255, 0.4);
}

:root[data-theme="light"] {
  --bg-canvas: #FFFFFF;
  --fg-grain: #000000;
  --surface: rgba(246, 246, 246, 0.88);
  --surface-solid: #F4F4F4;
  --border: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.42);
  --text-primary: #000000;
  --text-muted: rgba(0, 0, 0, 0.50);
  --text-subtle: rgba(0, 0, 0, 0.26);
  --accent-fill: #000000;
  --accent-text: #FFFFFF;
  --hover-bg: rgba(0, 0, 0, 0.06);
  --active-bg: rgba(0, 0, 0, 0.14);
  --cursor-ring: rgba(0, 0, 0, 0.35);
  --reticle-border: rgba(0, 0, 0, 0.4);
}

/* Universal Scrollbar Elimination: clean presentation across all viewports */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

*::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

html, body {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: background-color 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Fullscreen Interaction Canvas */
#sand-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  z-index: 1;
}

/* Precision Interaction Field Ring */
#cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 95px;
  height: 95px;
  border: 1px solid var(--reticle-border);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

/* Top Telemetry HUD Header */
.hud-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  width: 6px;
  height: 6px;
  background: var(--text-primary);
  display: inline-block;
}

.brand-title {
  font-weight: 600;
  letter-spacing: 0.12em;
}

.brand-sub {
  color: var(--text-subtle);
  font-size: 10px;
}

.telemetry-cluster {
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--text-muted);
}

.telemetry-item span {
  color: var(--text-primary);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tactile Mechanical Buttons */
.tactile-btn {
  appearance: none;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0 11px;
  height: 28px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease, color 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tactile-btn:hover {
  border-color: var(--border-strong);
  background: var(--hover-bg);
}

.tactile-btn:active {
  transform: translateY(1px);
  background: var(--active-bg);
}

.tactile-btn.active {
  background: var(--accent-fill);
  color: var(--accent-text);
  border-color: var(--accent-fill);
}

/* Bottom Control Dock */
.control-dock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1040px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Row 1: Direct Glyph Input */
.dock-top-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.input-wrapper {
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.input-prompt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.glyph-input {
  width: 100%;
  height: 46px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  user-select: text;
  min-width: 0;
}

.glyph-input::placeholder {
  color: var(--text-subtle);
  font-weight: 400;
  letter-spacing: 0.08em;
}

/* Row 2: Presets & Physics Sliders */
.dock-bottom-row {
  display: flex;
  align-items: stretch;
  min-height: 46px;
  width: 100%;
}

.preset-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  max-width: 58%;
}

.strip-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-right: 4px;
  white-space: nowrap;
}

.physics-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 8px 16px;
  flex: 1;
  min-width: 0;
  align-items: center;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.slider-val {
  color: var(--text-primary);
  font-weight: 600;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px;
  height: 9px;
  background: var(--text-primary);
  border: none;
  cursor: ew-resize;
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.35);
}

/* Responsive & Compact Viewport Adaptations */
@media (max-width: 900px) {
  .telemetry-cluster { display: none; }
  .brand-sub { display: none; }
  
  .dock-bottom-row {
    flex-direction: column;
  }

  .preset-strip {
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 14px;
    flex-wrap: wrap; /* Wraps cleanly into neat chips without horizontal scrollbar */
  }

  .physics-strip {
    width: 100%;
    padding: 10px 14px;
    gap: 12px;
  }
}

@media (max-width: 580px) {
  .control-dock {
    width: calc(100vw - 16px);
    bottom: 8px;
  }

  .hud-header {
    padding: 0 12px;
  }

  .physics-strip {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
