/* Side Street — city journal
   Palette: warm paper, ink, single terracotta accent.
   Type: Literata (serif) for editorial text, Space Grotesk (sans) for UI. */

@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 1 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/space-grotesk.ttf') format('truetype');
  font-weight: 1 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 1 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f7f4ec;
  --paper-2: #efe9dc;
  --ink: #1c1b19;
  --ink-soft: #4a463f;
  --ink-faint: #8a8276;
  --rule: #d8d0bf;
  --accent: #b0431f;
  --accent-deep: #8a3517;
  --accent-soft: #efe0d6;
  --shadow: 0 1px 0 rgba(28, 27, 25, 0.08);

  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --sans: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --maxw: 1180px;
  --gutter: clamp(1rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

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

button { font: inherit; color: inherit; cursor: pointer; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6em 1em;
  z-index: 1000;
  font-family: var(--sans);
  text-decoration: none;
}
.skip-link:focus { left: 0.75rem; top: 0.75rem; }

/* ---------- Masthead ---------- */
.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem var(--gutter) 0;
}
.masthead__rule {
  height: 0;
  border: 0;
  border-top: 1px solid var(--ink);
  margin: 0;
}
.masthead__rule--top { border-top-width: 3px; }
.masthead__rule--mid { border-top: 1px solid var(--rule); margin: 0; }

.masthead__bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0.1rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.masthead__weather { display: none; }
.masthead__loc { text-align: right; }
.masthead__date { font-weight: 600; color: var(--ink); }

.wordmark {
  text-align: center;
  margin: 0.35rem 0 0.45rem;
  position: relative;
}
.wordmark__main {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 5.4rem);
  letter-spacing: -0.02em;
  line-height: 0.95;
  color: var(--ink);
  display: block;
  font-style: italic;
}
.wordmark__sub {
  display: block;
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.65rem;
}

.sections {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.4rem;
  padding: 0.85rem 0.1rem 1.1rem;
}
.section-link {
  background: none;
  border: 0;
  padding: 0.3rem 0;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  position: relative;
  transition: color 0.15s ease;
}
.section-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -0.15rem;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.18s ease;
}
.section-link:hover { color: var(--ink); }
.section-link[aria-pressed="true"] { color: var(--ink); }
.section-link[aria-pressed="true"]::after { transform: scaleX(1); }

/* ---------- Controls ---------- */
.browse-controls {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem 1.1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field--search { flex: 1 1 320px; min-width: 220px; }
.field--filter { flex: 0 0 auto; }
.field--saved { flex: 0 0 auto; margin-left: auto; }

.field > label {
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.field__wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.55rem 0.7rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.field__wrap:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
.field__icon {
  width: 18px; height: 18px;
  color: var(--ink-faint);
  margin-right: 0.5rem;
  flex: 0 0 auto;
}
.field__wrap input {
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink);
  width: 100%;
  padding: 0;
}
.field__wrap input::placeholder { color: var(--ink-faint); font-style: italic; }

.field__wrap--select { padding: 0; }
.field__wrap--select select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--ink);
  padding: 0.7rem 2.2rem 0.7rem 0.85rem;
  outline: none;
  width: 100%;
  cursor: pointer;
}
.field__chevron {
  position: absolute;
  right: 0.7rem;
  width: 18px; height: 18px;
  color: var(--ink);
  pointer-events: none;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.6rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.saved-toggle__icon { width: 18px; height: 18px; }
.saved-toggle__count {
  font-size: 0.68rem;
  background: var(--paper-2);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  min-width: 1.3rem;
  text-align: center;
  border: 1px solid var(--rule);
}
.saved-toggle:hover { background: var(--paper-2); }
.saved-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__icon path {
  fill: rgba(255,255,255,0.25);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__count {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

.result-meta {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0.75rem 0.1rem 0;
  min-height: 1.2em;
}

/* ---------- Story grid ---------- */
.story-grid {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 3rem;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-flow: dense;
  gap: 1.75rem 1.5rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--rule);
  border-bottom: 3px solid var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px -18px rgba(28, 27, 25, 0.4);
  border-color: var(--ink);
}
.card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Featured spans wide; others get varied column spans for an editorial layout. */
.card--feature { grid-column: span 12; flex-direction: row; }
.card--wide { grid-column: span 8; }
.card--tall { grid-column: span 4; }
.card--half { grid-column: span 6; }
.card--third { grid-column: span 4; }
.card--quarter { grid-column: span 3; }

.card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--paper-2);
}
.card--feature .card__media { aspect-ratio: 5 / 4; flex: 1 1 55%; }
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  filter: saturate(0.92) contrast(1.02);
}
.card:hover .card__media img { transform: scale(1.04); }

.card__body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.55rem; }
.card--feature .card__body { flex: 1 1 45%; justify-content: center; padding: 1.8rem 2rem 2rem; }

