/* The stage is the player: video, info bar, controls. Two layouts:
   overlay  - desktop, landscape phones, fullscreen: controls float over the picture and fade out.
   stacked  - phone in portrait: 16:9 picture on top, info and big buttons underneath. */
.stage { position: relative; width: 100%; height: 100%; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none; }
.stage .frame { position: absolute; inset: 0; background: #000; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; outline: none; }
.stage video::cue { font: 600 clamp(15px, 2.2vw, 26px) var(--font); background: #000a; }

.stage .top, .stage .bottom { position: absolute; left: 0; right: 0; z-index: 2; transition: opacity .25s; }
.stage .top {
  top: 0; display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 40px max(22px, env(safe-area-inset-left));
  background: linear-gradient(#000b, #0000); pointer-events: none;
}
.stage .top > * { pointer-events: auto; }
.stage .heading { min-width: 0; }
.stage .heading h1 { margin: 0; font-size: clamp(17px, 2vw, 22px); font-weight: 700; line-height: 1.25; text-shadow: 0 1px 8px #000a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .heading p { margin: 2px 0 0; color: #d0d0da; font-size: 14px; text-shadow: 0 1px 8px #000a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .top-actions { display: flex; gap: 8px; align-items: center; flex: none; }

.stage .bottom { bottom: 0; padding: 56px max(22px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left)); background: linear-gradient(#0000, #000c 55%); }
.stage[data-idle] .top, .stage[data-idle] .bottom { opacity: 0; pointer-events: none; }
.stage[data-idle] { cursor: none; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px;
  border-radius: 999px; background: #15151bcc; border: 1px solid #ffffff1f; font-size: 13px; font-weight: 600;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); white-space: nowrap;
}

.seek { position: relative; height: 22px; display: flex; align-items: center; touch-action: none; }
.seek .track { position: relative; width: 100%; height: 4px; border-radius: 3px; background: #ffffff33; overflow: hidden; transition: height .12s; }
.seek .buf, .seek .fill { position: absolute; inset: 0 auto 0 0; width: 0; }
.seek .buf { background: #ffffff40; }
.seek .fill { background: var(--accent); }
.seek .knob { position: absolute; left: 0; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #e5383b33; opacity: 0; transition: opacity .12s; pointer-events: none; }
[data-mode="host"] .seek { cursor: pointer; }
[data-mode="host"] .seek:hover .track, [data-mode="host"] .seek.drag .track { height: 7px; }
[data-mode="host"] .seek:hover .knob, [data-mode="host"] .seek.drag .knob { opacity: 1; }

.controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.controls .grow { flex: 1; }
.controls .time { font-variant-numeric: tabular-nums; font-size: 14px; color: #e4e4ec; margin: 0 8px; white-space: nowrap; }
.cbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 42px; height: 42px; padding: 0 10px; border-radius: 10px;
  background: transparent; border: 0; color: #fff; font-weight: 600; font-size: 14px;
  transition: background .15s;
}
.cbtn:hover { background: #ffffff22; }
.cbtn:disabled { opacity: .45; cursor: default; background: transparent; }
.cbtn.solid { background: #ffffff1c; padding: 0 14px; }
.cbtn.solid:hover { background: #ffffff33; }
.cbtn.solid:disabled { background: #ffffff10; }
.cbtn svg.i { width: 22px; height: 22px; }
.cbtn .lbl { display: none; }
.cbtn.solid .lbl { display: inline; }

.volume { display: flex; align-items: center; }
.volume input[type="range"] { width: 0; opacity: 0; transition: width .18s, opacity .18s, margin .18s; accent-color: var(--accent); height: 20px; cursor: pointer; }
.volume:hover input[type="range"], .volume:focus-within input[type="range"] { width: 90px; opacity: 1; margin: 0 8px 0 2px; }
@media (hover: none) { .volume input[type="range"] { display: none; } }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; bottom: calc(100% + 10px); min-width: 210px; max-width: min(80vw, 320px);
  background: #15151bf5; border: 1px solid var(--line-2); border-radius: 12px; padding: 6px;
  box-shadow: 0 14px 40px #000a; z-index: 6; max-height: 50vh; overflow: auto;
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; border-radius: 8px; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--surface-2); }
.menu button .tick { width: 18px; color: var(--accent); }

.center { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; pointer-events: none; padding: 24px; }
.center .msg { display: grid; justify-items: center; gap: 14px; text-align: center; max-width: 360px; pointer-events: auto; }
.center .msg p { margin: 0; font-size: 17px; font-weight: 600; text-shadow: 0 2px 14px #000; }
.center .msg .sub { color: #c4c4d0; font-weight: 500; font-size: 14px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #ffffff33; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.big-play { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; box-shadow: 0 10px 40px #000a; }
.big-play svg.i { width: 34px; height: 34px; margin-left: 4px; }

.stage .backdrop { position: absolute; inset: -60px; background-size: cover; background-position: center; filter: blur(38px) brightness(.42) saturate(1.25); transition: opacity .5s; }
.stage.started .backdrop { opacity: 0; }
.stage video { background: transparent; }
.stage:not(.started) video { opacity: 0; }

/* phone in portrait: stacked, no overlays, nothing fades */
@media (max-width: 760px) and (orientation: portrait) {
  .stage:not(:fullscreen):not(:-webkit-full-screen) {
    height: auto; min-height: 100dvh; background: var(--bg); overflow: visible;
    display: flex; flex-direction: column; padding-top: env(safe-area-inset-top);
  }
  .stage[data-mode="host"]:not(:fullscreen):not(:-webkit-full-screen) { min-height: 0; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .frame { position: relative; inset: auto; aspect-ratio: 16 / 9; flex: none; overflow: hidden; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .top,
  .stage:not(:fullscreen):not(:-webkit-full-screen) .bottom {
    position: static; background: none; opacity: 1 !important; pointer-events: auto !important; padding-left: 16px; padding-right: 16px;
  }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .top { flex-wrap: wrap; padding-top: 16px; padding-bottom: 4px; gap: 12px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .heading { flex-basis: 100%; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .heading h1 { white-space: normal; font-size: 24px; letter-spacing: -.01em; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .heading p { white-space: normal; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .top-actions { flex: 1; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .top-actions .leave { margin-left: auto; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .bottom { padding-top: 4px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .seek { margin-top: 10px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .controls { gap: 8px; margin-top: 4px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .controls .time { order: -1; flex-basis: 100%; margin: 0 0 6px; color: var(--muted); }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .controls .grow { display: none; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .volume,
  .stage:not(:fullscreen):not(:-webkit-full-screen) .menu-wrap { display: contents; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .cbtn { flex: 1 1 0; min-width: 56px; height: 50px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .cbtn.solid { min-width: 120px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .volume .cbtn { flex: 0 0 56px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .top-actions .cbtn { flex: none; min-width: 34px; width: 34px; height: 34px; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .cbtn .lbl { display: inline; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .cbtn.primary { flex: 1 1 100%; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .cbtn.primary:disabled { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .menu { position: fixed; inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px; max-width: none; }
  .stage:not(:fullscreen):not(:-webkit-full-screen) .toasts { top: calc(env(safe-area-inset-top) + 8px); }
}
