/* Titles use the italic serif. Everything else uses Instrument Sans. */

:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --paper: #f3e3b3;
  --ink: #1e1b16;
  --muted: #5c5240;
  --accent: #1f2a44;
  --hover: #7c2d3a;
  --line: rgba(30, 27, 22, 0.18);
  --dot: rgba(92, 82, 64, 0.55);
  --cream: #f3e3b3;
  --player: #23211e;
  --serif: "Newsreader", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --player-space: 7rem;
  --track-size: var(--space-1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  padding-bottom: calc(var(--player-space) + var(--space-6));
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: var(--space-1);
}

::selection {
  background: rgba(31, 42, 68, 0.18);
  color: var(--ink);
}

.wrap {
  width: min(40rem, calc(100% - var(--space-12)));
  margin-inline: auto;
}

.site-header {
  padding: calc(var(--space-8) + env(safe-area-inset-top)) 0 var(--space-8);
}

.player-kicker {
  font-weight: 600;
}

.headline {
  margin-top: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.6vw, 1.7rem);
  font-weight: 500;
  font-style: italic;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.intro {
  margin-top: var(--space-4);
  max-width: 60ch;
  color: var(--ink);
  font-size: 1.0625rem;
  line-height: 1.5;
}

.credit {
  margin-top: var(--space-3);
  max-width: 60ch;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: 0;
  margin-bottom: var(--space-8);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.chip-label {
  margin: 0;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--cream);
}

.chip:hover {
  border-color: var(--hover);
  color: var(--hover);
}

.chip[aria-pressed="true"]:hover {
  background: var(--hover);
  border-color: var(--hover);
  color: var(--cream);
}

.stories {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

.story {
  border-top: 1px solid var(--line);
}

.story:last-child {
  border-bottom: 1px solid var(--line);
}

.story-body {
  padding: 2em 0;
  font-size: 1rem;
  transition: font-size 300ms ease;
}

.story:hover .story-body,
.story:focus-within .story-body {
  font-size: 1.04rem;
}

.story.is-leaving {
  pointer-events: none;
  transition: opacity 200ms ease;
}

.story.is-leaving.is-gone {
  opacity: 0;
}

.story.is-entering {
  opacity: 0;
}

.story.is-entering.is-shown {
  opacity: 1;
  transition: opacity 200ms ease;
}

.story-button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.story-title {
  font-family: var(--serif);
  font-size: clamp(1.9em, 4.4vw, 2.85em);
  font-weight: 500;
  font-style: italic;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.title-text {
  display: inline-block;
  max-width: 100%;
  color: var(--ink);
  font-variant-numeric: oldstyle-nums;
}

.story.is-selected .title-text {
  color: var(--accent);
}

.meta {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: 1em;
  line-height: 1.45;
}

.dot {
  font-weight: 700;
}

.row-kicker {
  display: none;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--hover);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.story.is-current .row-kicker {
  display: flex;
}

.now-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--hover);
  flex: none;
  animation: now-pulse 1.6s ease-in-out infinite;
}

@keyframes now-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.35;
    transform: scale(0.65);
  }
}

