/* ══════════════════════════════════════════════════════════════
   Glitterbomb Sandbox — Styles
   Overplay green palette, mobile-first, side-menu + two-screen
   ══════════════════════════════════════════════════════════════ */

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

:root {
  --green-dark:   #1B5E20;
  --green-mid:    #2E7D32;
  --green-btn:    #388E3C;
  --green-light:  #E8F5E9;
  --green-border: #A5D6A7;
  --green-grad-1: #E8F5E9;
  --green-grad-2: #C8E6C9;
  --white:   #ffffff;
  --gray-50: #fafafa;
  --gray-100:#f5f5f5;
  --gray-200:#eeeeee;
  --gray-300:#e0e0e0;
  --gray-400:#bdbdbd;
  --gray-600:#757575;
  --gray-800:#333333;
  --black:   #000000;
  --font: Tahoma, Geneva, sans-serif;
  --radius: 6px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

html, body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}


/* ── Screen management ────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }


/* ══ HOME SCREEN ══════════════════════════════════════════════ */

/* ── Header ───────────────────────────────────────────────── */

.home-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  padding: 10px 12px;
  padding-top: calc(10px + var(--sat));
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

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

.header-center h1 {
  font-size: 16px;
  font-weight: bold;
  color: var(--gray-800);
  letter-spacing: -0.3px;
}

.header-center .logo-mark {
  width: 10px;
  height: 10px;
  background: var(--green-mid);
  border-radius: 50%;
}

.header-spacer { width: 36px; }


/* ── Menu toggle button ───────────────────────────────────── */

.menu-toggle {
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  transition: border-color 0.2s;
}

.menu-toggle:hover { border-color: var(--green-mid); }

.menu-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--gray-800);
  border-radius: 1px;
}


/* ── Side menu (inline push, not overlay) ─────────────────── */

.side-menu-overlay {
  display: none;
}

#screen-home {
  flex-direction: row;
  overflow: hidden;
}

.home-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.side-menu {
  width: 125px;
  min-width: 125px;
  max-width: 125px;
  overflow: hidden;
  background: var(--white);
  border-right: 1px solid var(--gray-300);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .side-menu {
    width: 107px;
    min-width: 107px;
    max-width: 107px;
  }
}

.side-menu-header {
  background: linear-gradient(135deg, var(--green-grad-1), var(--green-grad-2));
  border-bottom: 1px solid var(--green-border);
  padding: 10px 12px;
  padding-top: calc(10px + var(--sat));
  font-size: 12px;
  font-weight: bold;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
  flex-shrink: 0;
}

.side-menu-close { display: none; }
.menu-toggle     { display: none; }
.header-spacer   { width: 0; }

.shader-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.shader-list-loading {
  padding: 16px;
  font-size: 12px;
  color: var(--gray-600);
  text-align: center;
}

.shader-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  transition: background 0.15s;
}

.shader-list-item:hover {
  background: var(--gray-50);
}

.shader-list-item.selected {
  background: var(--green-light);
  border-left: 3px solid var(--green-mid);
  padding-left: 13px;
}

.shader-list-item-name {
  font-size: 13px;
  font-weight: bold;
  color: var(--gray-800);
}

.shader-list-item-desc {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 2px;
}


/* ── Status bar ───────────────────────────────────────────── */

.status-bar {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.status-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.status-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.status-label {
  font-size: 12px;
  font-weight: bold;
  color: var(--black);
  min-width: 0;
}

.status-label-inline {
  margin-left: 20px;
  min-width: 0;
}

.status-value {
  font-size: 12px;
  color: var(--gray-600);
  white-space: normal;
  word-break: break-word;
}

.status-value strong {
  font-weight: bold;
  color: var(--black);
}

/* ── Global mode toggle ───────────────────────────────────── */

.mode-toggle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  align-self: flex-start;
}

.mode-toggle-btns {
  display: flex;
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mode-toggle-btn {
  font-family: var(--font);
  font-size: 10px;
  font-weight: bold;
  padding: 5px 10px;
  min-width: 46px;
  border: none;
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}

.mode-toggle-btn + .mode-toggle-btn {
  border-left: 1px solid var(--green-border);
}

.mode-toggle-btn.active {
  background: var(--green-mid);
  color: var(--white);
}


/* ── Scrollable body ──────────────────────────────────────── */

.home-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(16px + var(--sab));
}


/* ── Sections ─────────────────────────────────────────────── */

