/* ============================================================
   Crosswalk — a journal of everyday city life
   Editorial, paper-warm, reading-first.
   ============================================================ */

/* ---------- Fonts (local, OFL / Unsplash-licensed assets) ---------- */
@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('assets/dm-sans.ttf') format('truetype');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@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: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper:        #F5F1E8;
  --paper-2:      #EFEAE0;
  --paper-sunk:   #ECE6D9;
  --ink:          #1C1A17;
  --ink-2:        #2A2622;
  --muted:        #5C544A;
  --muted-2:      #6F6658;
  --rule:         #D7CDBB;
  --rule-2:       #C9BEA9;
  --accent:       #A8412A;
  --accent-deep:  #8B3520;

  --c-culture:    #A8412A;
  --c-food:       #B6852A;
  --c-movement:   #3E6B7A;
  --c-people:     #7A4A6B;
  --c-places:     #4E6B3A;

  --shadow-soft: 0 1px 0 rgba(28,26,23,.04), 0 18px 40px -28px rgba(28,26,23,.45);
  --shadow-card: 0 1px 0 rgba(28,26,23,.05), 0 24px 50px -34px rgba(28,26,23,.55);

  --serif: 'Literata', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --display: 'DM Serif Display', 'Literata', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --maxw: 1240px;
  --readw: 68ch;
  --rhythm: clamp(20px, 2.4vw, 34px);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 12% -8%, rgba(168,65,42,.05), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(62,107,122,.05), transparent 55%);
  line-height: 1.55;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
a { color: inherit; }

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

.skip-link {
  position: absolute; left: 12px; top: -60px;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-family: var(--sans); font-size: 14px;
  border-radius: 4px; z-index: 100; text-decoration: none;
  transition: top .18s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- Masthead ---------- */
.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 30px) clamp(16px, 3vw, 36px) 0;
  text-align: center;
}
.masthead__strip {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.masthead__edition,
.masthead__tagline { margin: 0; }
.masthead__tagline { text-align: right; color: var(--ink-2); }

.masthead__plate { padding: clamp(22px, 4vw, 40px) 0 clamp(14px,2vw,20px); }
.wordmark {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .22em;
  color: var(--ink);
  font-size: clamp(54px, 11vw, 116px);
}
.wordmark__glyph {
  font-size: .32em;
  color: var(--accent);
  display: inline-flex;
  transform: translateY(-.06em);
}
.wordmark__text {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: .9;
}

.sections { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.sections ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0;
}
.sections li { margin: 0; }
.sections a {
  display: block;
  padding: 13px clamp(14px,2.4vw,26px);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
  position: relative;
  transition: color .16s ease;
}
.sections a::after {
  content: ""; position: absolute; left: 50%; right: 50%; bottom: -1px;
  height: 2px; background: var(--accent);
  transition: left .2s ease, right .2s ease;
}
.sections a:hover { color: var(--accent); }
.sections a:hover::after { left: 14px; right: 14px; }

/* ---------- Toolbar ---------- */
.toolbar {
  max-width: var(--maxw);
  margin: clamp(22px, 4vw, 38px) auto 0;
  padding: 0 clamp(16px, 3vw, 36px);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px 26px;
}
.search {
  flex: 1 1 320px;
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1.5px solid var(--ink);
  padding: 4px 0 8px;
}
.search__icon {
  display: inline-flex; color: var(--muted); margin-right: 12px;
}
.search__label {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
}
.search__input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: var(--serif); font-size: clamp(17px, 2.2vw, 21px);
  color: var(--ink); padding: 2px 0; font-style: italic;
}
.search__input::placeholder { color: var(--muted-2); font-style: italic; }
.search__clear {
  border: 0; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
  border-radius: 50%; width: 26px; height: 26px;
}
.search__clear:hover { color: var(--accent); }

.toolbar__controls {
  display: flex; align-items: flex-end; gap: 14px 22px;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
}
.field__control { position: relative; display: flex; align-items: center; }
.select {
  appearance: none; -webkit-appearance: none;
  border: 0; border-bottom: 1.5px solid var(--ink);
  background: transparent; padding: 6px 28px 8px 0;
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  cursor: pointer; outline: none; border-radius: 0;
}
.select:focus-visible { border-bottom-color: var(--accent); }
.select__chevron { position: absolute; right: 2px; top: 50%; transform: translateY(-40%); color: var(--muted); pointer-events: none; }

.saved-toggle {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 16px 8px 13px;
  border: 1.5px solid var(--rule-2);
  background: var(--paper);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--ink-2);
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .08s ease;
}
.saved-toggle:hover { border-color: var(--ink); }
.saved-toggle:active { transform: translateY(1px); }
.saved-toggle__bookmark { display: inline-flex; color: var(--muted); transition: color .16s ease, transform .18s ease; }
.saved-toggle__count {
  font-family: var(--mono); font-size: 11px;
  background: var(--paper-sunk); color: var(--muted);
  padding: 1px 7px; border-radius: 999px; min-width: 22px; text-align: center;
  transition: background .16s ease, color .16s ease;
}
.saved-toggle[aria-pressed="true"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__bookmark { color: var(--accent); transform: scale(1.08); }
.saved-toggle[aria-pressed="true"] .saved-toggle__count { background: rgba(245,241,232,.16); color: var(--paper); }

/* ---------- Results meta ---------- */
.results-meta {
  max-width: var(--maxw);
  margin: 14px auto 0;
  padding: 0 clamp(16px, 3vw, 36px);
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted);
  min-height: 16px;
}