.person {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.person-name {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.person:hover,
.person:focus-visible {
  color: var(--hover);
}

.external {
  display: inline-block;
  width: 0;
  height: 0.8em;
  margin-left: 0;
  overflow: hidden;
  vertical-align: -0.12em;
  opacity: 0;
  transition: width 200ms ease, margin-left 200ms ease, opacity 200ms ease;
}

.person:hover .external,
.person:focus-visible .external {
  width: 0.85em;
  margin-left: 0.2em;
  opacity: 1;
}

.detail {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  transition: grid-template-rows 250ms ease-out, opacity 250ms ease-out;
}

.story.is-selected .detail {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
}

.detail-inner {
  overflow: hidden;
  min-height: 0;
}

.story.is-selected .story-body {
  padding-bottom: 0.5em;
}

.detail-content {
  padding-top: var(--space-2);
  padding-bottom: var(--space-8);
}

.summary {
  max-width: 36rem;
  color: var(--ink);
  font-size: 1.125rem;
  line-height: 1.55;
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.listen,
.save {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.listen {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--cream);
}

.save {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
}

.listen:hover,
.save:hover {
  border-color: var(--hover);
}

.listen:hover {
  background: var(--hover);
}

.save:hover {
  color: var(--hover);
}

.status {
  margin: 0;
  padding: var(--space-8) 0 var(--space-12);
  color: var(--muted);
  list-style: none;
}

.stories.is-instant .detail {
  transition: none;
}

.player {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  background: var(--player);
  color: var(--cream);
  color-scheme: dark;
}

.player :focus-visible {
  outline-color: var(--cream);
}

.scrubber {
  position: absolute;
  right: 0;
  left: 0;
  /* Keeps the line's top edge flush with the bar as the line grows. */
  top: calc((var(--track-size) - var(--space-6)) / 2);
  z-index: 3;
  height: var(--space-6);
  transition: top 150ms ease;
}

.player-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4);
  width: min(68rem, calc(100% - var(--space-8)));
  margin-inline: auto;
  padding: var(--space-6) 0 calc(var(--space-6) + env(safe-area-inset-bottom));
}

.player-title {
  min-width: 0;
}

.player-kicker {
  margin: 0 0 var(--space-1);
  color: var(--cream);
  opacity: 0.72;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-kicker.is-error {
  opacity: 1;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.72rem;
}

.now-playing {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  font-style: normal;
  line-height: 1.3;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing.is-idle {
  font-weight: 400;
  opacity: 0.72;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
}

.player-times {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--space-2);
}

.skip,
.play {
  margin: 0;
  border: 0;
  cursor: pointer;
}

.skip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.skip-icon,
.icon-play,
.icon-pause {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
}

.skip:hover:not(:disabled) {
  background: rgba(243, 227, 179, 0.12);
}

.play {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--player);
}

.play .icon-pause {
  display: none;
}

.play.is-playing .icon-play {
  display: none;
}

.play.is-playing .icon-pause {
  display: block;
}

.icon-play {
  transform: translateX(1.5px);
}

.play:hover:not(:disabled) {
  background: #fff6d8;
}

.skip:disabled,
.play:disabled {
  opacity: 0.35;
  cursor: default;
}

.time {
  color: var(--cream);
  opacity: 0.86;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.scrubber input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--space-6);
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  accent-color: var(--cream);
}

.scrubber input[type="range"]:disabled {
  opacity: 0.45;
  cursor: default;
}

.scrubber input[type="range"]:focus-visible {
  outline: none;
}

.scrubber input[type="range"]::-webkit-slider-runnable-track {
  height: var(--track-size);
  border-radius: 0;
  background: linear-gradient(
    to right,
    #fff 0%,
    #fff var(--pct, 0%),
    rgba(255, 255, 255, 0.18) var(--pct, 0%),
    rgba(255, 255, 255, 0.18) 100%
  );
  transition: height 150ms ease;
}

.scrubber:hover,
.scrubber:focus-within {
  --track-size: var(--space-2);
}

.scrubber input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--space-3);
  height: var(--space-3);
  margin-top: calc((var(--track-size) - var(--space-3)) / 2);
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.45);
  transition: margin-top 150ms ease;
}

.scrubber input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 var(--space-1) rgba(255, 255, 255, 0.45);
}

.scrubber input[type="range"]::-moz-range-track {
  height: var(--track-size);
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.18);
  transition: height 150ms ease;
}

.scrubber input[type="range"]::-moz-range-progress {
  height: var(--track-size);
  border-radius: 0;
  background: #fff;
}

.scrubber input[type="range"]::-moz-range-thumb {
  width: var(--space-3);
  height: var(--space-3);
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.45);
}

audio {
  display: none;
}

@media (max-width: 719px) {
  .wrap {
    width: min(40rem, calc(100% - var(--space-8)));
  }

  .player-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title times"
      "controls controls";
    width: min(68rem, calc(100% - var(--space-6)));
    padding-top: var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
    row-gap: var(--space-3);
  }

  .player-title {
    grid-area: title;
  }

  .player-times {
    grid-area: times;
  }

  .transport {
    grid-area: controls;
  }
}

@media (min-width: 720px) {
  .site-header {
    padding-top: calc(var(--space-16) + env(safe-area-inset-top));
    padding-bottom: var(--space-8);
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-body,
  .external,
  .story.is-leaving,
  .story.is-entering,
  .detail,
  .stories.is-instant .detail,
  .scrubber {
    transition: none;
  }

  .story:hover .story-body,
  .story:focus-within .story-body {
    font-size: 1rem;
  }

  .now-dot {
    animation: none;
  }

  .scrubber:hover,
  .scrubber:focus-within {
    --track-size: var(--space-1);
  }
}
