/* ============================================================
   KERB — a journal of everyday city life
   Visual thesis: a street-level field zine. Warm paper, ink,
   vermilion street paint; serif headlines over mono marginalia;
   warm-monochrome photographs that reveal their color up close.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --paper: #f4eee0;
  --paper-2: #e9e0c9;
  --ink: #221c12;
  --ink-2: #61594a;
  --line: #c9bfa4;
  --accent: #d2481c;        /* street paint — large marks only */
  --accent-ink: #a83a12;    /* accent at text-safe contrast */
  --serif-d: "DM Serif Display", "Times New Roman", serif;
  --serif: "Literata", Georgia, serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
  --gutter: clamp(20px, 4vw, 44px);
}

/* ---------- fonts ---------- */
@font-face {
  font-family: "DM Serif Display";
  src: url("assets/dm-serif.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

/* ---------- base ---------- */
*, *::before, *::after { 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: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

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

img { max-width: 100%; }

button { font-family: inherit; color: inherit; }

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

.container {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.mono {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tick {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  background: var(--accent);
  vertical-align: 0;
}

/* print signature: heavy + thin double rule */
.rule-double { border-top: 3px solid var(--ink); }
.rule-double::after {
  content: "";
  display: block;
  border-top: 1px solid var(--ink);
  margin-top: 3px;
}

/* ---------- masthead ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-block: 11px;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
}
.topbar p { margin: 0; }

.brand {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 400px);
  gap: clamp(24px, 4vw, 56px);
  align-items: end;
  padding-block: clamp(26px, 4.5vw, 52px) clamp(22px, 3.4vw, 36px);
}

.brand-name {
  margin: 0;
  font-family: var(--serif-d);
  font-weight: 400;
  font-size: clamp(72px, 10.5vw, 138px);
  line-height: 0.88;
  letter-spacing: -0.015em;
}

.dot { color: var(--accent); }

.mission {
  border-left: 1px solid var(--line);
  padding-left: clamp(18px, 2vw, 28px);
}
.mission p { margin: 0; }
.mission p:first-child {
  font-size: 16.5px;
  line-height: 1.55;
}
.mission-note { margin-top: 12px !important; color: var(--ink-2); }

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

.controls-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px clamp(20px, 3vw, 40px);
  padding-block: 13px 16px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-2);
}

.field-search { flex: 1 1 240px; max-width: 340px; }
.field-topic { flex: 0 1 auto; }

#search, #topic {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  padding: 8px 2px;
  border-radius: 0;
}

#search::placeholder { color: var(--ink-2); opacity: 0.75; }

#search:focus-visible, #topic:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-bottom-color: var(--ink);
}

#topic {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  min-width: 170px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23221c12' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.saved-toggle:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.count {
  margin: 0 0 2px auto;
  color: var(--ink-2);
}

/* ---------- index (story list) ---------- */
.index {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(32px, 5vw, 72px);
}

.index > li:first-child { grid-column: 1 / -1; }

.item { position: relative; }

/* lead story */
.lead {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: clamp(24px, 4vw, 60px);
  align-items: center;
  padding-block: clamp(26px, 4vw, 46px) clamp(30px, 4vw, 48px);
}

.lead-media { margin: 0; }
.lead-media img {
  width: 100%;
  aspect-ratio: 16 / 10.5;
  object-fit: cover;
  border: 1px solid var(--ink);
}

.lead-headline {
  margin: 14px 0 0;
  font-family: var(--serif-d);
  font-weight: 400;
  font-size: clamp(32px, 4.3vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.005em;
}

/* index rows */
.row-li { border-top: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: clamp(16px, 2.5vw, 26px);
  padding-block: clamp(22px, 2.6vw, 30px);
}

.row-media { margin: 0; }
.row-media img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--ink);
}

.row-headline {
  margin: 10px 0 0;
  font-family: var(--serif-d);
  font-weight: 400;
  font-size: clamp(21px, 1.9vw, 26px);
  line-height: 1.12;
}

/* shared item text */
.headline-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}
.headline-btn:hover, .headline-btn:focus-visible {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.14em;
}

.tagline { margin: 0; color: var(--ink-2); }

.summary {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 58ch;
}
.lead .summary { font-size: 17.5px; color: var(--ink); }

.meta {
  margin: 14px 0 0;
  color: var(--ink-2);
}
.meta .saved-flag { color: var(--accent-ink); font-weight: 700; }

.btn {
  display: inline-block;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 12px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover, .btn:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.read-btn { margin-top: 22px; }

/* photography: warm monochrome at rest, true color up close */
.media img {
  filter: grayscale(0.9) sepia(0.16) contrast(1.04);
  transition: filter 0.45s ease;
}
.item:hover .media img,
.item:focus-within .media img { filter: none; }

/* ---------- empty state ---------- */
.empty {
  padding-block: clamp(64px, 9vw, 110px);
  text-align: center;
}
.empty h2 {
  margin: 18px 0 0;
  font-family: var(--serif-d);
  font-weight: 400;
  font-size: clamp(26px, 3.2vw, 36px);
  line-height: 1.1;
}
.empty-kicker { color: var(--accent-ink); }
.empty-detail { color: var(--ink-2); margin: 14px auto 0; max-width: 52ch; }
.empty .btn { margin-top: 28px; }

/* ---------- colophon ---------- */
.colophon { margin-top: 8px; }
.colophon-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: clamp(24px, 4vw, 64px);
  padding-block: clamp(30px, 4vw, 48px) clamp(40px, 6vw, 64px);
}
.colophon-name {
  margin: 0 0 10px;
  font-family: var(--serif-d);
  font-size: 34px;
  line-height: 1;
}
.colophon-about p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.colophon-notes p { margin: 0 0 12px; color: var(--ink-2); font-size: 10.5px; line-height: 1.7; }

/* ---------- detail (dialog) ---------- */
.detail {
  width: min(780px, calc(100% - 36px));
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(20, 14, 6, 0.45);
}
.detail::backdrop { background: rgba(28, 22, 12, 0.55); }

.sheet {
  padding: clamp(22px, 4.5vw, 52px) clamp(20px, 6vw, 68px) clamp(36px, 5vw, 56px);
}

.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.close:hover, .close:focus-visible { background: var(--ink); color: var(--paper); }

#detail-title {
  margin: 16px 0 0;
  font-family: var(--serif-d);
  font-weight: 400;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.005em;
}

.byline { margin: 16px 0 0; color: var(--ink-2); }

.sheet-actions { margin-top: 22px; }

.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.save-btn:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.save-btn[aria-pressed="true"] {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: var(--paper);
}

.sheet-figure { margin: clamp(26px, 4vw, 40px) 0 0; }
.sheet-figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--ink);
}
.sheet-figure figcaption {
  margin-top: 9px;
  color: var(--ink-2);
  font-size: 10.5px;
  letter-spacing: 0.12em;
}