/* ---------- Stories grid ---------- */
.stories { max-width: var(--maxw); margin: 10px auto 0; padding: 0 clamp(16px, 3vw, 36px) 40px; }
.stories__grid {
  display: grid; gap: clamp(26px, 3vw, 40px);
  grid-template-columns: 1fr;
}

.item {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--paper);
}

/* Featured (first) layout */
.item--featured { grid-column: 1 / -1; }

.item__media {
  position: relative; overflow: hidden; background: var(--paper-sunk);
  aspect-ratio: 16 / 10;
}
.item__media::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(28,26,23,.06); pointer-events: none;
}
.item__img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .6s cubic-bezier(.2,.7,.2,1);
}
.item:hover .item__img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) { .item__img { transition: none; } .item:hover .item__img { transform: none; } }

.item__text { display: flex; flex-direction: column; padding-top: 16px; flex: 1; }

.kicker {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 12px;
}
.kicker__dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--accent); }
.kicker__sep { color: var(--rule-2); }
.kicker__num { color: var(--muted); }

.item__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.12;
  letter-spacing: -.01em;
  margin: 0 0 12px;
  color: var(--ink);
  text-wrap: balance;
}

.item__summary {
  font-family: var(--serif);
  font-size: clamp(15px, 1.8vw, 17px);
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 16px;
}

.item__meta {
  margin-top: auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  font-family: var(--sans); font-size: 13px; color: var(--muted-2);
  padding-top: 4px;
}
.item__meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--rule-2); display: inline-block; }
.item__author { color: var(--ink-2); font-weight: 500; }

.open-item {
  display: inline-flex; align-items: center; gap: 8px;
  align-self: flex-start;
  margin-top: 16px;
  padding: 9px 18px;
  border: 1.5px solid var(--ink);
  background: transparent; color: var(--ink);
  font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  letter-spacing: .02em; cursor: pointer;
  border-radius: 999px;
  transition: background .16s ease, color .16s ease, transform .08s ease;
}
.open-item .open-item__arrow { transition: transform .2s ease; }
.open-item:hover { background: var(--ink); color: var(--paper); }
.open-item:hover .open-item__arrow { transform: translateX(4px); }
.open-item:active { transform: translateY(1px); }

/* Saved badge on a card */
.item__saved-mark {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase;
  background: var(--paper); color: var(--accent);
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-soft);
}
.item__saved-mark svg { width: 12px; height: 12px; }

/* Responsive grids */
@media (min-width: 680px) {
  .stories__grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1080px) {
  .stories__grid { grid-template-columns: repeat(3, 1fr); gap: clamp(32px, 3vw, 48px); }
}

/* Featured: side-by-side on wider screens */
@media (min-width: 720px) {
  .item--featured {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: clamp(28px, 4vw, 56px);
    align-items: center;
    padding-bottom: clamp(24px, 3vw, 40px);
    margin-bottom: clamp(8px, 1vw, 12px);
    border-bottom: 1px solid var(--rule);
  }
  .item--featured .item__media { aspect-ratio: 4 / 3; }
  .item--featured .item__text { padding-top: 0; }
  .item--featured .item__title { font-size: clamp(30px, 4.4vw, 50px); }
  .item--featured .item__summary { font-size: clamp(17px, 2vw, 20px); }
}
@media (min-width: 1000px) {
  .item--featured { grid-template-columns: 1.2fr 1fr; }
}

@media (max-width: 719px) {
  .item__media { aspect-ratio: 16 / 11; }
}

