/* ============================================================
   Voltaj Live Canvas — Mobile Client Styles
   ============================================================ */

/* --- Theme Variables --- */
:root {
  --color-bg: #0a0a0f;
  --color-bg-secondary: #12121a;
  --color-bg-tertiary: #1a1a2e;
  --color-surface: rgba(255, 255, 255, 0.05);
  --color-surface-hover: rgba(255, 255, 255, 0.08);
  --color-border: rgba(255, 255, 255, 0.08);

  --color-text: #f0f0f5;
  --color-text-secondary: #8888aa;
  --color-text-muted: #555570;

  --color-electric-blue: #00bfff;
  --color-hot-pink: #ff1493;
  --color-gold: #ffd700;
  --color-green: #00e676;

  --glass-bg: rgba(18, 18, 30, 0.75);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: 20px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-glow-blue: 0 0 20px rgba(0, 191, 255, 0.3);
  --shadow-glow-pink: 0 0 20px rgba(255, 20, 147, 0.3);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --header-height: 48px;
  --picker-height: 180px;

  --tap-min: 44px;
}

/* --- Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* --- App Shell --- */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* --- Header --- */
.header {
  flex: 0 0 var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  z-index: 10;
}

.header__brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(
    135deg,
    var(--color-electric-blue),
    var(--color-hot-pink)
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.header__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-green);
  box-shadow: 0 0 6px var(--color-green);
  transition: background 0.3s, box-shadow 0.3s;
}

.header__dot--disconnected {
  background: #ff4444;
  box-shadow: 0 0 6px #ff4444;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Canvas Area --- */
.canvas-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: var(--color-bg);
}

.canvas-wrap canvas {
  display: block;
  touch-action: none;
}

/* --- Element Picker --- */
.picker {
  flex: 0 0 auto;
  max-height: var(--picker-height);
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  z-index: 10;
}

/* Tabs */
.picker__tabs {
  display: flex;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--color-border);
}

.picker__tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.picker__tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 2px;
  background: transparent;
  border-radius: 2px;
  transition: background 0.25s;
}

.picker__tab--active {
  color: var(--color-electric-blue);
}

.picker__tab--active::after {
  background: var(--color-electric-blue);
}

/* Tray */
.picker__tray {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.picker__tray::-webkit-scrollbar {
  display: none;
}

/* Element Items */
.picker__item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  min-height: 72px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease,
    box-shadow 0.15s ease;
}

.picker__item:active {
  transform: scale(0.92);
  background: var(--color-surface-hover);
}

.picker__item-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}

.picker__item-label {
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
  text-align: center;
}

/* Effect items have a different look */
.picker__item--effect {
  border-color: rgba(255, 215, 0, 0.2);
}

.picker__item--effect:active {
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}

/* --- Connection Banner --- */
.reconnect-banner {
  position: fixed;
  top: calc(var(--safe-top) + var(--header-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: var(--radius-full);
  background: rgba(255, 68, 68, 0.9);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.reconnect-banner--visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- Placement Feedback --- */
.place-feedback {
  position: fixed;
  pointer-events: none;
  font-size: 40px;
  z-index: 50;
  animation: place-pop 0.4s ease-out forwards;
}

@keyframes place-pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(-20px);
    opacity: 0;
  }
}

/* --- Responsive Adjustments --- */

/* Very small phones */
@media (max-height: 600px) {
  :root {
    --header-height: 40px;
    --picker-height: 140px;
  }

  .picker__item {
    width: 60px;
    min-height: 60px;
  }

  .picker__item-icon {
    font-size: 24px;
  }
}

/* Landscape */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --header-height: 36px;
    --picker-height: 110px;
  }

  .picker__item {
    width: 56px;
    min-height: 56px;
    padding: 4px;
  }

  .picker__item-icon {
    font-size: 22px;
  }

  .picker__item-label {
    display: none;
  }
}

/* Tablet / wider screens */
@media (min-width: 768px) {
  .picker__item {
    width: 84px;
    min-height: 84px;
  }

  .picker__item-icon {
    font-size: 32px;
  }

  .picker__item-label {
    font-size: 11px;
  }
}
