/* ABC Diatype */
@font-face {
  font-family: "Diatype";
  src: url("fonts/Diatype-Light.otf") format("opentype");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Diatype";
  src: url("fonts/Diatype-Regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Diatype";
  src: url("fonts/Diatype-Medium.otf") format("opentype");
  font-weight: 500;
  font-display: swap;
}

/* ABC Arizona Flare Condensed Italic — sub-page headers */
@font-face {
  font-family: "Arizona Flare Condensed";
  src: url("fonts/ArizonaFlareCond-Italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Arizona Flare Condensed";
  src: url("fonts/ArizonaFlareCond-MediumItalic.otf") format("opentype");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --bg-warm: #e8e7e1;
  --text: #0a0a0a;
  --muted: #6b6b6b;
  --link: #0a0a0a;
  --maxwidth: 640px;
  --font-sans: "Diatype", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  /* warm gold used for the glow over the homepage video (and the corner fish) */
  --gold: 242, 202, 145;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

/* The "Dear Olin" / writing pages use the warm background */
body.warm {
  background: var(--bg-warm);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.7;
  position: relative;
}

/* Page titles ("Dear Olin", "2025 Books"): small, tracked-out all-caps */
body.warm h1,
body.warm h2 {
  font-family: "Arizona Flare Condensed", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0;
  color: var(--muted);
}

.wrap {
  max-width: var(--maxwidth);
  margin: 0 auto;
  padding: 80px 24px 120px;
}

.wrap.wide {
  max-width: 900px;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  opacity: 0.6;
}

h1 {
  font-size: 1.05rem;
  font-weight: 400;
  margin: 0 0 1.5rem;
}

h2 {
  font-size: 1rem;
  font-weight: 400;
  margin: 2.5rem 0 1rem;
}

p {
  margin: 0 0 1.25rem;
}

.intro p {
  margin: 0 0 0.25rem;
}

/* ---------- Homepage: full-screen background video ----------
   iOS Safari clips `position: fixed` / `sticky` content to the *visual*
   viewport (the strip between the status bar and the URL bar), so a fixed
   video can never paint behind those translucent system bars — that's the
   white banding. Normal-flow content, however, DOES render behind them.
   So the video is a normal-flow block sized TALLER than the screen (via
   --screen-h, set in JS with an iOS overshoot) and page scroll is locked
   to the top; its edges then extend behind the status bar and URL bar for
   true edge-to-edge. (Same fix as the bottle.blue map.) */
body.home {
  margin: 0;
  min-height: 100dvh;
  /* The document is intentionally taller than the screen and JS pins the
     scroll offset — we must NOT hide overflow, or the scroll-lock trick that
     tucks the video behind the status bar can't run. */
  overscroll-behavior: none;
  touch-action: none;          /* don't let the browser start a scroll/pan gesture */
  position: relative;
  background: #2b2620;         /* only ever visible for a frame before the video paints */
}

.bg-video {
  display: block;
  width: 100%;
  height: var(--screen-h, 100dvh);
  object-fit: cover;
}

.home-content {
  /* Fixed (not absolute) so the text stays pinned to the visible viewport
     while the document is held at a scroll offset. iOS clips fixed content to
     the visual viewport — here that's exactly what we want: it keeps the text
     out of the status/URL-bar zones. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  max-width: none;
  padding: calc(72px + env(safe-area-inset-top)) 0 0 calc(88px + env(safe-area-inset-left));
  color: #ffffff;
  /* even, single-color warm glow so white text stays legible over the video */
  text-shadow: 0 0 8px rgba(var(--gold), 0.55),
               0 0 8px rgba(var(--gold), 0.55);
  /* Hold the text hidden until the background video is ready, then fade in
     together so nothing flashes on a blank background first. */
  opacity: 0;
  transition: opacity 0.6s ease;
}

body.home.video-ready .home-content {
  opacity: 1;
}

/* If JS is off, never leave the text invisible */
@media (prefers-reduced-motion: reduce) {
  .home-content {
    transition: none;
  }
}

.home-content a {
  color: #ffffff;
}

.home-content .intro,
.home-content .writing {
  max-width: 53%;
}

.home-content .writing {
  margin-top: 64px;
}

@media (max-width: 809px) {
  .home-content {
    padding:
      calc(48px + env(safe-area-inset-top))
      calc(24px + env(safe-area-inset-right))
      0
      calc(24px + env(safe-area-inset-left));
  }
  .home-content .intro,
  .home-content .writing {
    max-width: 100%;
  }
}

/* Section label like "Writing" */
.section-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* On the homepage, "Writing" sits over the video, so keep it light */
.home-content .section-label {
  color: rgba(255, 255, 255, 0.7);
}

/* List of writing links */
.links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.links li {
  margin: 0 0 0.5rem;
}

.home-content .links {
  font-size: 0.9rem;
}

/* Arrow + title on one line at the top of sub-pages */
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2.5rem;
}

.page-head h1 {
  margin: 0;
}

/* Back link — little hand-drawn SVG arrow */
.back {
  display: inline-block;
  color: var(--muted);
  line-height: 0;
  text-decoration: none;
}

.back svg {
  width: 17px;
  height: auto;
  display: block;
  transition: transform 0.18s ease;
}

.back:hover svg {
  transform: translateX(-3px);
}

.back:hover {
  color: var(--text);
  opacity: 1;
}

/* Little school of fish, fixed in the top-right corner */
.creature-corner {
  position: fixed;
  top: 12px;
  right: 0;       /* flush to the right edge, no side buffer */
  width: 110px;   /* another ~0.7x down from 158px */
  height: auto;
  z-index: 5;
  pointer-events: none;
  image-rendering: pixelated;
}

@media (max-width: 809px) {
  .creature-corner {
    width: 74px;
    top: 8px;
    right: 0;
  }
}

/* Reading list — grid of book covers */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 48px;
  margin-top: 2rem;
  align-items: end;
}

.book-grid img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.book-grid img:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.26);
}

@media (max-width: 809px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 28px;
  }
}

/* Essay spacing */
.essay p {
  margin: 0 0 1.5rem;
}

.essay .divider {
  text-align: center;
  color: var(--muted);
  margin: 2rem 0;
}

.essay ul {
  margin: 0 0 1.5rem;
  padding-left: 1.25rem;
}

.essay li {
  margin: 0 0 0.75rem;
}

.signature {
  margin-top: 2rem;
}