/* ---------- Empty state ---------- */
.empty-state { padding: clamp(40px, 8vw, 80px) 0; }
.empty-state__plate {
  max-width: 480px; margin: 0 auto; text-align: center;
  border: 1px dashed var(--rule-2); border-radius: 6px;
  padding: clamp(28px, 5vw, 44px);
  background: var(--paper);
}
.empty-state__mark { color: var(--rule-2); display: inline-flex; margin-bottom: 14px; }
.empty-state__title {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(24px, 4vw, 32px); margin: 0 0 10px; color: var(--ink);
}
.empty-state__body { color: var(--muted); margin: 0 0 22px; font-size: 16px; }
.empty-state__recover {
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: 11px 22px; border-radius: 999px; cursor: pointer;
  font-family: var(--sans); font-size: 14px;
  transition: background .16s ease, color .16s ease;
}
.empty-state__recover:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- Colophon ---------- */
.colophon {
  max-width: var(--maxw); margin: 30px auto 0;
  padding: clamp(24px, 4vw, 40px) clamp(16px, 3vw, 36px) clamp(40px, 6vw, 70px);
}
.colophon__rule { height: 1px; background: var(--ink); margin-bottom: clamp(28px,4vw,40px); }
.colophon__cols { display: grid; gap: clamp(20px,3vw,40px); grid-template-columns: 1fr; }
.colophon__col { max-width: 42ch; }
.colophon__head {
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 8px;
}
.colophon__note { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.colophon__sign {
  margin-top: clamp(28px,4vw,40px); font-family: var(--display);
  font-size: clamp(18px, 2.4vw, 22px); color: var(--ink-2); font-style: italic;
}
@media (min-width: 820px) {
  .colophon__cols { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Detail / reading view ---------- */
.detail {
  position: fixed; inset: 0; z-index: 80;
  display: flex; justify-content: center; align-items: flex-start;
  overflow-y: auto; overscroll-behavior: contain;
}
.detail[hidden] { display: none; }
.detail__scrim {
  position: fixed; inset: 0; background: rgba(20,18,16,.42);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: scrim-in .22s ease;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.detail__sheet {
  position: relative; z-index: 1;
  width: 100%; max-width: 760px;
  margin: clamp(8px, 4vh, 44px) auto;
  background: var(--paper);
  box-shadow: var(--shadow-card);
  border-radius: 4px;
  animation: sheet-in .28s cubic-bezier(.2,.7,.2,1);
}
@media (prefers-reduced-motion: reduce) {
  .detail__scrim, .detail__sheet { animation: none; }
}

.detail__bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(18px, 4vw, 30px);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: saturate(1.1);
}
.detail__close {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--ink); background: transparent;
  color: var(--ink); padding: 8px 14px; border-radius: 999px;
  cursor: pointer; font-family: var(--sans); font-size: 14px;
  transition: background .16s ease, color .16s ease, transform .08s ease;
}
.detail__close:hover { background: var(--ink); color: var(--paper); }
.detail__close:active { transform: translateY(1px); }
.detail__crumb {
  margin: 0; font-family: var(--mono); font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}

.detail__body { padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 64px) clamp(48px, 7vw, 80px); }

.detail__kicker {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-2); margin: 0 0 18px;
}
.detail__kicker .kicker__dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.detail__title {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(30px, 5.4vw, 50px);
  line-height: 1.05; letter-spacing: -.015em;
  margin: 0 0 22px; color: var(--ink); text-wrap: balance;
}

.detail__byline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding-bottom: 22px; margin-bottom: 26px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 14px; color: var(--muted);
}
.detail__byline .author { color: var(--ink-2); font-weight: 600; }
.detail__byline .pip { width: 3px; height: 3px; border-radius: 50%; background: var(--rule-2); }

.detail__lede {
  font-family: var(--serif); font-style: italic;
  font-size: clamp(19px, 2.6vw, 23px); line-height: 1.5;
  color: var(--ink-2); margin: 0 0 26px; max-width: 56ch;
}

.detail__media {
  margin: 0 0 30px; border-radius: 2px; overflow: hidden;
  background: var(--paper-sunk);
}
.detail__media img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.detail__caption {
  margin: 10px 2px 0; font-family: var(--sans); font-size: 12.5px;
  color: var(--muted-2); line-height: 1.5; max-width: 60ch;
}

.detail__prose { max-width: var(--readw); }
.detail__prose p {
  font-family: var(--serif); font-size: clamp(18px, 2.1vw, 20px);
  line-height: 1.72; color: var(--ink-2); margin: 0 0 1.1em;
}
.detail__prose p:first-child::first-letter {
  font-family: var(--display); font-size: 3.4em; line-height: .82;
  float: left; padding: .04em .08em 0 0; color: var(--accent);
}

.detail__tail {
  margin-top: clamp(30px, 5vw, 44px); padding-top: 26px;
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}

.save-item {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 20px;
  border: 1.5px solid var(--ink); background: var(--paper);
  color: var(--ink); font-family: var(--sans); font-size: 14px; font-weight: 500;
  border-radius: 999px; cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .08s ease;
}
.save-item:active { transform: translateY(1px); }
.save-item__icon { display: inline-flex; transition: transform .18s ease, color .16s ease; color: var(--muted); }
.save-item:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.save-item:hover .save-item__icon { color: var(--paper); }
.save-item[aria-pressed="true"] {
  background: var(--accent); color: var(--paper); border-color: var(--accent);
}
.save-item[aria-pressed="true"] .save-item__icon { color: var(--paper); transform: scale(1.05); }
.save-item[aria-pressed="true"]:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.detail__share {
  font-family: var(--mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
}

/* hide body scroll when detail open */
body.detail-open { overflow: hidden; }

/* ---------- Mobile tweaks ---------- */
@media (max-width: 620px) {
  .masthead__strip { flex-direction: column; gap: 4px; text-align: center; }
  .masthead__tagline { text-align: center; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar__controls { justify-content: space-between; }
  .item--featured .item__media { aspect-ratio: 16/11; }
  .detail__bar { padding: 12px 16px; }
  .detail__close-label { display: none; }
  .detail__close { padding: 8px 10px; }
  .detail__body { padding: 24px 18px 48px; }
  .results-meta { font-size: 10px; letter-spacing: .14em; }
  .sections a { padding: 12px 12px; font-size: 12px; }
}