.section {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.section-header {
  background: linear-gradient(135deg, var(--green-grad-1), var(--green-grad-2));
  border-bottom: 1px solid var(--green-border);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: bold;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-body {
  padding: 14px;
}


/* ── Video picker ─────────────────────────────────────────── */

.video-picker {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.video-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.video-picker-label {
  font-size: 11px;
  font-weight: normal;
  color: var(--gray-600);
  white-space: nowrap;
  min-width: 62px;
}

.video-btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.video-btn-loading {
  font-size: 12px;
  color: var(--gray-600);
  padding: 8px;
}

.video-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: bold;
  color: var(--green-dark);
  background: linear-gradient(135deg, var(--green-grad-1), var(--green-grad-2));
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.video-btn:hover {
  background: linear-gradient(135deg, var(--green-grad-2), var(--green-border));
}

.video-btn.selected {
  background: var(--green-mid);
  color: var(--white);
  border-color: var(--green-dark);
}

.video-preview {
  position: relative;
  width: 100%;
  max-height: 42vh;
  overflow: hidden;
  border-radius: var(--radius);
  background: transparent;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-preview canvas {
  display: block;
  max-width: 100%;
  max-height: 42vh;
  width: auto;
  height: auto;
}

.video-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--gray-400);
  font-size: 11px;
  z-index: 1;
}

.video-preview-empty.hidden { display: none; }

/* ── Play button overlay on preview (logo image) ──────────── */

.preview-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 13%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.2s, transform 0.2s;
  padding: 0;
  overflow: hidden;
}

.preview-play-btn img {
  width: 75%;
  height: 75%;
  object-fit: contain;
  pointer-events: none;
}

.preview-play-btn:hover {
  background: rgba(0,0,0,0.5);
  transform: translate(-50%, -50%) scale(1.08);
}

.preview-play-btn:disabled {
  background: rgba(100, 100, 100, 0.5);
  cursor: not-allowed;
  opacity: 0.5;
}

.preview-play-btn:disabled:hover {
  transform: translate(-50%, -50%);
}




/* ── Controls ─────────────────────────────────────────────── */

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.control-row:last-child { margin-bottom: 0; }

.control-label {
  font-size: 12px;
  font-weight: bold;
  color: var(--gray-800);
  min-width: 70px;
}

.control-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-200);
  outline: none;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-mid);
  border: 2px solid var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}

.control-value {
  font-size: 12px;
  color: var(--gray-600);
  min-width: 32px;
  text-align: right;
}


/* (Play button is now the overlay on the video preview) */


/* ══ PLAYER SCREEN ════════════════════════════════════════════ */

#screen-player { background: var(--black); }

canvas#glcanvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  touch-action: none;
}

video#srcvideo { display: none; }


/* ── Back button (hidden on Android) ──────────────────────── */

.back-btn {
  position: absolute;
  top: calc(12px + var(--sat));
  left: calc(12px + var(--sal));
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s;
  line-height: 1;
  padding: 0;
}

.back-btn:hover { background: rgba(0,0,0,0.7); }
body.is-android .back-btn { display: none; }


/* ── FX badge ─────────────────────────────────────────────── */

.fx-badge {
  position: absolute;
  top: calc(12px + var(--sat));
  right: calc(12px + var(--sar));
  font-size: 11px;
  font-family: var(--font);
  padding: 5px 10px;
  border-radius: var(--radius);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--green-border);
  border: 1px solid rgba(165, 214, 167, 0.3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}

.fx-badge.show { opacity: 1; }


/* ── Shader name overlay on canvas ────────────────────────── */

.shader-name-overlay {
  position: absolute;
  bottom: calc(20px + var(--sab));
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font);
  font-size: 13px;
  font-weight: bold;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 100;
}


/* ── Touch ripple ─────────────────────────────────────────── */

.touch-ring {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 2px solid rgba(165, 214, 167, 0.6);
  border-radius: 50%;
  pointer-events: none;
  animation: ring-expand 0.5s ease-out forwards;
  z-index: 50;
}

@keyframes ring-expand {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(2.5); opacity: 0; }
}


/* ══ ZONE ASSIGNMENT PANEL ════════════════════════════════════ */

.zone-panel-wrap {
  margin-bottom: 12px;
}

/* Grid: 2×2 on mobile (row-first: TL TR / BL BR), column-first on PC */
.zone-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Swipe slot spans full width */
.zone-swipe {
  grid-column: 1 / -1;
}

/* On PC: 2 columns, 3 rows — place zones explicitly for column-first order:
   col1: TL(row1) BL(row2)   col2: TR(row1) BR(row2)   swipe spans both */
@media (min-width: 600px) {
  .zone-panel {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
  }
  .zone-slot[data-zone="tl"] { grid-column: 1; grid-row: 1; }
  .zone-slot[data-zone="bl"] { grid-column: 1; grid-row: 2; }
  .zone-slot[data-zone="tr"] { grid-column: 2; grid-row: 1; }
  .zone-slot[data-zone="br"] { grid-column: 2; grid-row: 2; }
  .zone-swipe                 { grid-column: 1 / -1; grid-row: 3; }
}

/* Individual zone slot */
.zone-slot {
  background: var(--white);
  border: 1px dashed var(--green-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s;
  cursor: default;
  user-select: none;
}

.zone-slot.drag-over {
  background: var(--green-light);
  border-color: var(--green-mid);
  border-style: solid;
}

.zone-label {
  font-size: 10px;
  font-weight: bold;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Pill — empty state */
.zone-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  min-height: 24px;
  gap: 4px;
}

.zone-pill-empty {
  font-size: 10px;
  color: var(--gray-400);
  font-style: italic;
  align-self: flex-start;
}

/* Pill — assigned state: name row + mode toggle row */
.zone-pill.assigned {
  background: var(--green-mid);
  padding: 4px 6px 4px 8px;
}

/* Name + × row */
.zone-pill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.zone-pill-name {
  font-size: 11px;
  font-weight: bold;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.zone-pill-x {
  background: rgba(255,255,255,0.25);
  border: none;
  color: var(--white);
  font-size: 14px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s;
}

.zone-pill-x:hover {
  background: rgba(255,255,255,0.45);
}

/* Dragging state on shader list items */
.shader-list-item.dragging {
  opacity: 0.5;
  background: var(--green-light);
}

/* Touch-drag ghost label */
.touch-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--green-mid);
  color: var(--white);
  font-family: var(--font);
  font-size: 12px;
  font-weight: bold;
  padding: 6px 10px;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  white-space: nowrap;
  transform: translateY(-50%);
}
