/* ══════════════════════════════════════════════════════════════
   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: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--white);
  border-right: 0px solid var(--gray-300);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease, min-width 0.25s ease, border-width 0.25s ease;
}

.side-menu.open {
  width: auto;
  min-width: 140px;
  max-width: 240px;
  border-right-width: 1px;
}

@media (max-width: 480px) {
  .side-menu.open {
    min-width: 120px;
    max-width: 45vw;
  }
}

.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 {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--green-dark);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.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: column;
  gap: 4px;
}

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

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

.status-value {
  font-size: 12px;
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── 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 select dropdown (standalone) ───────────────────── */

.video-select-row {
  margin-bottom: 8px;
}

.video-select {
  width: 100%;
  font-family: var(--font);
  font-size: 12px;
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 8px 28px 8px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23757575'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.video-select:focus { border-color: var(--green-mid); outline: none; }


/* ── Video preview / thumbnail (standalone, top of body) ──── */

.video-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--black);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.video-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.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: 20%;
  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%);
}


/* ── Add video row (upload + drop inline) ─────────────────── */

.add-video-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: bold;
  color: var(--green-dark);
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color 0.2s, background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.upload-btn:hover {
  border-color: var(--green-mid);
  background: var(--green-light);
}

.upload-btn-icon {
  width: 14px;
  height: 14px;
}

.drop-zone {
  position: relative;
  flex: 1;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-600);
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--green-mid);
  background: var(--green-light);
  color: var(--green-dark);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}


/* ── 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; }
}
