/* voided thoughts: one stylesheet for every page */

:root {
  --bg: #07070a;
  --surface: #0f0f15;
  --line: #252736;
  --text: #dfe1ec;
  --muted: #8b8fa6;
  --accent: #9e1218;

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --column: 38rem;   /* width of a block of reading text */
  --wide: 54rem;     /* width of the video and the archive */
  --gutter: 1.25rem; /* space at the screen edges on a phone */
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* faint ink scratches, the same as the background of the drawings */
  background: var(--bg) url("../assets/ink/scratches.svg") 0 0 / 900px 900px repeat;
  color: var(--text);
  font: 400 1.0625rem/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 720px) {
  body {
    font-size: 1.125rem;
  }
}

img {
  max-width: 100%;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.15;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 1px dashed var(--muted);
  outline-offset: 5px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 2;
}

.skip:focus {
  top: 1rem;
}

/* a link with a hand-drawn underline that turns red on hover */
.ink-link {
  text-decoration: none;
  padding-bottom: 5px;
  background: url("../assets/ink/underline.svg") 0 100% / 100% 7px no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.ink-link:hover,
.ink-link:focus-visible {
  background-image: url("../assets/ink/underline-red.svg");
}

/* a small italic heading followed by a hand-drawn line */
.label {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-style: italic;
  font-size: 1.5rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.label::after {
  content: "";
  flex: 1;
  height: 14px;
  background: url("../assets/ink/rule.svg") 0 50% / 100% 100% no-repeat;
}

/* a hand-drawn sheet of paper behind a block of text */
.sheet {
  position: relative;
  isolation: isolate;
  padding: 2.25rem 1.75rem 2.5rem;
}

.sheet::before {
  content: "";
  position: absolute;
  inset: -4px -12px -14px -4px;
  z-index: -1;
  background: url("../assets/ink/sheet-a.svg") 0 0 / 100% 100% no-repeat;
}

@media (min-width: 720px) {
  .sheet {
    padding: 3rem 3rem 3.25rem;
  }
}

/* header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem var(--gutter);
}

.site-name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.1rem;
  margin-left: auto;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 5px;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: url("../assets/ink/underline-red.svg") 0 100% / 100% 7px no-repeat;
}

@media (min-width: 720px) {
  .site-nav {
    gap: 1.6rem;
    font-size: 0.95rem;
  }
}

/* home: the cover */

.hero {
  position: relative;
}

.hero img {
  display: block;
  width: 100%;
  height: auto;
  /* on a phone, keep the right part of the drawing: the skull and the lettering */
  aspect-ratio: 25 / 18;
  object-fit: cover;
  object-position: 100% 50%;
  padding-right: 4vw; /* the lettering sits right at the edge of the drawing */
}

.hero-text {
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 1.75rem var(--gutter) 0;
}

.hero h1 {
  font-size: clamp(3rem, 13vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.hero p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--muted);
  max-width: 24ch;
}

@media (min-width: 720px) {
  .hero img {
    aspect-ratio: 5 / 2;
    max-height: 88vh;
    padding-right: 0;
  }

  /* the left half of the drawing is empty, so the name sits there */
  .hero-text {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 50%;
    max-width: none;
    margin: 0;
    padding: 0 0 0 7vw;
  }

  .hero h1 {
    font-size: clamp(3rem, 6vw, 6.5rem);
  }

  .hero p {
    font-size: clamp(1.3rem, 1.8vw, 1.75rem);
  }
}

/* home: the letter */

.letter {
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 6rem auto 0;
  padding: 0 var(--gutter);
}

.letter-art {
  display: block;
  width: 130px;
  height: auto;
  margin: 0 0 0.5rem auto;
}

.letter-open {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.75rem;
  line-height: 1.25;
  margin-bottom: 1.5rem;
}

.letter p + p {
  margin-top: 1.25em;
}

/* patreon, in red ink: under the channel line on the cover, and signing off the letter.
   the same mark twice, and the only red on the page */
.hero .hero-patreon {
  display: inline-block;
  margin-top: 1.4rem;
  font-size: 1.75rem;
}
.letter .letter-sign {
  margin-top: 2rem;
  text-align: right;
}

.patreon-link {
  font-family: var(--serif);
  font-style: italic;
  font-size: 2rem;
  line-height: 1.2;
  text-decoration: none;
  padding: 0 0.15em 8px;
  background: url("../assets/ink/underline-red.svg") 0 100% / 100% 8px no-repeat;
}

@media (min-width: 900px) {
  /* the envelope moves out into the left margin */
  .letter {
    position: relative;
  }

  .letter-art {
    position: absolute;
    right: 100%;
    top: -1rem;
    width: 190px;
    margin: 0;
  }

  .letter-open {
    font-size: 2.1rem;
  }
}

/* home: the latest video, in a sketched frame */

.latest {
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 7rem auto 0;
  padding: 0 var(--gutter);
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
}

.video-frame::after {
  content: "";
  position: absolute;
  inset: -14px;
  background: url("../assets/ink/frame.svg") 0 0 / 100% 100% no-repeat;
  pointer-events: none;
}

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

.video-play {
  display: block;
  padding: 0;
  background: none;
  cursor: pointer;
}

.video-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.78);
}

