/* Kerbside — a journal of the everyday city */

@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --paper: #e7e8e1;
  --sheet: #f4f4ee;
  --ink: #15211d;
  --ink-soft: #46534e;
  --rule: #b7bbb0;
  --kerb: #efc31d;

  --cat-culture: #5b3a70;
  --cat-food: #8a4418;
  --cat-movement: #1e5a78;
  --cat-people: #8e2b3d;
  --cat-places: #35583c;

  --serif: 'Literata', 'Iowan Old Style', Georgia, serif;
  --sans: 'Work Sans', 'Helvetica Neue', Arial, sans-serif;

  --gutter: clamp(20px, 4vw, 56px);
  --rule-hair: 1px solid var(--rule);
}

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

html {
  background: var(--paper);
  scroll-behavior: smooth;
  scroll-padding-top: 110px;
}

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

img {
  display: block;
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

html.no-scroll,
html.no-scroll body {
  overflow: hidden;
}

.shell {
  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-size: 14px;
}

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

/* ---------- Masthead ---------- */

.masthead {
  padding-top: clamp(26px, 4.5vw, 52px);
}

.masthead-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

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

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 800;
  font-size: clamp(3.1rem, 12.2vw, 8.6rem);
  line-height: 0.8;
  letter-spacing: -0.045em;
  color: var(--ink);
}

.tagline {
  margin: 20px 0 0;
  max-width: 26ch;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.issue-meta {
  border-left: var(--rule-hair);
  padding-left: 22px;
  margin-bottom: 6px;
  text-align: right;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.issue-meta p {
  margin: 0;
}

.issue-number {
  color: var(--ink);
  font-weight: 600;
}

.skyline-wrap {
  margin-top: clamp(22px, 3vw, 36px);
  border-bottom: 3px solid var(--kerb);
}

.skyline {
  display: block;
  width: 100%;
  height: clamp(64px, 8.333vw, 120px);
  color: var(--ink);
}

/* ---------- Filter toolbar ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--paper);
  border-bottom: var(--rule-hair);
}

.toolbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px auto;
  align-items: end;
  gap: clamp(16px, 2.4vw, 30px);
  padding-block: 14px 15px;
}

.field {
  min-width: 0;
}

.field label,
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-soft);
}

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

#search,
#filter {
  width: 100%;
  height: 44px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-size: 15px;
}

#search {
  padding: 0 14px 0 39px;
}

#search::placeholder {
  color: #5d6a64;
  opacity: 1;
}

#search::-webkit-search-cancel-button {
  cursor: pointer;
}

#filter {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 38px 0 13px;
  cursor: pointer;
}

.select-wrap {
  position: relative;
}

.select-arrow {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

#search:hover,
#filter:hover {
  background: rgba(21, 33, 29, 0.035);
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.saved-toggle svg {
  flex: none;
}

.saved-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.saved-toggle:hover {
  background: rgba(21, 33, 29, 0.06);
}

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

.saved-toggle[aria-pressed='true'] svg {
  fill: var(--kerb);
  stroke: var(--kerb);
}

.saved-toggle[aria-pressed='true']:hover {
  background: #24332e;
}

.saved-toggle[aria-pressed='true']:focus-visible {
  outline-color: var(--ink);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--kerb);
}

/* ---------- Story list ---------- */

.main {
  padding-top: clamp(28px, 4vw, 48px);
  padding-bottom: 24px;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--ink);
}

.list-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.2rem, 1.8vw, 1.45rem);
  letter-spacing: -0.01em;
}

.list-count {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(24px, 4.2vw, 60px);
}

.story {
  position: relative;
  scroll-margin-top: 110px;
  min-width: 0;
  padding-block: clamp(28px, 3.4vw, 42px);
  border-bottom: var(--rule-hair);
}

.story--lead,
.story--wide {
  grid-column: 1 / -1;
}

.story-media {
  margin: 0 0 20px;
  overflow: hidden;
  background: #d6d8cf;
}

.story-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.16) contrast(1.03);
}

.story-media--standard {
  aspect-ratio: 3 / 2;
}

.story-media--lead {
  aspect-ratio: 5 / 4;
}

.story--lead {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: clamp(26px, 4vw, 60px);
  align-items: end;
  padding-top: clamp(20px, 2.4vw, 30px);
  padding-bottom: clamp(38px, 5vw, 64px);
}

.story--wide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.52fr);
  gap: clamp(26px, 4vw, 60px);
  align-items: center;
}

.story--wide .story-media {
  margin: 0;
  aspect-ratio: 4 / 3;
}

.story--lead .story-media {
  margin: 0;
  aspect-ratio: 4 / 3;
}

.story-body {
  min-width: 0;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-soft);
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: none;
  background: var(--cat, var(--ink-soft));
}

