/* The Rewrite Project fan site. Episode text lives in the HTML files. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: Cinzel;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/cinzel-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b0910;
  --panel: #16121e;
  --text: #f4f0f8;
  --heading: #f6ecff;
  --silver: #e4dfec;
  --silver-soft: #c9c0da;
  --purple: #9354c4;
  --purple-deep: #6d348f;
  --focus: #ffe9a8;
  --line: rgba(210, 196, 232, 0.35);
  --corner-tl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M2 13V3.2H12' fill='none' stroke='rgb(238,234,246)' stroke-width='1.2'/%3E%3Cpath d='M4 13V5.2H12' fill='none' stroke='rgb(196,176,224)' stroke-width='0.9'/%3E%3Cpath d='M3.1 1 L4.8 2.7 L3.1 4.4 L1.4 2.7 Z' fill='rgb(247,244,252)'/%3E%3C/svg%3E");
  --corner-tr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cg transform='translate(16 0) scale(-1 1)'%3E%3Cpath d='M2 13V3.2H12' fill='none' stroke='rgb(238,234,246)' stroke-width='1.2'/%3E%3Cpath d='M4 13V5.2H12' fill='none' stroke='rgb(196,176,224)' stroke-width='0.9'/%3E%3Cpath d='M3.1 1 L4.8 2.7 L3.1 4.4 L1.4 2.7 Z' fill='rgb(247,244,252)'/%3E%3C/g%3E%3C/svg%3E");
  --corner-bl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cg transform='translate(0 16) scale(1 -1)'%3E%3Cpath d='M2 13V3.2H12' fill='none' stroke='rgb(238,234,246)' stroke-width='1.2'/%3E%3Cpath d='M4 13V5.2H12' fill='none' stroke='rgb(196,176,224)' stroke-width='0.9'/%3E%3Cpath d='M3.1 1 L4.8 2.7 L3.1 4.4 L1.4 2.7 Z' fill='rgb(247,244,252)'/%3E%3C/g%3E%3C/svg%3E");
  --corner-br: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cg transform='translate(16 16) scale(-1 -1)'%3E%3Cpath d='M2 13V3.2H12' fill='none' stroke='rgb(238,234,246)' stroke-width='1.2'/%3E%3Cpath d='M4 13V5.2H12' fill='none' stroke='rgb(196,176,224)' stroke-width='0.9'/%3E%3Cpath d='M3.1 1 L4.8 2.7 L3.1 4.4 L1.4 2.7 Z' fill='rgb(247,244,252)'/%3E%3C/g%3E%3C/svg%3E");
}

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

html {
  font-size: 100%;
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Atkinson Hyperlegible", "Segoe UI", Verdana, sans-serif;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.65;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 980px 520px at 0% -8%, rgba(132, 70, 196, 0.28), transparent 58%),
    radial-gradient(ellipse 760px 460px at 100% 0%, rgba(96, 44, 160, 0.18), transparent 52%),
    radial-gradient(ellipse 860px 540px at 50% 112%, rgba(78, 30, 130, 0.22), transparent 54%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cg fill='rgb(214,196,245)'%3E%3Ccircle cx='8' cy='14' r='0.7' opacity='0.45'/%3E%3Ccircle cx='28' cy='40' r='0.5' opacity='0.28'/%3E%3Ccircle cx='46' cy='12' r='0.6' opacity='0.34'/%3E%3Ccircle cx='70' cy='28' r='0.45' opacity='0.22'/%3E%3Ccircle cx='92' cy='8' r='0.7' opacity='0.4'/%3E%3Ccircle cx='120' cy='22' r='0.5' opacity='0.26'/%3E%3Ccircle cx='148' cy='36' r='0.6' opacity='0.32'/%3E%3Ccircle cx='18' cy='78' r='0.5' opacity='0.24'/%3E%3Ccircle cx='54' cy='66' r='0.8' opacity='0.3'/%3E%3Ccircle cx='88' cy='90' r='0.45' opacity='0.2'/%3E%3Ccircle cx='110' cy='70' r='0.6' opacity='0.28'/%3E%3Ccircle cx='140' cy='96' r='0.5' opacity='0.24'/%3E%3Ccircle cx='24' cy='120' r='0.55' opacity='0.26'/%3E%3Ccircle cx='64' cy='138' r='0.7' opacity='0.32'/%3E%3Ccircle cx='100' cy='124' r='0.4' opacity='0.2'/%3E%3Ccircle cx='132' cy='146' r='0.65' opacity='0.3'/%3E%3Ccircle cx='150' cy='118' r='0.45' opacity='0.18'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, no-repeat, repeat;
  background-size: auto, auto, auto, 160px 160px;
}

img {
  max-width: 100%;
  height: auto;
  border: 0;
}

a {
  color: #fff;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
}

a:visited {
  color: #fff;
}

p {
  margin: 0.7rem 0 0;
}

h1,
h2,
h3 {
  font-family: Cinzel, "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--heading);
}

::selection {
  background: #6d3d98;
  color: #fff;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 0;
  z-index: 5;
  padding: 0.7rem 1rem;
  background: #f7f4fb;
  color: #1a1028;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  transform: translateY(-130%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page {
  width: min(1200px, 100%);
  margin: 0 auto;
}

.site-header {
  position: relative;
  margin: 0 0 1.15rem;
}

/* Hero banner bottom fade. The overlay stays inside the header and does not receive clicks. */
.site-header::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.banner {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  background: #120c18;
}

.layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 250px;
  gap: 1.4rem;
  align-items: start;
  padding: 0 1rem;
}

.layout > * {
  min-width: 0;
}

main,
.side {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

main:focus {
  outline: none;
}

main:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

[id] {
  scroll-margin-top: 1rem;
}

.panel {
  position: relative;
  margin: 0;
  padding: 1.85rem 1.4rem 1.6rem;
  color: var(--text);
  background-color: var(--panel);
  background-image: linear-gradient(180deg, rgba(150, 96, 210, 0.11), rgba(22, 18, 30, 0) 7.5rem);
  border: 1px solid var(--purple);
  box-shadow:
    inset 0 0 0 3px var(--panel),
    inset 0 0 0 4px var(--silver),
    0 12px 24px rgba(0, 0, 0, 0.32);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--corner-tl), var(--corner-tr), var(--corner-bl), var(--corner-br);
  background-repeat: no-repeat;
  background-position: 2px 2px, right 2px top 2px, left 2px bottom 2px, right 2px bottom 2px;
  background-size: 16px 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin: 0 0 0.8rem;
  text-align: center;
  font-family: Cinzel, "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.25;
  color: var(--heading);
}

.panel-title::before,
.panel-title::after {
  content: "";
  height: 1px;
  flex: 1 1 1.25rem;
  max-width: 4.5rem;
  background: linear-gradient(90deg, transparent, var(--silver));
}

.panel-title::after {
  background: linear-gradient(90deg, var(--silver), transparent);
}

.panel-title span {
  flex: 0 1 auto;
  min-width: 0;
  text-wrap: balance;
}

.panel > p:first-of-type,
.panel .ep-name + p {
  margin-top: 0;
}

.ep-name {
  margin: 0;
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  color: #f7f4fb;
}

.ep-name a {
  color: inherit;
}

.nav-list,
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stack {
  margin-top: 0.9rem;
}

.bevel,
.social {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 48px;
  padding: 0.55rem 0.85rem;
  border: 1px solid #0e0c14;
  border-radius: 8px;
  color: #f7f4fb;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  background-image: linear-gradient(#4e4860, #2c2838 46%, #1b1824 54%, #262232);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 -2px 0 rgba(0, 0, 0, 0.38);
  transition: background-image 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.bevel {
  width: 100%;
}

.bevel:hover,
.social:hover {
  color: #fff;
  background-image: linear-gradient(#615b78, #383448 46%, #242033 54%, #312c40);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 -2px 0 rgba(0, 0, 0, 0.38),
    0 0 12px rgba(147, 84, 196, 0.45);
}

.bevel:active,
.social:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.bevel[aria-current="page"] {
  background-image: linear-gradient(#6a5688, #3d3154 46%, #2a213c 54%, #3a2d50);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 0 0 1px #eadcf8,
    inset 0 -2px 0 rgba(0, 0, 0, 0.38);
}

.tri {
  width: 0;
  height: 0;
  flex: none;
  border-style: solid;
  border-width: 6px 0 6px 9px;
  border-color: transparent transparent transparent #e4d6f6;
}

.video {
  position: relative;
  width: 100%;
  margin-top: 0.9rem;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--silver);
  box-shadow: 0 0 0 1px var(--purple-deep), 0 0 16px rgba(147, 84, 196, 0.25);
}

.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.guide {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
}

.guide a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.4rem 0.35rem;
  color: #fff;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid var(--line);
  border-radius: 6px;
}

.guide li:last-child a {
  border-bottom: 0;
}

.guide a::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  background: #d7c4f2;
  transform: rotate(45deg);
}