.video-play:hover .video-thumb,
.video-play:focus-visible .video-thumb {
  filter: none;
}

.play-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76px;
  height: 76px;
  transform: translate(-50%, -50%);
  background: url("../assets/ink/play.svg") 0 0 / 100% 100% no-repeat;
}

.video-caption {
  margin-top: 2.25rem;
}

.video-caption h3 {
  font-size: 1.75rem;
}

.meta {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.35rem;
}

.video-link {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 1.1rem;
}

/* home: a short contents list of the videos before the latest */

.earlier {
  max-width: var(--column);
  margin-top: 4rem;
}

.earlier .label {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.contents {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contents a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.55rem 0;
  text-decoration: none;
}

.contents-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.3;
  padding-bottom: 4px;
}

.contents a:hover .contents-title,
.contents a:focus-visible .contents-title {
  background: url("../assets/ink/underline-red.svg") 0 100% / 100% 7px no-repeat;
}

.contents-dots {
  flex: 1;
  min-width: 1.5rem;
  height: 6px;
  background: url("../assets/ink/dots.svg") 0 0 / 96px 6px repeat-x;
}

.contents-length {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.quiet-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.25rem;
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 5rem auto 0;
  padding: 0 var(--gutter);
  color: var(--muted);
  font-size: 0.95rem;
}

/* other pages: a small drawing, a title, then the page */

.page {
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 0;
}

.page--wide {
  max-width: calc(var(--wide) + 2 * var(--gutter));
}

.page-art {
  display: block;
  width: 150px;
  height: auto;
  margin: 0 0 1rem -14px;
}

.page-title {
  font-size: clamp(3rem, 12vw, 4.5rem);
  line-height: 1;
}

.page-note {
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  margin-top: 0.5rem;
}

.page-lead {
  margin-top: 2rem;
}

@media (min-width: 720px) {
  .page {
    padding-top: 3rem;
  }

  .page-art {
    width: 190px;
  }
}

/* videos page */

.archive {
  margin-top: 4rem;
}

.year + .year {
  margin-top: 4.5rem;
}

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2.25rem;
}

.entry a {
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 1.1rem;
  align-items: start;
  text-decoration: none;
}

.entry-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
}

.entry-thumb::after {
  content: "";
  position: absolute;
  inset: -7px;
  background: url("../assets/ink/frame.svg") 0 0 / 100% 100% no-repeat;
}

.entry-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.78);
}

.entry a:hover .entry-thumb img,
.entry a:focus-visible .entry-thumb img {
  filter: none;
}

