@font-face {
  font-family: "DM Sans";
  src: url("./assets/dm-sans.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "DM Serif Display";
  src: url("./assets/dm-serif.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #14211d;
  --paper: #f3efe5;
  --paper-light: #faf8f2;
  --red: #ef573d;
  --red-dark: #b83121;
  --sage: #b7c4a8;
  --line: #bbb9ae;
  --muted: #5c625f;
  --white: #fffdf8;
  --sans: "DM Sans", Arial, sans-serif;
  --serif: "DM Serif Display", Georgia, serif;
  --content: min(1320px, calc(100vw - 72px));
  --shadow: 0 24px 70px rgba(20, 33, 29, 0.2);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
select,
a,
input[type="search"] {
  cursor: pointer;
  touch-action: manipulation;
}

input[type="search"] {
  cursor: text;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 12px 16px;
  color: var(--white);
  background: var(--ink);
  transform: translateY(-150%);
}

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

.site-header {
  border-bottom: 1px solid var(--ink);
}

.header-inner {
  width: var(--content);
  min-height: 82px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.wordmark {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.13em;
  text-decoration: none;
}

.wordmark-mark {
  width: 22px;
  height: 22px;
  border: 6px solid var(--ink);
  border-right-color: var(--red);
  border-radius: 50%;
  transform: rotate(-25deg);
}

.header-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-link {
  justify-self: end;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-underline-offset: 4px;
}

.cover {
  width: var(--content);
  margin: 0 auto;
  padding: 52px 0 66px;
  display: grid;
  grid-template-columns: 1fr 6fr 2fr;
  align-items: end;
  gap: 40px;
  border-bottom: 1px solid var(--ink);
}

.cover-meta {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.cover h1 {
  max-width: 950px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(56px, 6.6vw, 104px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.91;
}

.cover h1 em {
  color: var(--red);
  font-weight: 400;
}

.cover-aside {
  border-left: 1px solid var(--line);
  padding-left: 24px;
}

.cover-number {
  display: block;
  margin-bottom: 12px;
  font-family: var(--serif);
  font-size: 56px;
  line-height: 0.8;
}

.cover-aside p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.browser {
  width: var(--content);
  margin: 0 auto;
  padding: 64px 0 100px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 30px;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(40px, 4.2vw, 62px);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1;
}

.result-count {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.filter-bar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 230px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 38px;
  padding: 18px;
  border: 1px solid var(--ink);
  background: var(--paper-light);
}

.filter-bar label {
  display: block;
  margin: 0 0 7px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.input-wrap,
.select-wrap {
  position: relative;
}

.input-wrap svg {
  position: absolute;
  top: 50%;
  left: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  transform: translateY(-50%);
  pointer-events: none;
}

.input-wrap input,
.select-wrap select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--white);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.input-wrap input {
  padding: 0 16px 0 48px;
}

.select-wrap select {
  appearance: none;
  padding: 0 46px 0 16px;
}

.input-wrap input:hover,
.select-wrap select:hover {
  border-color: var(--ink);
}

.input-wrap input::placeholder {
  color: #777b77;
}

.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transform: translateY(-50%);
  pointer-events: none;
}

.saved-toggle {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
  font-weight: 650;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.saved-toggle:hover {
  transform: translateY(-2px);
}

.saved-toggle[aria-pressed="true"] {
  color: var(--white);
  background: var(--ink);
}

.saved-toggle svg,
.saved-marker svg,
.save-story svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.saved-toggle[aria-pressed="true"] svg,
.saved-marker svg,
.save-story[aria-pressed="true"] svg {
  fill: currentColor;
}

.saved-count {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--red-dark);
  font-size: 12px;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 32px 20px;
}

.story-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--ink);
}

.story-card:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--sage);
}

.story-card:first-child .card-image-wrap {
  aspect-ratio: 16 / 10;
}

.card-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.78) contrast(1.02);
  transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1), filter 300ms ease;
}

.story-card:hover .card-image {
  transform: scale(1.035);
  filter: saturate(0.95) contrast(1.02);
}

.illustration-label {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 7px;
  color: var(--white);
  background: rgba(20, 33, 29, 0.82);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.saved-marker {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--red-dark);
  border-radius: 50%;
}

