/* ============================================================
   THE DELAWARE PAPERS — style.css
   ============================================================ */

/* --- Google Fonts ---
   Loaded in <head>. Fonts used:
   Oswald       — display, headings, titles
   Courier Prime — puzzle gate, classified text
   Barlow Condensed — body, UI labels
   ---------------------------------------------------------- */

/* --- Variables ------------------------------------------- */
:root {
  --bg:           #0a0a0a;
  --surface:      #0f0e0d;
  --surface-2:    #141210;
  --accent:       #c0392b;
  --accent-dim:   #8b2920;
  --text:         #cec9c2;
  --text-dim:     #d9a169;
  --paper:        #e9dfc8;
  --paper-line:   #d8cdb4;
  --paper-text:   #1a150e;
  --stamp:        #c0392b;

  --font-display: 'Oswald', sans-serif;
  --font-body:    'Barlow Condensed', sans-serif;
  --font-mono:    'Courier Prime', monospace;

  --player-max:   820px;
  --gate-max:     580px;
  --content-max:  1100px;
}

/* --- Reset ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* --- Typography utilities -------------------------------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
  background: #180c0a;
  background-image: url('images/TDP_Series_Poster_16-9.webp');
  background-size: cover;
  background-position: center top;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(10,5,4,0.15) 0%,
    rgba(10,5,4,0.45) 50%,
    rgba(10,5,4,0.97) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  padding: 0 2rem 6rem;
}

.series-title {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 11vw, 9rem);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 80px rgba(192,57,43,0.35);
  opacity: 0;
  animation: fadeUp 1s 0.2s ease forwards, glitchPulse 9s 3s infinite;
}

.series-logline {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 400;
  color: var(--text);
  max-width: 640px;
  margin: 1.5rem auto 0.6rem;
  opacity: 0;
  animation: fadeUp 1s 0.5s ease forwards;
}

.series-languages {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  opacity: 0;
  animation: fadeUp 1s 0.7s ease forwards;
}

.hero-cta {
  display: inline-block;
  margin-top: 2.5rem;
  padding: 0.9rem 3rem;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: background 0.2s, transform 0.2s;
  opacity: 0;
  animation: fadeUp 1s 0.9s ease forwards;
}

.hero-cta:hover { background: var(--accent-dim); transform: translateY(-2px); color: #fff; }

/* Scroll indicator */
.scroll-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  opacity: 0;
  animation: fadeUp 1s 1.4s ease forwards;
}

.scroll-hint span {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.scroll-hint::after {
  content: '';
  display: block;
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--text-dim), transparent);
  animation: scrollPulse 2s 2s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.3; transform: scaleY(1); }
  50% { opacity: 1; transform: scaleY(1.2); }
}

/* --- Animations ------------------------------------------ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes glitchPulse {
  0%,91%,100% { text-shadow: 0 0 80px rgba(192,57,43,0.35); clip-path: none; transform: none; }
  92%  { text-shadow: 3px 0 var(--accent), -3px 0 #00c8e0; }
  93%  { clip-path: inset(15% 0 72% 0); transform: translateX(4px); text-shadow: none; }
  94%  { clip-path: none; transform: none; }
  95%  { clip-path: inset(60% 0 18% 0); transform: translateX(-3px); }
  96%  { clip-path: none; transform: none; text-shadow: 0 0 80px rgba(192,57,43,0.35); }
}

/* ============================================================
   CONCEPT SECTION
   ============================================================ */
.concept-section {
  padding: 6rem 2rem;
  text-align: center;
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.04);
}

.concept-section .eyebrow { margin-bottom: 1.75rem; }

.concept-text {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 400;
  max-width: 680px;
  margin: 0 auto;
  color: var(--text);
  line-height: 1.75;
}

.concept-text strong { color: #fff; font-weight: 500; }
.concept-text em { color: var(--accent); font-style: normal; }

/* ============================================================
   TEASERS SECTION
   ============================================================ */
.teasers-section {
  padding: 5rem 2rem;
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.04);
}