.card__cat {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.card__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  font-size: 1.35rem;
  color: var(--ink);
}
.card--feature .card__title { font-size: clamp(1.9rem, 3.4vw, 2.85rem); font-style: italic; }
.card--half .card__title { font-size: 1.5rem; }
.card__summary {
  margin: 0;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.card--feature .card__summary { font-size: 1.12rem; max-width: 46ch; }
.card__meta {
  margin: auto 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
}
.card__meta b { color: var(--ink-soft); font-weight: 600; }

/* Stretched open control covering the card (keyboard accessible). */
.card__open {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 0;
  color: transparent;
  z-index: 2;
}
.card__open:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}
.card__open::after {
  content: "Read story →";
  position: absolute;
  left: 1.2rem;
  bottom: 1.2rem;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.card:hover .card__open::after { opacity: 1; transform: translateY(0); }

.card__savedflag {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 3;
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  pointer-events: none;
}

/* ---------- Empty state ---------- */
.empty-state {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 4rem;
  text-align: center;
}
.empty-state__title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0 0 0.4rem;
}
.empty-state__text { color: var(--ink-soft); margin: 0 0 1.2rem; }
.empty-state__reset {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 2px;
  padding: 0.7rem 1.3rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.empty-state__reset:hover { background: var(--accent); }

/* ---------- Colophon ---------- */
.colophon {
  border-top: 3px solid var(--ink);
  margin-top: 2rem;
  background: var(--paper-2);
}
.colophon__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.colophon__brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0;
}
.colophon__note, .colophon__set {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  max-width: 52ch;
}
.colophon__set { color: var(--ink-faint); }

/* ---------- Detail dialog ---------- */
.detail {
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(96vw, 880px);
  width: 100%;
  max-height: 92vh;
  overflow: hidden;
  border-radius: 4px;
}
.detail::backdrop {
  background: rgba(20, 19, 17, 0.62);
  backdrop-filter: blur(2px);
}
.detail[open] { animation: detail-in 0.22s ease; }
@keyframes detail-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .detail[open] { animation: none; }
  .card, .card__media img, .section-link, .saved-toggle { transition: none; }
}

.detail__article {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail__media {
  position: relative;
  aspect-ratio: 16 / 8;
  overflow: hidden;
  background: var(--paper-2);
  flex: 0 0 auto;
}
.detail__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.02);
}
.detail__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(247, 244, 236, 0.94);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.85rem 0.45rem 0.6rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  z-index: 3;
  transition: background 0.15s ease, color 0.15s ease;
}
.detail__close svg { width: 16px; height: 16px; }
.detail__close:hover { background: var(--ink); color: var(--paper); }

.detail__body { padding: 1.8rem clamp(1.2rem, 4vw, 2.6rem) 2.2rem; }
.detail__cat {
  margin: 0 0 0.6rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.detail__title {
  margin: 0 0 0.7rem;
  font-family: var(--serif);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(1.7rem, 4.4vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.detail__byline b { color: var(--ink); font-weight: 600; }
.detail__rule { border: 0; border-top: 1px solid var(--rule); margin: 1.1rem 0 1.3rem; }

.detail__content { font-family: var(--serif); font-size: 1.14rem; line-height: 1.72; }
.detail__content p { margin: 0 0 1.1rem; }
.detail__content p:first-letter {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 3.4em;
  line-height: 0.8;
  float: left;
  padding: 0.05em 0.12em 0 0;
  color: var(--accent);
}
.detail__content p:first-child:first-letter { } /* keep */

.detail__actions {
  margin-top: 1.8rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
}
.save-item {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.65rem 1.1rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.save-item__icon { width: 20px; height: 20px; transition: fill 0.15s ease; }
.save-item:hover { background: var(--paper-2); }
.save-item[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.save-item[aria-pressed="true"] .save-item__icon path { fill: rgba(255,255,255,0.3); }
.detail__tag {
  margin: 0.8rem 0 0;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--accent-deep);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .card--feature { grid-column: span 12; flex-direction: column; }
  .card--feature .card__media { aspect-ratio: 16 / 9; flex: none; }
  .card--wide, .card--half { grid-column: span 6; }
  .card--tall, .card--third { grid-column: span 6; }
  .card--quarter { grid-column: span 6; }
  .masthead__weather { display: block; flex: 1 1 100%; text-align: center; order: 3; padding-top: 0.3rem; }
  .masthead__bar { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .story-grid { gap: 1.25rem; padding: 1.2rem var(--gutter) 2.5rem; }
  .card--wide, .card--half, .card--tall, .card--third, .card--quarter { grid-column: span 12; }
  .controls { flex-wrap: wrap; }
  .field--saved { margin-left: 0; width: 100%; }
  .saved-toggle { width: 100%; justify-content: center; }
  .masthead__loc { display: none; }
  .masthead__bar { justify-content: center; text-align: center; }
  .wordmark__main { font-size: clamp(2.4rem, 14vw, 3.6rem); }
  .sections { gap: 0.2rem 0.9rem; }
  .section-link { font-size: 0.68rem; letter-spacing: 0.14em; }
  .detail { max-height: 100vh; border-radius: 0; max-width: 100vw; }
  .detail__article { max-height: 100vh; border-radius: 0; border: 0; }
  .detail__media { aspect-ratio: 4 / 3; }
  .detail__content { font-size: 1.06rem; }
  .detail__content p:first-letter { font-size: 2.9em; }
}

@media (hover: none) {
  .card:hover { transform: none; }
  .card__open::after { opacity: 1; transform: none; }
  .card:hover .card__media img { transform: none; }
}
