/**
 * Spring Synth - Toddler-Friendly PWA Styles
 *
 * Restrictions applied:
 * - No text selection
 * - No touch callout (long press menu)
 * - No zoom (double-tap)
 * - No scroll/overscroll
 * - No image drag
 * - Safe areas for notch/home indicator
 */

/* ==================== RESET & RESTRICTIONS ==================== */

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

  /* Disable text selection */
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;

  /* Disable iOS callout menu */
  -webkit-touch-callout: none;
}

html {
  /* Disable double-tap zoom */
  touch-action: manipulation;
}

/* Only for touch devices */
@media (hover: none) and (pointer: coarse) {
  html,
  body {
    /* No scrolling */
    overflow: hidden;

    /* Dynamic viewport height (fixes iOS 100vh bug) */
    height: 100dvh;
    width: 100dvw;

    /* Disable pull-to-refresh & bounce */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
  }
}

/* For installed PWA */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html,
  body {
    overflow: hidden;
    height: 100dvh;
    width: 100dvw;
    overscroll-behavior: none;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;

  /* Safe areas for notch & home indicator */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);

  /* Legacy iOS 11 syntax */
  padding-top: constant(safe-area-inset-top);
  padding-right: constant(safe-area-inset-right);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-left: constant(safe-area-inset-left);
}

/* Image protection */
img,
picture,
figure {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

/* ==================== LAYOUT ==================== */

#app {
  position: fixed;
  inset: 0;
  display: flex;

  /* Account for safe areas */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

/* ==================== SPLASH SCREEN ==================== */

.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;

  display: flex;
  align-items: center;
  justify-content: center;

  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  cursor: pointer;

  /* Smooth fade out */
  transition:
    opacity 0.3s ease-out,
    visibility 0.3s ease-out;
}

.splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  text-align: center;
}

.splash-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

.splash-text {
  font-size: 1.5rem;
  font-weight: 600;
  opacity: 0.9;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* ==================== CANVAS ==================== */

#canvas {
  flex: 1;
  display: block;

  /* Fill available space */
  width: 100%;
  height: 100%;

  /* Touch feedback */
  touch-action: none;
}

/* ==================== CONTROLS PANEL ==================== */

.controls {
  width: min(30%, 200px);
  min-width: 160px;

  background: rgba(22, 33, 62, 0.95);
  border-left: 1px solid rgba(255, 255, 255, 0.1);

  padding: 1rem;
  overflow-y: auto;

  /* Smooth slide in */
  transition:
    transform 0.3s ease-out,
    opacity 0.3s ease-out;
}

.controls.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Touch-friendly control sizes (min 44px) */
.control-group {
  margin-bottom: 1rem;
}

.control-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.5rem;
}

.control-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  cursor: pointer;
}

.control-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: #4a9eff;
  border-radius: 50%;
  margin-top: -10px;

  /* Touch area extension */
  box-shadow: 0 0 0 8px transparent;
}

.control-slider:active::-webkit-slider-thumb {
  transform: scale(1.2);
  background: #6bb3ff;
}

.control-button {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 44px;
  padding: 0.75rem;

  background: rgba(74, 158, 255, 0.2);
  border: 1px solid rgba(74, 158, 255, 0.4);
  border-radius: 8px;

  color: #fff;
  font-size: 1rem;
  font-weight: 500;

  cursor: pointer;
  transition: background 0.15s ease;
}

.control-button:active {
  background: rgba(74, 158, 255, 0.4);
}

/* ==================== ORIENTATION WARNING ==================== */

.orientation-warning {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;

  background: #1a1a2e;
  color: #fff;
}

.orientation-icon {
  font-size: 4rem;
  animation: rotate-hint 2s ease-in-out infinite;
}

.orientation-text {
  font-size: 1.25rem;
  opacity: 0.9;
}

@keyframes rotate-hint {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-15deg);
  }
  75% {
    transform: rotate(15deg);
  }
}

/* Show warning only in portrait on touch devices */
@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .orientation-warning {
    display: flex;
  }

  #app {
    display: none;
  }
}

/* ==================== EDGE BLOCKERS (back gesture prevention) ==================== */

.edge-blocker {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 20px;
  z-index: 9998;
  touch-action: none;
}

.edge-blocker-left {
  left: 0;
}

.edge-blocker-right {
  right: 0;
}

/* ==================== UTILITY ==================== */

.hidden {
  display: none;
}

/* Focus visible only for keyboard navigation */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid #4a9eff;
  outline-offset: 2px;
}
