/* Motion Player — styles.css
   Dark, minimal, phone-first. See SPEC.md "Visual design". */

:root {
  color-scheme: dark;
  --bg: #000;
  --chrome-bg: rgba(15, 17, 22, .72);
  --chrome-border: #ffffff1a;
  --accent: #38bdf8;
  --text: #f5f7fa;
  --text-dim: #9aa4b2;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
}

#app {
  /* Fixed to the viewport, top-left origin: the orientation neutralizer
     (app.js) resizes/transforms this box directly to counter-rotate the UI
     back to device-natural portrait when the OS flips the viewport. See
     SPEC.md "Screen-orientation compensation". Children must size relative
     to this box (100%), never to the physical viewport (100dvh), or they'd
     mismatch the box when it's swapped to portrait dimensions. */
  position: fixed;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ===================== Landing ===================== */

#landing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at top, #0b1220 0%, #000 65%);
}

.landing-inner {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  text-align: center;
}

.brand {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

#landing-form {
  display: flex;
  gap: 8px;
}

#url-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--chrome-border);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font-size: 1rem;
}

#url-input::placeholder {
  color: var(--text-dim);
}

.btn {
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--chrome-border);
  background: rgba(255, 255, 255, .08);
  cursor: pointer;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #001018;
  font-weight: 600;
}

.error-slot {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .35);
  color: var(--danger);
  font-size: 0.9rem;
}

.recents { text-align: left; }

.recents h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin: 6px 0;
}

#recents-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#recents-list li {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--chrome-border);
  cursor: pointer;
}

#recents-list li:hover { background: rgba(255, 255, 255, .09); }

.install-hint {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ===================== Player ===================== */

#player {
  background: var(--bg);
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}

#yt-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  transform: translate(-50%, -50%) rotate(var(--roll, 0deg)) scale(var(--zoom, 1)) translate(var(--tx, 0px), var(--ty, 0px));
  will-change: transform;
}

#yt-host,
#yt-host iframe {
  width: 100%;
  height: 100%;
  pointer-events: none;
  border: 0;
  display: block;
}

#gesture-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
  background: transparent;
}

.chip {
  position: absolute;
  left: 50%;
  bottom: calc(50% - 40px);
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--chrome-border);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
}

.banner {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  max-width: min(88vw, 420px);
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--chrome-border);
  color: var(--text);
  font-size: 0.88rem;
  text-align: center;
}

/* ===================== Chrome ===================== */

.chrome {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}

.chrome-top {
  top: 0;
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-left: calc(env(safe-area-inset-left) + 12px);
  padding-right: calc(env(safe-area-inset-right) + 12px);
}

.chrome-bottom {
  bottom: 0;
  justify-content: center;
  padding-bottom: calc(env(safe-area-inset-bottom) + 14px);
  padding-left: calc(env(safe-area-inset-left) + 12px);
  padding-right: calc(env(safe-area-inset-right) + 12px);
  gap: 18px;
}

.chrome-spacer { flex: 1; }

#player.chrome-hidden .chrome {
  opacity: 0;
  pointer-events: none;
}

#player.chrome-hidden #chrome-top { transform: translateY(-8px); }
#player.chrome-hidden #chrome-bottom { transform: translateY(8px); }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--chrome-border);
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}

.icon-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.icon-btn-lg {
  width: 56px;
  height: 56px;
}

.icon-btn-label {
  font-size: 0.6rem;
  margin-top: -2px;
}

/* ===================== Settings sheet ===================== */

.scrim {
  /* absolute (not fixed) so it rotates with #app instead of staying pinned
     to the physical viewport while the UI is counter-rotated. */
  position: absolute;
  inset: 0;
  z-index: 39;
  background: rgba(0, 0, 0, .4);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px);
  background: var(--chrome-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--chrome-border);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--chrome-border);
  align-self: center;
  margin-bottom: 4px;
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}

.sheet-row span:first-child { flex: 1; }

.sheet-row input[type="range"] {
  flex: 2;
  accent-color: var(--accent);
}

.sheet-val {
  width: 2.2em;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.sheet-row-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 40px;
  height: 22px;
  margin: 0;
  cursor: pointer;
}

.sheet-row-toggle {
  position: relative;
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  flex-shrink: 0;
  transition: background .15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}

.sheet-row-toggle input[type="checkbox"]:checked ~ .switch {
  background: var(--accent);
}

.sheet-row-toggle input[type="checkbox"]:checked ~ .switch::after {
  transform: translateX(18px);
}

#settings-close {
  margin-top: 4px;
}

.motion-debug {
  margin: -4px 0 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--chrome-border);
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  word-break: break-word;
}

/* ===================== Toast ===================== */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--chrome-border);
  color: var(--text);
  font-size: 0.88rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.toast.show { opacity: 1; }

[hidden] { display: none !important; }
