@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #171712;
  --paper: #f1eddf;
  --paper-light: #f9f6ec;
  --red: #f04c31;
  --blue: #2456d4;
  --acid: #d8f35a;
  --line: rgba(23, 23, 18, 0.28);
  --sans: "Space Grotesk", Arial, sans-serif;
  --serif: "Literata", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 300px;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, transparent 49.85%, rgba(23, 23, 18, 0.035) 50%, transparent 50.15%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: rgba(36, 86, 212, 0.16);
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  touch-action: manipulation;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 12px 16px;
  transform: translateY(-150%);
  background: var(--ink);
  color: white;
  text-decoration: none;
  transition: transform 160ms ease;
}

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

.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 88px;
  align-items: center;
  border-bottom: 1px solid var(--ink);
  padding: 0 clamp(22px, 4vw, 64px);
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: var(--paper-light);
  font-size: 24px;
  transform: rotate(-12deg);
}

.brand:hover .brand-mark {
  transform: rotate(12deg);
}

.issue {
  display: flex;
  gap: 28px;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pocket-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.pocket-link:hover .pocket-label,
.pocket-link[aria-pressed="true"] .pocket-label {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.pocket-icon {
  font-size: 22px;
}

.pocket-link[aria-pressed="true"] .pocket-icon {
  color: var(--red);
}

.pocket-count {
  display: grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-variant-numeric: tabular-nums;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.55fr);
  min-height: 510px;
  border-bottom: 1px solid var(--ink);
}

.intro-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(42px, 6vw, 88px) clamp(28px, 6vw, 94px) 58px clamp(22px, 4vw, 64px);
}

.eyebrow,
.kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before,
.kicker::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--red);
}

.intro h1 {
  max-width: 960px;
  margin: 50px 0 0;
  font-family: var(--serif);
  font-size: clamp(58px, 7.7vw, 116px);
  font-weight: 450;
  letter-spacing: -0.065em;
  line-height: 0.88;
  text-wrap: balance;
}

.intro h1 em {
  position: relative;
  color: var(--blue);
  font-weight: 450;
}

.intro h1 em::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -8px;
  left: 0;
  height: 10px;
  border-top: 4px solid var(--blue);
  border-radius: 50%;
  transform: rotate(-2deg);
}

.intro-note {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-left: 1px solid var(--ink);
  padding: 36px clamp(22px, 4vw, 56px) 58px;
  background:
    radial-gradient(circle at 34% 24%, rgba(240, 76, 49, 0.13) 0 4px, transparent 5px),
    linear-gradient(145deg, transparent 58%, rgba(36, 86, 212, 0.08));
}

.route-glyph {
  margin: auto auto auto 0;
  color: var(--red);
  font-family: var(--serif);
  font-size: 110px;
  line-height: 1;
  transform: rotate(-18deg);
}

.intro-note p {
  max-width: 280px;
  margin: 42px 0 34px;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.45;
  text-wrap: pretty;
}

.begin-link {
  display: flex;
  min-height: 44px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--ink);
  padding-top: 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.begin-link:hover {
  color: var(--blue);
}

.explorer {
  position: relative;
  scroll-margin-top: 20px;
  padding: 86px clamp(22px, 4vw, 64px) 120px;
  background-color: var(--paper-light);
  background-image: radial-gradient(rgba(23, 23, 18, 0.18) 0.75px, transparent 0.75px);
  background-size: 13px 13px;
}

.explorer-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
}

.explorer h2 {
  margin: 13px 0 0;
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 74px);
  font-weight: 450;
  letter-spacing: -0.055em;
  line-height: 1;
  text-wrap: balance;
}

.result-count {
  margin: 0 0 9px;
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
}

.toolbelt {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(210px, 0.75fr) auto;
  gap: 0;
  margin-top: 50px;
  border: 1px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  background: var(--paper);
}

.search-field,
.filter-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px 12px;
  border-right: 1px solid var(--ink);
}