.guide a:hover {
  background: rgba(150, 90, 210, 0.2);
  text-decoration-color: #fff;
}

.view-all {
  margin: 0.95rem 0 0;
  font-weight: 700;
}

.site-footer {
  padding: 0.4rem 1rem 2.5rem;
}

.rule {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.35rem 0 0.9rem;
}

.rule-line {
  flex: 1 1 auto;
  height: 1px;
  background: var(--silver);
}

.rule-line-mid {
  flex: 0 0 2.4rem;
}

.rule-gem,
.rule-cap {
  flex: none;
  transform: rotate(45deg);
}

.rule-gem {
  width: 12px;
  height: 12px;
  background: var(--purple-deep);
  border: 1px solid #f3eef8;
  box-shadow: inset 0 0 0 2px #140e1c;
}

.rule-gem-sm {
  width: 7px;
  height: 7px;
  background: var(--silver);
  border: 0;
  box-shadow: none;
}

.rule-cap {
  width: 7px;
  height: 7px;
  border: 1px solid var(--silver);
}

.disclaimer {
  max-width: 40rem;
  margin: 0 auto;
  text-align: center;
  color: #f3eef8;
}

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.social {
  min-width: 9.75rem;
  justify-content: center;
  padding-inline: 1rem;
}

.social svg {
  display: block;
  flex: none;
}

.visit-count {
  margin: 0.9rem 0 0;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.4;
  font-weight: 400;
  color: var(--silver-soft);
}

.side p,
.panel p {
  color: #f3eef8;
}

a:focus-visible,
.bevel:focus-visible,
.social:focus-visible,
.skip-link:focus-visible,
iframe:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .panel-title {
    font-size: 1.35rem;
    gap: 0.45rem;
  }

  .layout,
  .site-footer {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .social {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .bevel,
  .social {
    transition: none;
  }

  .bevel:active,
  .social:active {
    transform: none;
  }
}

@media (prefers-contrast: more) {
  body {
    background: #000;
    color: #fff;
  }

  .panel {
    background: #000;
    border: 2px solid #fff;
    box-shadow: none;
  }

  .panel-title,
  h1,
  h2,
  h3,
  p,
  a,
  .ep-name,
  .disclaimer {
    color: #fff;
  }

  .bevel,
  .social {
    background: #000;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: none;
  }

  .video {
    border-color: #fff;
    box-shadow: none;
  }
}

@media (forced-colors: active) {
  .panel,
  .bevel,
  .social,
  .video {
    border: 1px solid CanvasText;
    box-shadow: none;
    background: Canvas;
    color: CanvasText;
  }

  .bevel,
  .social,
  a {
    color: LinkText;
  }
}

.script-note {
  max-width: 42rem;
}

.script-actions {
  margin: 0.4rem 0 0;
}

.script-actions .bevel,
.script-download .bevel {
  width: auto;
  max-width: 100%;
  display: inline-flex;
  white-space: normal;
}

.script-download {
  margin: 0.2rem 0 1.4rem;
}

.script-text {
  max-width: 72ch;
  font-size: 1.125rem;
  line-height: 1.8;
  overflow-wrap: break-word;
}

.script-text p {
  margin: 0 0 1.15rem;
  overflow-wrap: break-word;
}

.script-text .script-titleline {
  font-weight: 700;
}

.chapter {
  margin: 2.4rem 0 1rem;
  font-size: 1.35rem;
  line-height: 1.35;
  text-align: left;
  letter-spacing: 0.02em;
  overflow-wrap: break-word;
}

.chapter-num,
.script-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #f3e7ff;
}

.script-label {
  margin: 1.6rem 0 1rem;
  text-align: center;
}

.script-text hr {
  width: 6rem;
  margin: 1.75rem auto;
  border: 0;
  border-top: 1px solid var(--silver-soft);
}

.script-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.85rem 1.5rem;
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.script-pager a {
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: break-word;
}

.pager-next {
  margin-left: auto;
}

.script-index {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
}

.script-index li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  padding: 0.75rem 0.15rem;
  border-bottom: 1px solid var(--line);
}

.script-index li:last-child {
  border-bottom: 0;
}

.script-index-title {
  flex: 1 1 14rem;
  font-weight: 700;
  overflow-wrap: break-word;
}

.script-index a {
  font-weight: 700;
  padding: 0.35rem 0.1rem;
}

@media (max-width: 600px) {
  .script-actions .bevel,
  .script-download .bevel {
    width: 100%;
  }

  .pager-next {
    margin-left: 0;
  }

  .script-index-title {
    flex-basis: 100%;
  }
}
