/* ————— Side Street — city journal ————— */

@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: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 400;
  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;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f7f3ea;
  --card: #fdfbf5;
  --ink: #221f1b;
  --muted: #69604f;
  --line: #ddd4c2;
  --line-strong: #b8ac94;
  --accent: #a8481d;
  --accent-deep: #7e3412;
  --accent-soft: #f3e2d6;
  --focus-ring: #1d4f8a;
  --shadow-card: 0 1px 2px rgba(60, 48, 30, 0.08);
  --shadow-hover: 0 10px 24px rgba(60, 48, 30, 0.14);
  --font-ui: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-body: "Literata", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html {
  -webkit-tap-highlight-color: transparent;
}

html.modal-open {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

/* ————— shared bits ————— */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 600;
  text-decoration: underline;
}
.skip-link:focus-visible {
  top: 1rem;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  touch-action: manipulation;
}

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

.icon {
  display: inline-block;
  vertical-align: -0.18em;
  fill: currentColor;
}

/* ————— masthead ————— */

.masthead {
  padding: 1.75rem 0 0;
}

.masthead-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.25rem;
  text-align: center;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1.6rem;
  padding: 0.45rem 0.9rem;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.masthead-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 8vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.masthead-tagline {
  margin: 0.65rem auto 1.4rem;
  max-width: 44ch;
  font-size: 0.95rem;
  color: var(--muted);
  text-wrap: pretty;
}

.rule-double {
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  height: 6px;
}

/* ————— toolbar ————— */

.toolbar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.toolbar {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.9rem 1.4rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.field label,
.field-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-search {
  flex: 1 1 220px;
}

.field-filter select {
  min-width: 128px;
}

#search {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink);
}

#search::placeholder {
  color: #8a8071;
}

#filter {
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink);
}

.btn-saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn-saved-toggle:hover {
  border-color: var(--accent);
  background: #fbf6ec;
}

.btn-saved-toggle .count {
  min-width: 1.4em;
  padding: 0.05em 0.35em;
  border-radius: 999px;
  background: var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-saved-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.btn-saved-toggle[aria-pressed="true"] .count {
  background: var(--accent);
  color: #fff;
}

/* ————— story grid ————— */

.main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.6rem 1.25rem 3.5rem;
}

.results-status {
  margin: 0 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  scroll-margin-top: 5.5rem;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-strong);
}

.card-figure {
  margin: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.card-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.55rem;
  padding: 1rem 1.1rem 1.15rem;
  min-width: 0;
}

.card-kicker {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.42rem;
  line-height: 1.16;
  text-wrap: balance;
}

.card-title button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 130ms ease;
}

.card-title button:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.card-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.card-meta {
  margin: auto 0 0;
  padding-top: 0.55rem;
  border-top: 1px dotted var(--line-strong);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.card-read {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.card-read:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card-saved-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent-deep);
  font-weight: 600;
}

/* featured card */

.card--featured {
  grid-column: 1 / -1;
  flex-direction: row;
}

.card--featured .card-figure {
  flex: 0 0 46%;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}

.card--featured .card-figure img {
  height: 100%;
  aspect-ratio: auto;
}

.card--featured .card-title {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
}

.card--featured .card-summary {
  font-size: 1.02rem;
}

/* ————— empty state ————— */

.empty-state {
  max-width: 30rem;
  margin: 3.5rem auto 0;
  padding: 2rem 1.5rem 2.4rem;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  background: var(--card);
}

.empty-state .icon-empty {
  color: var(--line-strong);
}

.empty-state h3 {
  margin: 0.8rem 0 0.4rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  text-wrap: balance;
}

.empty-state p {
  margin: 0 0 1.3rem;
  color: var(--muted);
  text-wrap: pretty;
}

.btn-primary {
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--accent-deep);
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.btn-primary:hover {
  background: var(--accent-deep);
}

/* ————— footer ————— */

.site-footer {
  border-top: 3px solid var(--ink);
  background: #efe9dc;
}

.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 2rem;
  text-align: center;
}

.footer-brand {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.site-footer p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-wrap: pretty;
}

/* ————— detail dialog ————— */

.story-dialog {
  width: min(46rem, calc(100vw - 1.5rem));
  max-height: min(88dvh, 1000px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(40, 30, 15, 0.35);
  overscroll-behavior: contain;
}

.story-dialog::backdrop {
  background: rgba(34, 31, 27, 0.55);
  backdrop-filter: blur(2px);
}

.story-sheet {
  display: flex;
  flex-direction: column;
  max-height: min(88dvh, 1000px);
  overflow-y: auto;
  padding: 0 2rem 1.5rem;
  scroll-padding-top: 4rem;
  scroll-padding-bottom: 4.5rem;
}

.story-sheet-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0 -2rem;
  padding: 0.65rem 2rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.story-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.btn-close {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.btn-close:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.story-title {
  margin: 1.4rem 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.7rem, 4.5vw, 2.5rem);
  line-height: 1.12;
  text-wrap: balance;
}

.story-byline {
  margin: 0 0 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.story-figure {
  margin: 0 0 1.4rem;
}

.story-figure img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.story-figure figcaption {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--muted);
}

.story-body {
  font-family: var(--font-body);
  font-size: 1.06rem;
  line-height: 1.75;
}

.story-body p {
  margin: 0 0 1.1em;
  text-wrap: pretty;
}

.story-body p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.2em;
  line-height: 0.85;
  float: left;
  padding: 0.08em 0.12em 0 0;
  color: var(--accent-deep);
}

.story-footer {
  position: sticky;
  bottom: 0;
  margin: 0.5rem -2rem 0;
  padding: 0.75rem 2rem 0.9rem;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.btn-save {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.btn-save:hover {
  background: #edd5c4;
}

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

.btn-save[aria-pressed="true"]:hover {
  background: #3d3833;
}

.btn-save .icon-bookmark {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

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

/* ————— responsive ————— */

@media (max-width: 700px) {
  .masthead-top {
    font-size: 0.58rem;
    gap: 0.4rem;
  }
  .masthead-top span:nth-child(2) {
    display: none;
  }
  .toolbar {
    gap: 0.7rem;
  }
  .card--featured {
    flex-direction: column;
  }
  .card--featured .card-figure {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .card--featured .card-figure img {
    aspect-ratio: 3 / 2;
    height: auto;
  }
  .story-sheet {
    padding: 0 1.1rem 1.1rem;
  }
  .story-sheet-top {
    margin: 0 -1.1rem;
    padding: 0.6rem 1.1rem;
  }
  .story-footer {
    margin: 0.5rem -1.1rem 0;
    padding: 0.7rem 1.1rem 0.8rem;
  }
  .story-dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
  }
  .story-body p:first-of-type::first-letter {
    font-size: 2.8em;
  }
}

/* ————— reduced motion ————— */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .card:hover {
    transform: none;
  }
}