.control-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.search-input-wrap,
.select-wrap {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.search-input-wrap input,
.select-wrap select {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 2px 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.search-field:focus-within,
.filter-field:focus-within {
  box-shadow: inset 0 -4px 0 var(--blue);
}

.search-input-wrap input::placeholder {
  color: rgba(23, 23, 18, 0.5);
}

.select-wrap select {
  appearance: none;
  cursor: pointer;
}

.select-wrap > span {
  pointer-events: none;
}

.shuffle-button {
  display: flex;
  min-width: 225px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  padding: 14px 22px;
  background: var(--acid);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.shuffle-button:hover {
  background: var(--ink);
  color: var(--acid);
}

.shuffle-mark {
  font-size: 22px;
}

.route-key {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 74px 0 38px;
  color: rgba(23, 23, 18, 0.62);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.route-key-line {
  width: min(22vw, 300px);
  border-top: 2px dashed var(--red);
}

.story-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 76px 28px;
  max-width: 1320px;
  margin: 0 auto;
}

.story-grid::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 6%;
  right: 16%;
  bottom: 8%;
  left: 17%;
  border: 3px dashed rgba(240, 76, 49, 0.55);
  border-right-color: transparent;
  border-radius: 38% 58% 46% 54%;
  transform: rotate(-4deg);
  pointer-events: none;
}

.story-card {
  --card-color: var(--paper);
  position: relative;
  z-index: 1;
  grid-column: span 4;
  min-width: 0;
  align-self: start;
  transform: rotate(var(--tilt, -1deg));
}

.story-card:nth-child(4n + 2) {
  --tilt: 1.3deg;
  margin-top: 68px;
}

.story-card:nth-child(4n + 3) {
  --tilt: -0.7deg;
  margin-top: 18px;
}

.story-card:nth-child(4n) {
  --tilt: 0.8deg;
  grid-column: 3 / span 4;
}

.story-card:nth-child(4n + 5) {
  grid-column: 7 / span 4;
}

.story-card[data-category="Culture"] { --card-color: #f7c9da; }
.story-card[data-category="Food"] { --card-color: #ffd46b; }
.story-card[data-category="Movement"] { --card-color: #bdd7ff; }
.story-card[data-category="People"] { --card-color: #d6c9f7; }
.story-card[data-category="Places"] { --card-color: #c8e5cb; }

.card-index {
  position: absolute;
  z-index: 2;
  top: -19px;
  left: -15px;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 3px 3px 0 var(--red);
}

.story-card.is-saved .card-index::after {
  content: "◆";
  position: absolute;
  top: -12px;
  right: -12px;
  color: var(--red);
  font-size: 14px;
}

.card-inner {
  display: flex;
  min-height: 390px;
  flex-direction: column;
  border: 1px solid var(--ink);
  padding: 30px 28px 25px;
  background: var(--card-color);
  box-shadow: 7px 7px 0 rgba(23, 23, 18, 0.9);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.story-card:hover .card-inner,
.story-card:focus-within .card-inner {
  transform: translate(-3px, -3px);
  box-shadow: 12px 12px 0 var(--ink);
}

.card-topline,
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.category,
.duration {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.duration {
  white-space: nowrap;
}

.category::before {
  content: "●";
  margin-right: 6px;
  color: var(--red);
}

.card-title {
  margin: 45px 0 18px;
  font-family: var(--serif);
  font-size: clamp(28px, 2.3vw, 38px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.02;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.card-summary {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.card-footer {
  align-items: end;
  margin-top: auto;
  padding-top: 28px;
  border-top: 1px solid rgba(23, 23, 18, 0.38);
}

.card-footer p {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
}

.by {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
}

.open-story {
  min-height: 44px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  padding: 4px 0;
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.open-story:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.empty-state {
  max-width: 590px;
  margin: 80px auto 0;
  border: 1px solid var(--ink);
  padding: 44px;
  background: var(--paper);
  text-align: center;
  box-shadow: 8px 8px 0 var(--red);
}

.empty-state[hidden] {
  display: none;
}

.empty-sign {
  color: var(--red);
  font-size: 54px;
}

.empty-state h3 {
  margin: 10px 0;
  font-family: var(--serif);
  font-size: 34px;
}

.empty-state p {
  font-family: var(--serif);
  line-height: 1.6;
}

.empty-state button {
  margin-top: 12px;
  border: 1px solid var(--ink);
  padding: 12px 18px;
  background: var(--acid);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.empty-state button:hover {
  background: var(--ink);
  color: white;
}

.footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: 30px;
  min-height: 250px;
  padding: 60px clamp(22px, 4vw, 64px);
  background: var(--ink);
  color: var(--paper-light);
}

.footer-brand {
  font-size: clamp(36px, 5vw, 74px);
  font-weight: 700;
  letter-spacing: -0.06em;
}

.footer-brand span {
  color: var(--red);
}

.footer p {
  max-width: 300px;
  margin: 0;
  font-family: var(--serif);
  line-height: 1.55;
}

.footer-small {
  justify-self: end;
  font-family: var(--sans) !important;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--paper-light);
  color: var(--ink);
}

.detail-dialog::backdrop {
  background: rgba(23, 23, 18, 0.72);
}

.detail-shell {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 100%;
}

.detail-rail {
  display: flex;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--ink);
  padding: 34px 20px;
  background: var(--red);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.detail-number {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-light);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rail-line {
  width: 1px;
  flex: 1;
  margin: 20px 0;
  border-left: 2px dashed var(--ink);
}

.detail-article {
  min-width: 0;
  padding-bottom: 100px;
}

.detail-header {
  padding: 28px clamp(30px, 7vw, 110px) 68px;
  border-bottom: 1px solid var(--ink);
}

.detail-actions {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: clamp(70px, 12vh, 130px);
}

.close-detail,
.save-item,
.next-story {
  min-height: 44px;
  border: 0;
  padding: 8px 0;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.close-detail,
.save-item {
  border-bottom: 2px solid var(--ink);
}

.close-detail:hover,
.save-item:hover,
.next-story:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.save-item[aria-pressed="true"] {
  color: var(--red);
  border-color: var(--red);
}

.save-symbol {
  margin-right: 6px;
  font-size: 17px;
}

.detail-category {
  margin: 0 0 16px;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.detail-header h2 {
  max-width: 1120px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(48px, 7.5vw, 108px);
  font-weight: 450;
  letter-spacing: -0.06em;
  line-height: 0.95;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.detail-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 30px;
  margin-top: 38px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-byline span + span::before {
  content: "◇";
  margin-right: 30px;
}

.detail-body {
  max-width: 760px;
  margin: 0 auto;
  padding: 90px 40px 70px;
  font-family: var(--serif);
  font-size: clamp(18px, 1.55vw, 22px);
  line-height: 1.78;
}

.detail-body p {
  margin: 0 0 1.55em;
  text-wrap: pretty;
}

.detail-body p:first-child::first-letter {
  float: left;
  margin: 0.05em 0.11em 0 0;
  color: var(--red);
  font-family: var(--sans);
  font-size: 4.1em;
  font-weight: 700;
  line-height: 0.8;
}

.article-end {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  max-width: 760px;
  margin: 0 auto;
  border-top: 1px solid var(--ink);
  padding: 28px 40px;
}

.article-end > span {
  color: var(--red);
  font-size: 30px;
}

.article-end p {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
}

.next-story {
  border-bottom: 2px solid var(--ink);
}

.noscript {
  position: fixed;
  z-index: 200;
  right: 20px;
  bottom: 20px;
  border: 1px solid var(--ink);
  padding: 14px;
  background: var(--acid);
}

@media (max-width: 900px) {
  .issue {
    display: none;
  }

  .masthead {
    grid-template-columns: 1fr auto;
  }

  .intro {
    grid-template-columns: 1fr;
  }

  .intro-note {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    border-top: 1px solid var(--ink);
    border-left: 0;
    padding: 30px;
  }

  .route-glyph {
    grid-row: span 2;
    margin: 0;
    font-size: 72px;
  }

  .intro-note p {
    max-width: none;
    margin: 0;
  }

  .toolbelt {
    grid-template-columns: 1fr 1fr;
  }

  .filter-field {
    border-right: 0;
  }

  .shuffle-button {
    grid-column: 1 / -1;
    min-height: 52px;
    border-top: 1px solid var(--ink);
  }

  .story-card,
  .story-card:nth-child(4n),
  .story-card:nth-child(4n + 5) {
    grid-column: span 6;
  }

  .footer {
    grid-template-columns: 1fr 1fr;
  }

  .footer-small {
    grid-column: 2;
  }
}

@media (max-width: 600px) {
  .masthead {
    min-height: 68px;
    padding: 0 18px;
  }

  .brand {
    font-size: 20px;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
  }

  .pocket-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .intro {
    min-height: auto;
  }

  .intro-copy {
    min-height: 430px;
    padding: 42px 20px 45px;
  }

  .intro h1 {
    margin-top: 48px;
    font-size: clamp(55px, 17vw, 72px);
    line-height: 0.91;
  }

  .intro-note {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 28px 20px 34px;
  }

  .route-glyph {
    display: none;
  }

  .intro-note p {
    margin-bottom: 16px;
    font-size: 18px;
  }

  .explorer {
    padding: 66px 18px 90px;
  }

  .explorer-heading {
    align-items: start;
    flex-direction: column;
    gap: 18px;
  }

  .explorer h2 {
    font-size: 45px;
  }

  .result-count {
    align-self: flex-end;
  }

  .toolbelt {
    grid-template-columns: 1fr;
    margin-top: 34px;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .search-field,
  .filter-field {
    min-height: 69px;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .shuffle-button {
    grid-column: auto;
    border-top: 0;
  }

  .route-key {
    justify-content: center;
    margin: 54px 0 40px;
  }

  .route-key-line {
    flex: 1;
  }

  .story-grid {
    display: block;
  }

  .story-grid::before {
    top: 30px;
    right: auto;
    bottom: 30px;
    left: 18px;
    width: 0;
    border: 0;
    border-left: 3px dashed rgba(240, 76, 49, 0.55);
    border-radius: 0;
    transform: none;
  }

  .story-card,
  .story-card:nth-child(4n + 2),
  .story-card:nth-child(4n + 3),
  .story-card:nth-child(4n),
  .story-card:nth-child(4n + 5) {
    margin: 0 0 42px 18px;
    transform: rotate(var(--tilt, -0.5deg));
  }

  .card-inner {
    min-height: 350px;
    padding: 26px 22px 22px;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .card-index {
    left: -17px;
  }

  .card-title {
    margin-top: 38px;
    font-size: 32px;
  }

  .card-footer {
    align-items: start;
    flex-direction: column;
  }

  .footer {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 52px 22px;
  }

  .footer-small {
    grid-column: auto;
    justify-self: start;
  }

  .detail-shell {
    display: block;
  }

  .detail-rail {
    display: none;
  }

  .detail-header {
    padding: max(20px, env(safe-area-inset-top)) 20px 42px;
  }

  .detail-actions {
    position: sticky;
    z-index: 2;
    top: 0;
    align-items: center;
    margin: -20px -20px 72px;
    border-bottom: 1px solid var(--ink);
    padding: max(16px, env(safe-area-inset-top)) 20px 14px;
    background: rgba(249, 246, 236, 0.96);
  }

  .close-detail,
  .save-item {
    border-bottom: 0;
    padding: 5px 0;
  }

  .close-detail {
    max-width: 130px;
  }

  .save-item {
    text-align: right;
  }

  .detail-header h2 {
    font-size: 50px;
    line-height: 0.98;
  }

  .detail-byline {
    display: grid;
    gap: 9px;
    margin-top: 30px;
  }

  .detail-byline span + span::before {
    margin-right: 10px;
  }

  .detail-body {
    padding: 55px 24px 42px;
    font-size: 18px;
    line-height: 1.7;
  }

  .article-end {
    grid-template-columns: auto 1fr;
    margin: 0 24px;
    padding: 24px 0 calc(30px + env(safe-area-inset-bottom));
  }

  .next-story {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
