:root {
  --bg: #000;
  --fg: #fff;
  --space: 6rem;
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 300;
  line-height: 1.6;
  margin: 0;
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space) 16px;
}

@media (min-width: 720px) {
  main {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (max-width: 719px) {
  :root {
    --space: 4rem;
  }
}

/* Type */

h1,
h2,
h3 {
  font-weight: 300;
  margin: 0;
}

h1 {
  font-size: clamp(2.25rem, 7vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
  letter-spacing: 0.04em;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

button {
  background: none;
  border: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:hover,
button:focus-visible {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

[aria-disabled="true"] {
  opacity: 0.2;
  cursor: default;
  text-decoration: none !important;
}

/* Opening */

.opening {
  margin-bottom: var(--space);
}

.opening p {
  margin-top: 1.5rem;
  max-width: 40rem;
  font-size: 1.125rem;
}

.opening p:empty {
  display: none;
}

/* Groups */

.group-intro {
  margin-top: 0.75rem;
  max-width: 40rem;
}

.media {
  margin-top: 3rem;
  container-type: inline-size;
}

.voices,
.stories {
  margin-top: 4rem;
}

hr.break {
  border: 0;
  height: 1px;
  width: 4rem;
  margin: var(--space) auto;
  background: var(--fg);
  opacity: 0.25;
}

/* Carousel */

.carousel {
  /* Slide width is capped by height (52vh) and by half the content width,
     so the visible box is two slides plus gaps wide: each neighbour shows
     half a slide. cqw resolves against .media. */
  --gap: 1rem;
  --slide-w: min(52vh, 50cqw - var(--gap));
  --car-w: calc(2 * var(--slide-w) + 2 * var(--gap));
  position: relative;
  max-width: var(--car-w);
  margin-inline: auto;
}

.track {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-inline: calc((var(--car-w) - var(--slide-w)) / 2);
  scroll-padding-inline: calc((var(--car-w) - var(--slide-w)) / 2);
  overscroll-behavior-x: contain;
}

.track::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

@media (max-width: 719px) {
  .carousel {
    --slide-w: min(76cqw, 60vh);
    --car-w: 100cqw;
  }
}

.slide {
  flex: 0 0 var(--slide-w);
  margin: 0;
  scroll-snap-align: center;
  opacity: 0.35;
  transition: opacity 300ms;
}

.slide.is-active {
  opacity: 1;
}

.slide-open,
.thumb {
  display: block;
  position: relative;
  width: 100%;
}

.slide-open:hover,
.thumb:hover {
  text-decoration: none;
}

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

.slide figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  text-align: center;
}

.badge {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  padding: 0 0.5rem;
  background: var(--bg);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  padding: 0.5rem 1rem;
  font-size: 3rem;
  line-height: 1;
  font-weight: 200;
}

.arrow:hover,
.arrow:focus-visible {
  text-decoration: none;
}

.arrow.prev {
  left: 0;
}

.arrow.next {
  right: 0;
}

.carousel .arrow {
  top: calc(50% - 1rem);
}

@media (max-width: 719px) {
  .carousel .arrow {
    display: none;
  }
}

/* Grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.thumb:hover img {
  opacity: 0.8;
}

.toggle-all {
  display: block;
  margin: 2rem auto 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
}

/* Voices */

.voice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 1rem 0;
}

.play {
  flex: 0 0 4.5rem;
  text-align: left;
  letter-spacing: 0.06em;
  padding: 0.25rem 0;
}

.voice-name {
  flex: 0 0 20rem;
  max-width: 100%;
}

.voice-note {
  flex: 1 1 12rem;
  min-width: 0;
  font-size: 0.875rem;
  opacity: 0.6;
}

.bar {
  position: relative;
  flex: 1 1 10rem;
  height: 1.5rem;
  cursor: pointer;
  touch-action: none;
}

.bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--fg);
  opacity: 0.25;
}

.fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 1px;
  width: 0;
  background: var(--fg);
}

.time {
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.voice-note:empty {
  display: none;
}

@media (max-width: 1099px) {
  .voice-name {
    flex: 1 1 12rem;
  }
}

@media (max-width: 719px) {
  .play {
    flex: 0 0 3.5rem;
    order: 1;
  }
  .voice-name {
    flex: 1 1 0;
    min-width: 0;
    order: 2;
  }
  .time {
    margin-left: auto;
    order: 3;
  }
  .voice-note {
    flex: 1 0 100%;
    order: 4;
  }
  .bar {
    flex: 1 0 100%;
    order: 5;
  }
}

/* Stories */

.story {
  max-width: 40rem;
}

.story + .story {
  margin-top: 3rem;
}

.story-name {
  margin-bottom: 0.5rem;
}

.story-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story.is-open .story-text {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}

.story-text p {
  white-space: pre-line;
  margin: 0 0 1em;
}

.story-text p:last-child {
  margin-bottom: 0;
}

.read {
  margin-top: 0.75rem;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
}

/* Share */

.share {
  margin-top: var(--space);
  max-width: 40rem;
}

.share p {
  margin-bottom: 1rem;
}

#share-link {
  letter-spacing: 0.08em;
  text-decoration: underline;
}

footer {
  margin-top: var(--space);
  font-size: 0.875rem;
}

footer:empty {
  display: none;
}

/* Viewer */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 0 0.5rem;
  background: var(--bg);
  color: var(--fg);
}

.viewer .stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer .stage img,
.viewer .stage video {
  display: block;
  max-width: 100vw;
  max-height: 85vh;
  max-height: min(85vh, calc(100dvh - 9rem));
  object-fit: contain;
}

.viewer .caption {
  margin: 1rem 1rem 0.25rem;
  max-width: 40rem;
  min-height: 1.6em;
  font-size: 0.875rem;
  text-align: center;
}

.viewer .save {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
}

.viewer .close {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  z-index: 3;
  padding: 0 0.75rem;
  font-size: 2.5rem;
  line-height: 1.2;
  font-weight: 200;
}

.viewer .close:hover,
.viewer .close:focus-visible {
  text-decoration: none;
}

.viewer .arrow {
  font-size: 2.5rem;
}

@media (max-width: 719px) {
  .viewer .arrow {
    padding: 0.5rem 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