.entry-number {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.entry-title {
  display: block;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.25;
}

.entry a:hover .entry-title,
.entry a:focus-visible .entry-title {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.entry .meta {
  display: block;
}

.entry-note {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text);
  margin-top: 0.6rem;
}

/* a turning point: a second hand-drawn line under the entry */
.entry--milestone {
  padding-bottom: 2.5rem;
  background: url("../assets/ink/rule.svg") 0 100% / 100% 14px no-repeat;
}

.entry--removed a {
  opacity: 0.55;
}

.entry--removed .entry-thumb img {
  filter: grayscale(1) brightness(0.6);
}

@media (min-width: 720px) {
  .entry a {
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: center;
  }

  .entry-title {
    font-size: 1.6rem;
  }
}

/* footer */

.site-footer {
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 8rem auto 0;
  padding: 0 var(--gutter) 3.5rem;
}

.site-footer::before {
  content: "";
  display: block;
  height: 14px;
  margin-bottom: 2rem;
  background: url("../assets/ink/rule.svg") 0 50% / 100% 100% no-repeat;
}

.footer-name {
  font-family: var(--serif);
  font-size: 1.2rem;
  text-decoration: none;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.75rem;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* line boil: on hover, drawings and ink frames are redrawn about eight times a second,
   like hand-drawn animation (js/site.js adds the extra frames of the drawings) */

.boil {
  position: relative;
}

.boil > img,
.boil > picture {
  display: block;
}

.letter-art img,
.page-art img {
  width: 100%;
  height: auto;
}

.boil-frame {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

/* motion: the boil and a slow fade-in, and nothing for people who turn motion off */

@media (prefers-reduced-motion: no-preference) {
  main {
    animation: fade-in 1.4s ease-out both;
  }

  .video-thumb,
  .entry-thumb img {
    transition: filter 0.6s ease;
  }

  /* on phones, js/site.js adds .is-boiling for a moment as things scroll into view */
  .boil.is-boiling .boil-frame--b {
    animation: show-second 360ms step-end infinite;
  }

  .boil.is-boiling .boil-frame--c {
    animation: show-third 360ms step-end infinite;
  }

  .is-boiling .video-frame::after {
    animation: boil-frame 360ms step-end infinite;
  }

  .is-boiling .play-mark {
    animation: boil-play 360ms step-end infinite;
  }

  .sheet.is-boiling::before {
    animation: boil-sheet-a 360ms step-end infinite;
  }
}

/* the boil only runs while the mouse is over something, so the page stays still otherwise */
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .hero:hover .boil-frame--b,
  .boil:hover .boil-frame--b {
    animation: show-second 360ms step-end infinite;
  }

  .hero:hover .boil-frame--c,
  .boil:hover .boil-frame--c {
    animation: show-third 360ms step-end infinite;
  }

  .video-frame:hover::after,
  .video-frame:focus-within::after,
  .entry a:hover .entry-thumb::after,
  .entry a:focus-visible .entry-thumb::after {
    animation: boil-frame 360ms step-end infinite;
  }

  .video-frame:hover .play-mark,
  .video-frame:focus-within .play-mark {
    animation: boil-play 360ms step-end infinite;
  }

  .sheet:hover::before {
    animation: boil-sheet-a 360ms step-end infinite;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes show-second {
  0% { opacity: 0; }
  33.333% { opacity: 1; }
  66.666% { opacity: 0; }
}

@keyframes show-third {
  0% { opacity: 0; }
  66.666% { opacity: 1; }
}

@keyframes boil-frame {
  0% { background-image: url("../assets/ink/frame.svg"); }
  33.333% { background-image: url("../assets/ink/frame-b.svg"); }
  66.666% { background-image: url("../assets/ink/frame-c.svg"); }
}

@keyframes boil-sheet-a {
  0% { background-image: url("../assets/ink/sheet-a.svg"); }
  33.333% { background-image: url("../assets/ink/sheet-a-b.svg"); }
  66.666% { background-image: url("../assets/ink/sheet-a-c.svg"); }
}

@keyframes boil-play {
  0% { background-image: url("../assets/ink/play.svg"); }
  33.333% { background-image: url("../assets/ink/play-b.svg"); }
  66.666% { background-image: url("../assets/ink/play-c.svg"); }
}
