/* ---------------------------------------------------------------
   Internal Episode template page
   Uses style.css + components.css. No episode record is attached.
--------------------------------------------------------------- */
body.episode-template-page {
  background:
    radial-gradient(54rem 36rem at 104% -6%, rgba(130, 146, 154, 0.13), transparent 62%),
    radial-gradient(42rem 34rem at -8% 8%, rgba(179, 154, 104, 0.12), transparent 58%),
    var(--paper);
}

.episode-template-main {
  padding: clamp(2.5rem, 5vw, 5rem) 0 clamp(4.5rem, 8vw, 7rem);
}

.template-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.34fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-strong);
}

.template-head h1 {
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(3rem, 6.4vw, 6.4rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.94;
}

.template-head h1 em {
  color: var(--green);
  font-weight: 400;
}

.template-head .template-intro {
  max-width: 56ch;
  margin-top: 1.1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.8;
}

.template-state {
  padding: 1.1rem 1.2rem 1.25rem;
  border: 1px solid var(--line-strong);
  background: var(--paper-light);
}

.template-state > span {
  color: var(--ink-soft);
  font-size: 0.45rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.template-state strong {
  display: block;
  margin-top: 0.3rem;
  color: var(--burgundy);
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1;
}

.template-state p {
  margin-top: 0.8rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.65;
}

.template-unfiled {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem 1.5rem;
  margin-top: 1.4rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.template-unfiled[hidden] {
  display: none;
}

.template-unfiled p {
  color: var(--ink-soft);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.template-unfiled .hand {
  color: var(--burgundy);
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  text-transform: none;
}

.template-hero {
  padding: clamp(2.8rem, 5.5vw, 5rem) 0 clamp(2.6rem, 5vw, 4.5rem);
}

.template-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(18rem, 0.66fr);
  gap: clamp(2.5rem, 5vw, 6rem);
  align-items: center;
}

.template-episode-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  line-height: 1.5;
  text-transform: uppercase;
}

.template-episode-kicker .sep {
  color: var(--gold);
}

.template-episode-kicker a {
  color: var(--green);
  border-bottom: 1px solid currentColor;
}

.template-episode-kicker a:not([href]) {
  color: var(--ink-soft);
  border-bottom: 0;
}

.template-episode-title {
  max-width: 13ch;
  margin-top: 0.9rem;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 6rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.96;
}

.template-deck {
  max-width: 34ch;
  margin-top: 1.1rem;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.2vw, 1.9rem);
  font-style: italic;
  line-height: 1.25;
}

.template-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.template-meta div {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.template-meta dt {
  color: var(--ink-soft);
  font-size: 0.43rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-transform: uppercase;
}

.template-meta dd {
  overflow-wrap: anywhere;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.2;
}

.template-hand {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--burgundy);
  font-family: var(--font-hand);
  font-size: 1.2rem;
  line-height: 1.1;
  transform: rotate(-3deg);
}

.template-cover {
  position: relative;
  justify-self: end;
  width: min(100%, 25rem);
  margin: 0;
  padding: 0.65rem 0.65rem 2.4rem;
  border: 1px solid var(--line-strong);
  background: var(--paper-light);
  box-shadow: var(--shadow-photo);
  transform: rotate(1.1deg);
}

.template-cover::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 1.2rem -0.8rem -0.9rem 0.9rem;
  background: var(--green);
  transform: rotate(-1.4deg);
}

.template-cover-paper {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.8rem;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(179, 154, 104, 0.09), transparent 52%),
    var(--paper);
  text-align: center;
}

.template-cover-kicker {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: var(--green);
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.template-cover-mark {
  color: var(--gold);
  font-family: var(--font-serif);
  font-size: 8rem;
  font-style: italic;
  font-weight: 300;
  line-height: 0.6;
}

.template-cover-paper p {
  color: var(--ink-soft);
  font-family: var(--font-hand);
  font-size: 1.3rem;
  line-height: 1.05;
}

.template-stamp {
  position: absolute;
  top: 1.6rem;
  right: -1.2rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--burgundy);
  background: var(--paper-light);
  color: var(--burgundy);
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(4deg);
}

.template-cover figcaption {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  left: 0.65rem;
  color: var(--ink-soft);
  font-size: 0.4rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}

.template-cover img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.template-cover img[hidden] {
  display: none;
}

.template-cover.has-image .template-cover-paper,
.template-cover.has-image .template-stamp {
  display: none;
}

.template-section {
  padding: clamp(2.6rem, 5vw, 4rem) 0;
  border-top: 1px solid var(--line-strong);
}

.template-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem 1.5rem;
  margin-bottom: 1.35rem;
}

.template-section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.4vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
}

.template-section-head h2 em {
  color: var(--green);
  font-weight: 400;
}

.template-section-head p {
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-style: italic;
}

.template-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: clamp(2.2rem, 4vw, 3.5rem);
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.template-foot a {
  color: var(--ink-soft);
  font-size: 0.49rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0.25rem;
}

.template-foot a:hover {
  color: var(--green);
  border-color: var(--green);
}

.template-foot .hand {
  color: var(--burgundy);
  font-size: 1.2rem;
}

/* Public episode page */
.episode-page .editorial-breadcrumb {
  border-bottom: 1px solid var(--line);
}

.episode-page [hidden] {
  display: none !important;
}

.episode-page .template-hero {
  padding-top: clamp(2.6rem, 5vw, 4.5rem);
}

.episode-missing {
  padding: clamp(4rem, 9vw, 8rem) 0;
}

.episode-missing .wrap {
  max-width: 44rem;
}

.episode-missing h2 {
  margin-top: 0.8rem;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 4.2rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.episode-missing p {
  max-width: 46ch;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.8;
}

.episode-missing .btn {
  margin-top: 1.5rem;
}

.episode-page .template-foot {
  padding-bottom: 1rem;
}

@media (max-width: 960px) {
  .template-head {
    grid-template-columns: 1fr;
    gap: 1.4rem;
  }

  .template-state {
    max-width: 30rem;
  }

  .template-hero-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .template-cover {
    justify-self: start;
    width: min(70%, 24rem);
    margin-left: clamp(1rem, 4vw, 2rem);
  }
}

@media (max-width: 600px) {
  .template-head h1 {
    font-size: clamp(2.9rem, 14vw, 4rem);
  }

  .template-meta {
    grid-template-columns: 1fr 1fr;
    row-gap: 1.1rem;
  }

  .template-cover {
    width: 86%;
    margin-left: 0;
  }

  .template-cover-mark {
    font-size: 5.5rem;
  }

  .template-section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .template-foot {
    align-items: flex-start;
    flex-direction: column;
  }
}
