:root {
  --line-green: #06c755;
  --line-green-dark: #05a648;
  --bg: #f7f7f8;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #767676;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/*
 * Slow, subtle gradient drift behind the whole page. background-size is
 * larger than the viewport so background-position can pan across it; colors
 * stay close to --bg so cards on top keep full contrast. Paused for users who
 * prefer reduced motion.
 */
.page {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 24px);
  background: linear-gradient(-45deg, #f7f7f8, #e8faf0, #eef6ff, #f7f7f8);
  background-size: 300% 300%;
  animation: bgDrift 16s ease-in-out infinite;
}

@keyframes bgDrift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .page {
    animation: none;
    background-position: 0% 50%;
  }
}

.content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.player-card p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

/*
 * Google Drive's player controls are a fixed pixel size we can't restyle
 * (cross-origin iframe). To make them smaller RELATIVE to the video, we let
 * the iframe render onto a viewport twice as large, then scale it back down to
 * fill the frame. The video still fits the frame, but Google's controls now
 * occupy half the relative area. Adjust --player-zoom to tune (2 = half-size
 * controls; higher = smaller). The width/height percentages must equal
 * --player-zoom * 100% so the scaled result fills the frame exactly.
 */
.player-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  border: 0;
  transform: scale(0.5);
  transform-origin: 0 0;
}

.player-frame .native-player {
  width: 100%;
  height: 100%;
}

.player-frame__external-blocker {
  position: absolute;
  top: 0;
  right: 0;
  width: 56px;
  height: 56px;
  z-index: 1;
}

.player-frame__error {
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 16px;
  text-align: center;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: nowrap; /* keep both buttons on one row, never stack */
  gap: 8px;
  /* Full content width, flush with the player card's outer edge above it. */
  width: 100%;
}

.btn {
  /*
   * flex-basis auto (not 0) sizes each button to its label, so the longer
   * "เพิ่มเพื่อน LINE OA" gets more width than "แชร์ให้เพื่อน" instead of being
   * squeezed into an equal half and wrapping. white-space: nowrap guarantees
   * the label stays on a single line; the clamped font shrinks to fit narrow
   * phones (down to 320px) without overflowing.
   */
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  padding: 16px 14px;
  font-family: inherit;
  font-size: clamp(0.9rem, 3.8vw, 1.02rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.985);
}

.btn--friend {
  background: linear-gradient(180deg, #08d95f 0%, var(--line-green) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.30),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn--friend:hover {
  box-shadow: 0 7px 18px rgba(6, 199, 85, 0.40),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn--friend:active {
  box-shadow: 0 3px 10px rgba(6, 199, 85, 0.30),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn--share {
  background: #fff;
  color: var(--text);
  border: 1px solid #e6e8eb;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06);
}

.btn--share:hover {
  background: #fafbfc;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.09);
}

/* Accent the share icon in LINE green while the label stays neutral. */
.btn--share .btn__icon { color: var(--line-green); }

.btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 21px;
  line-height: 1;
}

.btn__icon svg {
  display: block;
  width: 24px;
  height: 24px;
}

.episode-list {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
}

.episode-list h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.episode-list__items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.episode-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 8px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
}

.episode-item:hover { background: var(--bg); }

.episode-item--active {
  background: rgba(6, 199, 85, 0.1);
  color: var(--line-green-dark);
  font-weight: 700;
}

.episode-item img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #eee;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: rgba(26,26,26,0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