.story-title {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 700;
  font-size: clamp(1.42rem, 2.1vw, 1.85rem);
  line-height: 1.1;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

.story--lead .story-title {
  font-size: clamp(2.35rem, 4.6vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: -0.028em;
}

.story--wide .story-title {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.02;
}

.story-open {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  letter-spacing: inherit;
}

.story-open::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.story:hover .story-open {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.story-open:focus-visible {
  outline-offset: 4px;
}

.story-summary {
  margin: 14px 0 0;
  max-width: 46ch;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.story--lead .story-summary {
  margin-top: 20px;
  max-width: 44ch;
  font-size: 17px;
  line-height: 1.55;
}

.story--wide .story-summary {
  max-width: 44ch;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 18px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.story-meta span + span {
  position: relative;
}

.story-saved {
  color: var(--ink);
  font-weight: 600;
}

.story-meta span + span::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  width: 1px;
  height: 11px;
  background: var(--rule);
  transform: translateY(-50%);
}

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

.empty-state {
  margin: clamp(36px, 5vw, 64px) 0;
  padding: clamp(32px, 5vw, 64px) clamp(24px, 5vw, 56px);
  border: var(--rule-hair);
  background: var(--sheet);
  max-width: 720px;
}

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

.empty-state h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.empty-state p {
  margin: 12px 0 24px;
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
}

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

.button--ink:hover {
  background: #293833;
}

/* ---------- Footer ---------- */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  align-items: flex-start;
  margin-top: clamp(40px, 5vw, 64px);
  padding-top: 26px;
  padding-bottom: 48px;
  border-top: 1px solid var(--ink);
}

.footer-note {
  margin: 0;
  max-width: 62ch;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.footer-meta {
  margin: 0;
  flex: none;
  text-align: right;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Detail dialog ---------- */

.detail {
  width: min(740px, 100%);
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--ink);
  background: var(--sheet);
  color: var(--ink);
  overflow: hidden;
}

.detail[open] {
  display: flex;
  flex-direction: column;
  animation: detail-in 300ms cubic-bezier(0.22, 0.8, 0.3, 1);
}

.detail::backdrop {
  background: rgba(21, 33, 29, 0.45);
  animation: backdrop-in 240ms ease-out;
}

@keyframes detail-in {
  from {
    transform: translateX(30px);
    opacity: 0.4;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.detail-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(18px, 4vw, 38px);
  border-bottom: var(--rule-hair);
  background: var(--sheet);
}

.detail-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(21, 33, 29, 0.06);
}

.btn-save[aria-pressed='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn-save[aria-pressed='true'] svg {
  fill: var(--kerb);
  stroke: var(--kerb);
}

.btn-save[aria-pressed='true']:hover {
  background: #293833;
}

.btn-save[aria-pressed='true']:focus-visible {
  box-shadow: 0 0 0 4px var(--kerb);
}

.btn-close {
  border-color: var(--rule);
  padding-inline: 10px;
}

.detail-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(26px, 4.5vw, 48px) clamp(20px, 5vw, 56px) 72px;
}

.detail-article {
  max-width: 61ch;
  margin-inline: auto;
}

.detail-title {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 700;
  font-size: clamp(2rem, 4.2vw, 3.15rem);
  line-height: 1.02;
  letter-spacing: -0.024em;
  text-wrap: balance;
}

.detail-standfirst {
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 28px;
  padding: 13px 0;
  border-top: var(--rule-hair);
  border-bottom: var(--rule-hair);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.detail-meta span + span {
  position: relative;
}

.detail-meta span + span::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  width: 1px;
  height: 11px;
  background: var(--rule);
  transform: translateY(-50%);
}

.detail-figure {
  margin: 0 0 30px;
}

.detail-figure img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  filter: grayscale(0.16) contrast(1.03);
}

.detail-figure figcaption {
  margin-top: 9px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.detail-body {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.175rem;
  line-height: 1.72;
}

.detail-body p {
  margin: 0 0 1.15em;
}

.detail-body p:first-child::first-letter {
  float: left;
  font-size: 3.55em;
  font-weight: 600;
  line-height: 0.8;
  padding-right: 0.09em;
  margin-top: 0.06em;
}

.detail-body p:last-child {
  margin-bottom: 0;
}

.detail-end {
  margin-top: 40px;
  padding-top: 22px;
  border-top: var(--rule-hair);
}

.detail-end span {
  display: block;
  width: 46px;
  height: 3px;
  background: var(--kerb);
}

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

@media (max-width: 860px) {
  .toolbar-inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px 14px;
  }

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

  .field--saved {
    min-width: 0;
  }

  .saved-toggle {
    width: 100%;
    justify-content: center;
  }

  .story--lead {
    grid-template-columns: 1fr;
    gap: 26px;
    align-items: start;
  }

  .story--lead .story-media {
    aspect-ratio: 3 / 2;
  }

  .story--wide {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .story--wide .story-media {
    aspect-ratio: 3 / 2;
    order: 2;
  }

  .story--wide .story-body {
    order: 1;
  }
}

@media (max-width: 700px) {
  .toolbar {
    position: static;
  }
}

@media (max-width: 620px) {
  .masthead-top {
    gap: 14px;
    flex-wrap: nowrap;
  }

  .tagline {
    margin-top: 16px;
    font-size: 14px;
    max-width: 22ch;
  }

  .issue-meta {
    padding-left: 16px;
    font-size: 12px;
  }

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

  .story {
    padding-block: 28px;
  }

  .story--lead .story-title {
    font-size: clamp(2.1rem, 9.2vw, 2.9rem);
  }

  .story-summary {
    font-size: 14.5px;
  }

  .footer {
    flex-direction: column;
    gap: 20px;
  }

  .footer-meta {
    text-align: left;
  }

  .detail {
    border-left: 0;
    border-top: 1px solid var(--ink);
  }

  .detail-bar {
    padding: 10px 16px;
  }

  .detail-kicker span:last-child {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .detail-scroll {
    padding: 26px 20px 56px;
  }

  .detail-body {
    font-size: 1.1rem;
    line-height: 1.7;
  }

  .btn-close span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .btn-close {
    padding-inline: 9px;
  }
}

@media (max-width: 380px) {
  .masthead-top {
    flex-wrap: wrap;
  }

  .issue-number {
    display: none;
  }
}

@media (max-width: 390px) {
  .saved-toggle {
    font-size: 13px;
    gap: 7px;
    padding-inline: 10px;
  }

  .detail-actions {
    gap: 6px;
  }
}

@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;
  }
}