.article-body { margin-top: clamp(26px, 4vw, 40px); }
.article-body p {
  margin: 0 0 1.15em;
  font-size: 18.5px;
  line-height: 1.72;
  max-width: 66ch;
}
.article-body p:first-child::first-letter {
  font-family: var(--serif-d);
  font-size: 3.05em;
  float: left;
  line-height: 0.82;
  padding: 0.05em 0.14em 0 0;
  color: var(--accent);
}

.sheet-foot {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

.next-btn {
  border: 0;
  background: none;
  padding: 6px 0;
  cursor: pointer;
  text-align: right;
  color: var(--accent-ink);
  transition: color 0.15s ease;
}
.next-btn:hover, .next-btn:focus-visible { color: var(--ink); text-decoration: underline; text-underline-offset: 0.2em; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .brand { grid-template-columns: 1fr; align-items: start; }
  .mission { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 18px; }
  .index { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .lead { grid-template-columns: 1fr; align-items: start; }
  .lead-media { order: -1; }
  .lead-media img { aspect-ratio: 16 / 10; }
  .row { grid-template-columns: 92px 1fr; gap: 16px; }
  .count { flex: 1 0 100%; margin: 0; }
  .colophon-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { font-size: 10px; }
  .controls-inner { align-items: stretch; }
  .field-search, .field-topic { flex: 1 1 100%; max-width: none; }
  .saved-toggle { flex: 1 0 100%; justify-content: center; }
  .detail { width: 100%; max-height: 100dvh; height: 100dvh; }
  .article-body p { font-size: 17.5px; }
}

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