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

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

:root {
  --paper: #e9ebf1;
  --paper-raised: #f4f4ee;
  --ink: #171a23;
  --ink-soft: #555c6d;
  --rule: #c5cad6;
  --grape: #36214c;
  --grape-deep: #291839;
  --grape-line: #6d5a84;
  --cream: #f3efe5;
  --cream-soft: #d5cddf;
  --focus-dark: #d8c3f5;
  --focus-light: #3b2550;
  --accent: #a83b26;
  --serif: "DM Serif Display", Georgia, "Times New Roman", serif;
  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

svg {
  display: block;
}

.skip-link {
  position: absolute;
  top: -80px;
  left: 16px;
  z-index: 20;
  background: var(--cream);
  color: var(--grape);
  padding: 12px 18px;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

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

.rail :focus-visible,
.detail__bar :focus-visible {
  outline-color: var(--focus-dark);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.motif-store {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------- Page frame ---------- */

.site {
  display: grid;
  grid-template-columns: minmax(300px, 356px) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding: 42px 34px 30px;
  background: var(--grape);
  color: var(--cream);
}

.brand {
  font-family: var(--serif);
  font-size: clamp(64px, 6.6vw, 92px);
  line-height: 0.8;
  letter-spacing: -0.02em;
  margin-bottom: 26px;
}

.brand a {
  display: inline-block;
  text-decoration: none;
}

.brand span {
  display: block;
}

.brand a:hover span {
  color: #fff;
}

.tagline {
  font-size: 18px;
  line-height: 1.3;
  max-width: 15ch;
  color: var(--cream);
}

.issue {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--cream-soft);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 26px;
  border-top: 1px solid var(--grape-line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--cream-soft);
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  background: var(--grape-deep);
  border: 1.5px solid var(--grape-line);
  border-radius: 7px;
  color: #fff;
  font-size: 15px;
}

.field input::placeholder {
  color: #b9accb;
}

.field input:hover,
.field select:hover {
  border-color: #9a89b1;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23d5cddf' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.field select option {
  background: var(--grape-deep);
  color: #fff;
}

.saved-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1.5px solid var(--grape-line);
  border-radius: 7px;
  background: transparent;
  color: var(--cream);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.saved-toggle:hover {
  border-color: #b4a3c9;
  background: rgba(255, 255, 255, 0.05);
}

.saved-toggle__icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.saved-toggle__count {
  margin-left: auto;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border: 1px solid var(--grape-line);
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.saved-toggle[aria-pressed="true"] .saved-toggle__icon svg {
  fill: currentColor;
}

.saved-toggle[aria-pressed="true"] .saved-toggle__count {
  border-color: #b9aec9;
  background: #e4def0;
}

.rail__note {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--grape-line);
  color: #c6bcd4;
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 30ch;
}

/* ---------- Browsing column ---------- */

.main {
  padding: 54px clamp(28px, 4.6vw, 72px) 70px;
  min-width: 0;
}

.list-head {
  max-width: 780px;
}

.list-head__date {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 16px;
}

.list-head h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 4.1vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.01em;
  max-width: 16ch;
}

.list-head__intro {
  margin-top: 20px;
  max-width: 56ch;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.count {
  margin-top: 22px;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.stories {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  border-top: 2px solid var(--ink);
}

.story {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 132px;
  gap: 22px 28px;
  padding: 30px 0;
  border-bottom: 1px solid var(--rule);
}

.story__date {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 2px;
  color: var(--ink-soft);
}

.story__day {
  font-family: var(--serif);
  font-size: 38px;
  line-height: 0.95;
  color: var(--ink);
}

.story__month {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.story__weekday {
  font-size: 12.5px;
  color: var(--ink-soft);
}

.story__body {
  min-width: 0;
}

.story__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--ink-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--ink);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--mark);
}

.story h2 {
  margin: 10px 0 7px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 2.35vw, 33px);
  line-height: 1.08;
  letter-spacing: -0.005em;
}

.story__link {
  text-decoration: none;
  text-underline-offset: 5px;
  text-decoration-thickness: 2px;
}

.story__link:hover {
  text-decoration: underline;
  text-decoration-color: var(--mark);
}

.story__link:focus-visible {
  outline-offset: 5px;
}

.story__summary {
  margin-top: 2px;
  max-width: 56ch;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.story__saved {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
}

.story__saved svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
}

.plate {
  --tint: #dfe2e9;
  width: 132px;
  height: 132px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--tint);
  color: var(--ink);
}