.teasers-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.teasers-section .eyebrow { margin-bottom: 2rem; }

.trailer-featured { margin-bottom: 1.25rem; }

.teasers-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.875rem;
}

/* ============================================================
   YOUTUBE FACADE
   ============================================================ */
.yt-facade {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  overflow: hidden;
}

.yt-facade img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.7) saturate(0.8);
  transition: filter 0.35s ease, transform 0.4s ease;
}

.yt-facade:hover img {
  filter: brightness(0.9) saturate(1);
  transform: scale(1.03);
}

.yt-facade iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.yt-facade.playing img,
.yt-facade.playing .play-btn,
.yt-facade.playing .video-label { display: none; }

.play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  background: rgba(192,57,43,0.88);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 2;
}

.play-btn::after {
  content: '';
  display: block;
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent #fff;
  margin-left: 4px;
}

.yt-facade:hover .play-btn {
  background: var(--accent);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Smaller play button for teasers */
.yt-facade.small .play-btn {
  width: 44px;
  height: 44px;
}

.yt-facade.small .play-btn::after {
  border-width: 7px 0 7px 12px;
  margin-left: 3px;
}

.video-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 2.5rem 1rem 0.75rem;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  pointer-events: none;
}

/* ============================================================
   TABLE SECTION — player + puzzle gate
   ============================================================ */
.table-section {
  position: relative;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.table-surface {
  position: relative;
  min-height: 100svh;
  background-color: var(--surface-2);
  background-image: var(--table-bg, url('images/landing-table.webp'));
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem 6rem;
  gap: 3rem;
}

/* Dim overlay to ensure text readability over photo */
.table-surface::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(6,4,3,0.45);
  pointer-events: none;
}

.table-surface > * { position: relative; z-index: 1; }

/* Episode header — on episode pages only */
.episode-header {
  text-align: center;
}

.episode-number {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
}

.episode-title-text {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 24px rgba(0,0,0,0.9);
  margin-top: 0.3rem;
}

/* --- Player (pinned to table) ---------------------------- */
.table-player {
  width: 100%;
  max-width: var(--player-max);
  filter: drop-shadow(0 10px 40px rgba(0,0,0,0.85));
  transform: rotate(-0.4deg);
}

/* ============================================================
   PUZZLE GATE — document on the table
   ============================================================ */
.puzzle-gate {
  position: relative;
  width: 100%;
  max-width: var(--gate-max);
  background: var(--paper);
  color: var(--paper-text);
  padding: 2.25rem 2.5rem 2.5rem;
  transform: rotate(1.4deg);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.25),
    0 12px 50px rgba(0,0,0,0.6),
    inset 0 0 0 1px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* Tape strip on puzzle document */
.puzzle-gate::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 44%;
  width: 52px;
  height: 18px;
  background: rgba(238,214,158,0.6);
  transform: rotate(-0.5deg);
}

/* Lined paper texture */
.puzzle-gate::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 27px,
    rgba(0,0,0,0.04) 27px,
    rgba(0,0,0,0.04) 28px
  );
  pointer-events: none;
}

/* Red margin line */
.puzzle-gate-inner {
  position: relative;
  z-index: 1;
  border-left: 2px solid rgba(192,57,43,0.25);
  padding-left: 1.25rem;
}

.puzzle-header {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0,0,0,0.12);
}

.puzzle-question {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--paper-text);
  margin-bottom: 1.5rem;
  line-height: 1.4;
  min-height: 1.5em;
  /* Typewriter cursor when animating */
}

.puzzle-question.typewriter-active::after {
  content: '|';
  animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink {
  from, to { opacity: 1; }
  50% { opacity: 0; }
}

.puzzle-options {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.puzzle-option {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.7rem 0.9rem;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.18);
  color: var(--paper-text);
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
}

.puzzle-option:hover:not(:disabled) {
  background: rgba(192,57,43,0.08);
  border-color: var(--accent);
}

.puzzle-option.wrong {
  animation: shake 0.4s ease;
  border-color: var(--accent);
  background: rgba(192,57,43,0.08);
}

.puzzle-option.correct {
  border-color: #2e7d52;
  background: rgba(46,125,82,0.08);
}

.puzzle-option:disabled { cursor: not-allowed; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-5px); }
  40%     { transform: translateX(5px); }
  60%     { transform: translateX(-3px); }
  80%     { transform: translateX(3px); }
}