.card-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 17px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--red-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card-time {
  color: var(--muted);
}

.story-card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.04;
}

.story-card:first-child h3 {
  max-width: 610px;
  font-size: clamp(36px, 3.3vw, 50px);
}

.open-story {
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.open-story:hover {
  color: var(--red-dark);
  text-decoration-color: currentColor;
}

.open-story:active,
.header-link:active,
.wordmark:active,
.close-detail:active {
  opacity: 0.62;
}

.card-summary {
  margin: 13px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.story-card:first-child .card-summary {
  max-width: 560px;
  font-size: 16px;
}

.card-byline {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  font-weight: 650;
}

.arrow {
  color: var(--red-dark);
  font-size: 18px;
}

.empty-state {
  max-width: 660px;
  margin: 72px auto 0;
  text-align: center;
}

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

.empty-mark {
  width: 64px;
  height: 64px;
  display: block;
  margin: 0 auto 28px;
  border: 15px solid var(--ink);
  border-right-color: var(--red);
  border-radius: 50%;
  transform: rotate(-25deg);
}

.empty-state h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 400;
  letter-spacing: -0.03em;
}

.empty-state > p:not(.eyebrow) {
  margin: 12px 0 26px;
  color: var(--muted);
}

.button {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  font-weight: 700;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button:active,
.saved-toggle:active {
  transform: translateY(0);
  opacity: 0.78;
}

.button-dark {
  color: var(--white);
  background: var(--ink);
}

.site-footer {
  min-height: 250px;
  padding: 52px max(36px, calc((100vw - 1320px) / 2));
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: end;
  gap: 28px;
  color: var(--paper-light);
  background: var(--ink);
}

.footer-mark {
  font-family: var(--serif);
  font-size: 72px;
  line-height: 0.8;
}

.site-footer p {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.15;
}

.site-footer .footer-small {
  justify-self: end;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.6;
  text-align: right;
  text-transform: uppercase;
}

.story-dialog {
  width: min(1180px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper-light);
  box-shadow: var(--shadow);
}

.story-dialog::backdrop {
  background: rgba(20, 33, 29, 0.72);
  backdrop-filter: blur(4px);
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(430px, 1.35fr);
  min-height: min(800px, calc(100vh - 48px));
}

.dialog-visual {
  position: sticky;
  top: 0;
  height: min(800px, calc(100vh - 48px));
  overflow: hidden;
  background: var(--sage);
}

.dialog-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.75);
}

