/* The trailer layer. Near black like the page, the film letterboxed, the controls in the site's type. */

html.player-open { overflow: hidden; }

#player {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--black);
  color: var(--bone);
  font-family: var(--serif);
  animation: player-in .28s ease-out;
}
#player[hidden] { display: none; }

@keyframes player-in { from { opacity: 0; } to { opacity: 1; } }

/* The film fills the layer and is fitted inside it: bars above and below, never cropped. */
#trailer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--black);
  cursor: pointer;
}

/* Everything that sits over the film fades together after a moment of stillness. */
#player-close,
.player-bar,
#player-turn,
#player-error {
  transition: opacity .35s ease;
}
#player.idle { cursor: none; }
#player.idle #trailer { cursor: none; }
#player.idle #player-close,
#player.idle .player-bar {
  opacity: 0;
  pointer-events: none;
}

.pbtn {
  font: 600 12px/1 var(--serif);
  letter-spacing: .2em;
  color: var(--bone);
  background: transparent;
  border: 0;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  transition: color .2s;
}
.pbtn:hover { color: var(--gold); }
.pbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

#player-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  border: 1px solid rgba(243, 201, 139, .45);
  border-radius: 2px;
  background: rgba(5, 3, 2, .55);
  padding: 0 18px;
}
#player-close:hover { border-color: var(--gold); }

.player-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 40px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: linear-gradient(0deg, rgba(5, 3, 2, .92), rgba(5, 3, 2, 0));
}

#player-time {
  font-size: 12px;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 220, 200, .82);
  white-space: nowrap;
  padding: 0 8px;
}

/* The scrubber: a thin gold line over a faint track, an ember dot for the head. */
#player-scrub {
  --done: 0%;
  flex: 1;
  min-width: 0;
  height: 44px;
  margin: 0 6px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
#player-scrub:focus-visible { outline: 2px solid var(--gold); outline-offset: 0; }
#player-scrub::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold) var(--done), rgba(232, 220, 200, .25) var(--done));
}
#player-scrub::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold) var(--done), rgba(232, 220, 200, .25) var(--done));
}
#player-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  border: 0;
  background: var(--ember);
  box-shadow: 0 0 10px rgba(255, 106, 16, .75);
}
#player-scrub::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 0;
  background: var(--ember);
  box-shadow: 0 0 10px rgba(255, 106, 16, .75);
}

/* Portrait phones and tablets: the film is a thin strip, so say what to do about it. */
#player-turn {
  display: none;
  position: absolute;
  left: 24px; right: 24px;
  top: calc(50% + 28.125vw + 30px); /* just under the 1920x1080 film fitted to the width (v14: full 16:9, was 1920x872) */
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: .24em;
  line-height: 1.9;
  color: var(--gold);
  pointer-events: none;
}
#player-turn .turn-icon {
  display: block;
  width: 22px; height: 34px;
  margin: 0 auto 14px;
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  animation: turn-hint 2.6s ease-in-out infinite;
}
@media (orientation: portrait) and (max-width: 900px) {
  #player-turn { display: block; }
}
@keyframes turn-hint {
  0%, 25% { transform: rotate(0); }
  55%, 100% { transform: rotate(-90deg); }
}

#player-error {
  position: absolute;
  left: 24px; right: 24px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: .24em;
  line-height: 1.9;
  color: var(--bone);
  pointer-events: none;
}
#player-error[hidden] { display: none; }

@media (max-width: 520px) {
  #player-time { display: none; }
  .pbtn { padding: 0 10px; letter-spacing: .14em; }
}

@media (prefers-reduced-motion: reduce) {
  #player { animation: none; }
  #player-close, .player-bar, #player-turn, #player-error { transition: none; }
  #player-turn .turn-icon { animation: none; }
}
