/*
 * FreeShort Dramas — web watch page.
 *
 * Mobile-first and deliberately small: this page is the first thing a recipient
 * of a WhatsApp forward sees, often on a mid-range Android phone on a slow
 * connection, so there is no framework and no webfont.
 */

:root {
  /* Matches AppColor.colorPrimary in the Flutter client. */
  --brand: #ed3a57;
  --brand-strong: #ff4d67;
  --bg: #0b0b0f;
  --surface: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.68);
  --text-faint: rgba(255, 255, 255, 0.46);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
}

.watch-body {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── Stage ────────────────────────────────────────────────────────────────── */

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

.stage__media {
  position: absolute;
  inset: 0;
}

.player {
  width: 100%;
  height: 100%;
  /* `contain` rather than `cover`: these are 9:16 masters, and cropping a face
     out of frame on a tablet is worse than letterboxing. */
  object-fit: contain;
  background: #000;
  display: block;
}

/* Keeps white text legible over arbitrary video without dimming the middle. */
.stage__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0) 22%),
    linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0) 38%);
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */

.topbar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  z-index: 3;
}

.brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--brand);
  vertical-align: 1px;
}

.brand--stacked {
  display: block;
  margin-bottom: 24px;
}

.badge {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Episode meta ─────────────────────────────────────────────────────────── */

.meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 34px);
  padding: 0 18px;
  z-index: 3;
  transition: opacity 0.28s var(--ease);
}

.meta__sharer {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.meta__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-strong);
  box-shadow: 0 0 0 3px rgba(237, 58, 87, 0.28);
}

.meta__title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.meta__desc {
  margin: 7px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

/* ── Progress ─────────────────────────────────────────────────────────────── */

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 18px);
  height: 3px;
  margin: 0 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
  z-index: 3;
}

.progress__fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-strong);
  transform-origin: left center;
  transition: width 0.15s linear;
}

/* ── Controls ─────────────────────────────────────────────────────────────── */

.sound-pill {
  position: absolute;
  top: calc(var(--safe-top) + 56px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  z-index: 4;
  animation: pill-in 0.4s var(--ease) both;
}

.sound-pill svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

@keyframes pill-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 78px;
  height: 78px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  cursor: pointer;
  z-index: 4;
  display: grid;
  place-items: center;
}

.big-play svg {
  width: 38px;
  height: 38px;
  fill: currentColor;
  margin-left: 4px;
}

/* ── The wall ─────────────────────────────────────────────────────────────── */

.wall {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  padding-bottom: calc(var(--safe-bottom) + 24px);
  background: rgba(6, 6, 10, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: wall-in 0.34s var(--ease) both;
}

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

.wall__inner {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.wall__eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-strong);
}

.wall__title {
  margin: 0;
  font-size: 30px;
  line-height: 1.14;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.wall__sub {
  margin: 12px 0 26px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dim);
}

.wall__note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-faint);
}

.cta {
  display: block;
  width: 100%;
  padding: 16px 22px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 28px rgba(237, 58, 87, 0.36);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.cta:active {
  transform: scale(0.98);
  box-shadow: 0 4px 16px rgba(237, 58, 87, 0.3);
}

.replay {
  margin-top: 18px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.replay:active {
  background: var(--surface-strong);
}

/* Appears once the viewer is invested, before the episode actually ends. */
.sticky-cta {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 16px);
  z-index: 4;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  animation: sticky-in 0.34s var(--ease) both;
}

@keyframes sticky-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fallback / message pages ─────────────────────────────────────────────── */

.fallback {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-content: center;
  gap: 20px;
  padding: 28px;
  background: rgba(6, 6, 10, 0.94);
  text-align: center;
}

.fallback__text {
  margin: 0;
  font-size: 16px;
  color: var(--text-dim);
}

.watch-body--message {
  overflow: auto;
}

.message {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 32px;
  text-align: center;
  max-width: 460px;
  margin: 0 auto;
}

.message__title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.message__body {
  margin: 10px 0 26px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-dim);
}

.noscript {
  padding: 32px;
  text-align: center;
}

/* ── Landing ──────────────────────────────────────────────────────────────── */

.landing {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.landing__title {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.landing__sub {
  margin: 12px 0 28px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-dim);
}

/* ── Accessibility ────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Letterbox the 9:16 video on wide screens instead of stretching the stage. */
@media (min-width: 700px) and (orientation: landscape) {
  .stage {
    max-width: min(56.25vh, 480px);
    margin: 0 auto;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}

/* ── Gift page ────────────────────────────────────────────────────────────── */

.badge--gift {
  color: var(--text);
  background: rgba(237, 58, 87, 0.22);
}

/* Stand-in for the player when a gifted series has no transcoded episode yet. */
.stage__poster {
  position: absolute;
  inset: 0;
  background-color: #000;
  background-size: cover;
  background-position: center;
  filter: saturate(0.9);
}

/* The gift card is the wall, so it inherits that layout and only adjusts tone. */
.wall--gift {
  background: rgba(6, 6, 10, 0.88);
}

.wall--gift .wall__title {
  /* "3 free episodes" is the offer — give it the weight the headline deserves. */
  font-size: 34px;
}

.wall--gift .wall__sub strong {
  color: var(--text);
  font-weight: 700;
}

.giftcode {
  margin-top: 22px;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.giftcode__label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.giftcode__value {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  /* Monospace so a hand-typed code cannot be misread: the app is the fallback
     path when deferred deep linking is unavailable. */
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-align: center;
  cursor: pointer;
}

.giftcode__value:active {
  background: rgba(255, 255, 255, 0.14);
}

.giftcode__hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  min-height: 1.2em;
}