.plate svg {
  width: 86px;
  height: 86px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cat-culture { --tint: #e9c9bb; --mark: #b0472b; }
.cat-food { --tint: #eadcb4; --mark: #8c6100; }
.cat-movement { --tint: #c4dfd8; --mark: #1e6b60; }
.cat-people { --tint: #edcfd8; --mark: #a03a61; }
.cat-places { --tint: #ccd7ec; --mark: #33538c; }

/* ---------- Empty state ---------- */

.empty {
  margin-top: 24px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 52px 0 56px;
  max-width: 560px;
}

.empty__mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #ccd7ec;
  color: var(--ink);
  margin-bottom: 24px;
}

.empty__mark svg {
  width: 50px;
  height: 50px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.1;
}

.empty p {
  margin-top: 12px;
  color: var(--ink-soft);
  max-width: 44ch;
}

.empty__reset {
  margin-top: 24px;
  padding: 11px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
}

.empty__reset:hover {
  background: var(--ink);
  color: var(--paper);
}

.main-foot {
  margin-top: 54px;
  max-width: 56ch;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* ---------- Article view ---------- */

.detail {
  grid-column: 1 / -1;
  min-height: 100vh;
  background: var(--paper);
}

.detail__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(20px, 4.6vw, 64px);
  background: var(--grape);
  color: var(--cream);
  border-bottom: 1px solid var(--grape-deep);
}

.detail__brand {
  margin-right: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1;
}

.detail__brand:hover {
  color: #fff;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 4px;
  border: 0;
  background: transparent;
  color: var(--cream);
  font-size: 14px;
  font-weight: 500;
}

.back svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

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

.save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1.5px solid var(--cream);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.save svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.save:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.save[aria-pressed="true"] svg {
  fill: currentColor;
}

.article {
  max-width: 860px;
  margin: 0 auto;
  padding: 58px clamp(20px, 4.6vw, 52px) 88px;
}

.article__topic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.article h1 {
  margin-top: 18px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 4.4vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.01em;
  max-width: 18ch;
}

.article h1:focus {
  outline: none;
}

.article__standfirst {
  margin-top: 22px;
  font-size: 19px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 52ch;
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 13.5px;
  color: var(--ink-soft);
}

.byline strong {
  color: var(--ink);
  font-weight: 500;
}

.article__plate {
  margin: 36px 0 40px;
  padding: 34px 20px 26px;
  border-radius: 8px;
  background: var(--tint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.article__plate svg {
  width: clamp(130px, 22vw, 184px);
  height: clamp(130px, 22vw, 184px);
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.article__plate figcaption {
  font-size: 12.5px;
  color: rgba(23, 26, 35, 0.7);
}

.article__body {
  max-width: 66ch;
  font-size: 18px;
  line-height: 1.72;
}

.article__body p + p {
  margin-top: 1.15em;
}

.article__body p:first-child::first-letter {
  float: left;
  font-family: var(--serif);
  font-size: 4.05em;
  line-height: 0.78;
  padding: 0.06em 0.1em 0 0;
  color: var(--grape);
}

.article__end {
  margin-top: 46px;
  padding-top: 26px;
  border-top: 2px solid var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 26px;
}

.article__end p {
  color: var(--ink-soft);
  font-size: 14px;
  margin-right: auto;
}

.article__end .back {
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 10px 16px;
}

.article__end .back:hover {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .back svg {
    transition: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .detail.is-entering .article {
    animation: page-rise 0.32s ease-out both;
  }

  @keyframes page-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .story {
    grid-template-columns: 66px minmax(0, 1fr) 108px;
    gap: 20px 22px;
  }

  .plate {
    width: 108px;
    height: 108px;
  }

  .plate svg {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 860px) {
  .site {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    gap: 22px;
    padding: 24px 22px 26px;
    overflow: visible;
  }

  .brand {
    font-size: 58px;
    line-height: 0.82;
    margin-bottom: 14px;
  }

  .brand span {
    display: inline;
  }

  .tagline {
    font-size: 16px;
    max-width: 32ch;
  }

  .issue {
    margin-top: 8px;
  }

  .controls {
    padding-top: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

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

  .saved-toggle {
    grid-column: 1 / -1;
  }

  .rail__note {
    display: none;
  }

  .main {
    padding: 34px 22px 56px;
  }

  .list-head h1 {
    font-size: 38px;
    max-width: 14ch;
  }

  .list-head__intro {
    font-size: 15.5px;
  }

  .story {
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 6px 16px;
    padding: 24px 0;
  }

  .story__day {
    font-size: 32px;
  }

  .story__month,
  .story__weekday {
    font-size: 12px;
  }

  .story__meta {
    grid-column: 1 / -1;
  }

  .story h2 {
    font-size: 26px;
  }

  .story__summary {
    font-size: 15px;
  }

  .plate {
    display: none;
  }

  .detail__bar {
    gap: 10px;
    padding: 12px 16px;
  }

  .detail__brand {
    font-size: 21px;
  }

  .back {
    font-size: 13px;
    padding: 8px 2px;
  }

  .save {
    padding: 8px 12px;
    font-size: 13px;
  }

  .article {
    padding: 38px 20px 64px;
  }

  .article h1 {
    font-size: 36px;
    max-width: none;
  }

  .article__standfirst {
    font-size: 17.5px;
  }

  .article__plate {
    margin: 28px 0 32px;
    padding: 26px 16px 20px;
  }

  .article__body {
    font-size: 17px;
    line-height: 1.7;
  }
}

@media (max-width: 420px) {
  .detail__brand {
    margin-right: 0;
  }

  .back span {
    display: none;
  }

  .back {
    margin-right: auto;
  }

  .save {
    padding: 8px 11px;
  }
}