.dialog-visual::after {
  content: "Photo illustration";
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 5px 8px;
  color: var(--white);
  background: rgba(20, 33, 29, 0.85);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dialog-content {
  position: relative;
  padding: 78px clamp(42px, 5vw, 82px) 84px;
}

.dialog-actions {
  position: absolute;
  top: 20px;
  right: 22px;
  left: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-detail,
.save-story {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.close-detail {
  padding: 0 8px;
}

.close-detail span:first-child {
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.save-story {
  padding: 0 13px;
  border: 1px solid var(--ink);
  transition: color 180ms ease, background 180ms ease;
}

.save-story[aria-pressed="true"] {
  color: var(--white);
  background: var(--ink);
}

.save-story:active {
  opacity: 0.72;
}

.save-label-short {
  display: none;
}

.article-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 25px;
  color: var(--red-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.article-kicker span + span::before {
  content: "";
  width: 18px;
  height: 1px;
  display: inline-block;
  margin-right: 12px;
  vertical-align: middle;
  background: var(--line);
}

.dialog-content h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(46px, 5vw, 72px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.article-dek {
  margin: 24px 0 22px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.35;
}

.article-byline {
  margin: 0 0 44px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.article-body {
  font-family: Georgia, serif;
  font-size: 19px;
  line-height: 1.72;
}

.article-body p {
  margin: 0 0 1.45em;
}

.article-body p:first-child::first-letter {
  float: left;
  margin: 0.08em 0.09em 0 0;
  color: var(--red-dark);
  font-family: var(--serif);
  font-size: 4.2em;
  line-height: 0.73;
}

.article-end {
  width: 42px;
  height: 14px;
  margin-top: 46px;
  background: var(--red);
}

body:has(dialog[open]) {
  overflow: hidden;
}

@media (max-width: 1020px) {
  :root {
    --content: min(100% - 44px, 920px);
  }

  .cover {
    grid-template-columns: 1fr 6fr;
  }

  .cover-aside {
    display: none;
  }

  .story-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .story-card:first-child {
    grid-column: span 2;
  }

  .dialog-content {
    padding-right: 46px;
    padding-left: 46px;
  }
}

@media (max-width: 760px) {
  :root {
    --content: calc(100% - 32px);
  }

  .header-inner {
    min-height: 68px;
    grid-template-columns: 1fr auto;
  }

  .header-note {
    display: none;
  }

  .header-link {
    font-size: 12px;
  }

  .cover {
    padding: 34px 0 42px;
    display: block;
  }

  .cover-meta {
    margin-bottom: 46px;
    flex-direction: row;
    justify-content: space-between;
  }

  .cover h1 {
    font-size: clamp(50px, 15vw, 72px);
    line-height: 0.94;
  }

  .browser {
    padding: 48px 0 72px;
  }

  .section-heading {
    display: block;
    margin-bottom: 24px;
  }

  .section-heading h2 {
    font-size: 43px;
  }

  .result-count {
    margin-top: 18px;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .saved-toggle {
    align-self: end;
  }

  .story-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px 16px;
  }

  .story-card:first-child {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .site-footer {
    padding: 44px 24px;
    grid-template-columns: 1fr 1fr;
  }

  .site-footer p:not(.footer-small) {
    display: none;
  }

  .story-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

  .dialog-layout {
    display: block;
    min-height: 0;
  }

  .dialog-visual {
    position: relative;
    height: 38vh;
    min-height: 250px;
  }

  .dialog-content {
    padding: 72px 32px 60px;
  }

  .dialog-actions {
    top: 14px;
    right: 17px;
    left: 17px;
  }
}

@media (max-width: 520px) {
  .wordmark {
    font-size: 13px;
  }

  .wordmark-mark {
    width: 19px;
    height: 19px;
    border-width: 5px;
  }

  .header-link {
    max-width: 74px;
    text-align: right;
  }

  .cover h1 br {
    display: none;
  }

  .cover .eyebrow {
    max-width: 220px;
  }

  .filter-bar {
    display: block;
  }

  .filter-bar > * + * {
    margin-top: 12px;
  }

  .saved-toggle {
    width: 100%;
  }

  .story-grid {
    display: block;
  }

  .story-card {
    margin-bottom: 34px;
    display: grid;
    grid-template-columns: 42% 1fr;
    column-gap: 15px;
  }

  .story-card:first-child {
    display: block;
  }

  .story-card:not(:first-child) .card-image-wrap {
    aspect-ratio: auto;
    min-height: 180px;
  }

  .story-card:not(:first-child) .illustration-label {
    display: none;
  }

  .story-card:not(:first-child) .card-copy {
    padding-top: 12px;
  }

  .story-card h3 {
    font-size: 24px;
  }

  .story-card:first-child h3 {
    font-size: 38px;
  }

  .story-card:not(:first-child) .card-summary {
    display: none;
  }

  .story-card:not(:first-child) .card-time {
    display: none;
  }

  .card-byline {
    padding-top: 9px;
  }

  .empty-state h3 {
    font-size: 38px;
  }

  .site-footer {
    min-height: 210px;
  }

  .footer-mark {
    font-size: 58px;
  }

  .dialog-visual {
    height: 29vh;
    min-height: 200px;
  }

  .dialog-content {
    padding: 70px 24px 54px;
  }

  .dialog-content h2 {
    font-size: 43px;
  }

  .article-dek {
    font-size: 20px;
  }

  .article-byline {
    display: block;
  }

  .article-byline span {
    display: block;
  }

  .article-byline span + span {
    margin-top: 5px;
  }

  .article-body {
    font-size: 18px;
  }

  .save-story .save-label-long {
    display: none;
  }

  .save-story .save-label-short {
    display: inline;
  }
}

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

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