.puzzle-feedback {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  min-height: 1em;
  text-transform: uppercase;
}

/* ============================================================
   STAMP ANIMATION
   ============================================================ */
.stamp-overlay {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg) scale(2.5);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

.stamp-overlay.animate {
  animation: stampIn 0.45s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
}

@keyframes stampIn {
  0%   { transform: translate(-50%,-50%) rotate(-12deg) scale(2.5); opacity: 0; }
  55%  { transform: translate(-50%,-50%) rotate(-12deg) scale(0.92); opacity: 1; }
  75%  { transform: translate(-50%,-50%) rotate(-12deg) scale(1.06); }
  100% { transform: translate(-50%,-50%) rotate(-12deg) scale(1);    opacity: 1; }
}

.stamp-mark {
  border: 4px solid var(--stamp);
  padding: 0.45rem 1.25rem;
  display: inline-block;
}

.stamp-mark span {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--stamp);
  text-transform: uppercase;
  opacity: 0.82;
}

/* ============================================================
   SOLVE REVEAL
   ============================================================ */
.solve-reveal {
  display: none;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.12);
  text-align: center;
}

.solve-reveal.visible {
  display: block;
  opacity: 0;
  animation: fadeUp 0.7s 0.4s ease forwards;
}

.solve-message {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--paper-text);
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.next-episode-btn {
  display: inline-block;
  padding: 0.85rem 2.75rem;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: background 0.2s, transform 0.2s;
}

.next-episode-btn:hover { background: var(--accent-dim); transform: translateY(-2px); color: #fff; }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  padding: 3.5rem 2rem;
  text-align: center;
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-brand {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.footer-credit {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.footer-credit a {
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  transition: color 0.2s;
}

.footer-credit a:hover { color: var(--text); }

/* ============================================================
   MOBILE — below 768px
   ============================================================ */
@media (max-width: 768px) {
  /* Kill the table photo; fall back to dark surface */
  .table-surface {
    background-image: none !important;
    background-color: var(--surface-2);
    padding: 3rem 1.25rem 4rem;
  }

  /* Subtle noise grain via SVG data URI */
  .table-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    opacity: 1;
    pointer-events: none;
    z-index: 0;
  }

  .table-surface::after { display: none; }

  .table-player { transform: none; }
  .table-player::before { display: none; }
  .puzzle-gate { transform: none; max-width: 100%; padding: 1.75rem 1.5rem 2rem; }
  .puzzle-gate::before { display: none; }
  .puzzle-options { grid-template-columns: 1fr; }
  .teasers-row { grid-template-columns: 1fr; }
  .hero-content { padding: 0 1.25rem 4rem; }
}

/* ============================================================
   PREVIOUS EPISODES STRIP
   Add this block to the end of style.css
   ============================================================ */

#prev-episodes {
  display: none; /* shown by JS only when prevEpisodes array exists */
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.05);
  padding: 2.5rem 2rem;
}

.prev-episodes-header {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.prev-episodes-strip {
  display: flex;
  gap: 0.875rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.prev-episodes-strip::-webkit-scrollbar {
  height: 3px;
}

.prev-episodes-strip::-webkit-scrollbar-track {
  background: transparent;
}

.prev-episodes-strip::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 2px;
}

.prev-episode-thumb {
  flex: 0 0 180px;
  position: relative;
  display: block;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.prev-episode-thumb:hover {
  transform: translateY(-3px);
}

.prev-episode-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  filter: brightness(0.6) saturate(0.7);
  transition: filter 0.25s ease;
}

.prev-episode-thumb:hover img {
  filter: brightness(0.85) saturate(1);
}

@media (max-width: 768px) {
  .prev-episode-thumb {
    flex: 0 0 140px;
  }
}