/* Street Level — city journal
   Type system: Space Grotesk (display/UI), Literata (reading), IBM Plex Mono (data/meta) */

@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/space-grotesk.ttf') format('truetype');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 380 700;
  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 {
  --ink: #101f38;
  --ink-soft: #2c3f5e;
  --ink-line: rgba(16, 31, 56, 0.16);
  --ink-line-strong: rgba(16, 31, 56, 0.28);
  --paper: #e9edf1;
  --paper-card: #fbfaf6;
  --paper-tint: #cfd8e6;
  --amber: #e3a83a;
  --amber-deep: #a9691c;
  --amber-soft: rgba(227, 168, 58, 0.16);
  --text: #14223c;
  --text-muted: #526074;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-panel: -24px 0 48px -12px rgba(16, 31, 56, 0.38), -4px 0 12px rgba(16, 31, 56, 0.18);
  --shadow-soft: 0 10px 24px -14px rgba(16, 31, 56, 0.4);
  --ease-out: cubic-bezier(0.16, 0.84, 0.44, 1);
  --dur: 0.28s;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0ms; }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: 'Space Grotesk', 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--paper-tint); border-radius: 999px; border: 3px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); }

:focus-visible {
  outline: 2.5px solid var(--amber-deep);
  outline-offset: 3px;
  border-radius: 3px;
}

button, input, select { font-family: inherit; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--amber);
  color: var(--ink);
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  z-index: 200;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

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

.masthead {
  background: var(--ink);
  color: var(--paper-card);
  padding: 2.25rem 1.5rem 1.5rem;
}

.masthead__inner {
  max-width: 74rem;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.masthead__mark {
  width: 2.75rem;
  height: 2.75rem;
  color: var(--amber);
  flex: 0 0 auto;
}

.masthead__wordmark {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 4.4vw, 3.6rem);
  letter-spacing: -0.02em;
  line-height: 0.98;
}

.masthead__tagline {
  margin: 0.4rem 0 0;
  font-family: 'Literata', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: var(--paper-tint);
  font-size: clamp(0.92rem, 1.4vw, 1.05rem);
  max-width: 34ch;
}

.masthead__stat {
  margin: 0 0 0.3rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-tint);
  white-space: nowrap;
}

.masthead__stat #result-count {
  color: var(--amber);
  font-weight: 700;
}

.controls {
  max-width: 74rem;
  margin: 1.75rem auto 0;
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field--search { flex: 1 1 18rem; min-width: 14rem; }
.field--filter { flex: 0 1 13rem; min-width: 10rem; }

.field label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-tint);
}

.field__shell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(251, 250, 246, 0.06);
  border: 1.5px solid rgba(207, 216, 230, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.field__shell:focus-within {
  border-color: var(--amber);
  background: rgba(251, 250, 246, 0.1);
}

.field__icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; color: var(--paper-tint); }

#search-input {
  border: 0;
  background: transparent;
  color: var(--paper-card);
  font-size: 0.98rem;
  width: 100%;
  outline: none;
}
#search-input::placeholder { color: rgba(207, 216, 230, 0.65); }

.field--filter select {
  border: 1.5px solid rgba(207, 216, 230, 0.4);
  background: rgba(251, 250, 246, 0.06) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M5 8l5 5 5-5" fill="none" stroke="%23cfd8e6" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat right 0.75rem center / 1rem;
  color: var(--paper-card);
  border-radius: var(--radius-sm);
  padding: 0.68rem 2.25rem 0.68rem 0.85rem;
  font-size: 0.98rem;
  appearance: none;
  cursor: pointer;
}
.field--filter select:focus-visible { border-color: var(--amber); }
.field--filter select option { color: var(--ink); }

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1.5px dashed rgba(207, 216, 230, 0.55);
  background: transparent;
  color: var(--paper-card);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
  white-space: nowrap;
}
.saved-toggle__icon { width: 1.05rem; height: 1.05rem; }
.saved-toggle__count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  background: rgba(207, 216, 230, 0.22);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}
.saved-toggle:hover { border-color: var(--amber); color: var(--amber); }
.saved-toggle[aria-pressed="true"] {
  background: var(--amber);
  border-style: solid;
  border-color: var(--amber-deep);
  color: var(--ink);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__count { background: rgba(16, 31, 56, 0.16); color: var(--ink); }
.saved-toggle[aria-pressed="true"]:hover { color: var(--ink); }
.saved-toggle[aria-pressed="true"] .saved-toggle__icon path { fill: var(--ink); }

/* ---------- Board (story list) ---------- */

main { max-width: 74rem; margin: 0 auto; padding: 0 1.5rem 5rem; }

.board__status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.75rem 0 0.5rem;
}

.board__list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border-top: 1.5px solid var(--ink-line-strong);
}

.row { border-bottom: 1.5px solid var(--ink-line); }

.row__open {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 1.15rem 0.75rem;
  cursor: pointer;
  color: inherit;
  transition: background var(--dur) var(--ease-out);
}
.row__open:hover, .row__open:focus-visible { background: var(--amber-soft); }

.row__code {
  flex: 0 0 auto;
  width: 3.4rem;
  padding-top: 0.15rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.row__title {
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.3;
  color: var(--text);
}

.row__summary {
  font-family: 'Literata', Georgia, serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 62ch;
}

.row__saved-mark {
  display: inline-flex;
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.4em;
  color: var(--amber-deep);
  vertical-align: -0.05em;
}

.row__meta {
  flex: 0 0 auto;
  width: 12.5rem;
  padding-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.4rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.row__chevron {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.3rem;
  color: var(--ink-soft);
  transition: transform var(--dur) var(--ease-out);
}
.row__open:hover .row__chevron { transform: translateX(3px); }

@media (max-width: 640px) {
  .row__open { flex-wrap: wrap; padding: 1rem 0.5rem; gap: 0.6rem 1rem; }
  .row__meta { width: auto; flex-basis: 100%; order: 3; padding-top: 0; margin-left: calc(3.4rem + 1rem); }
  .row__chevron { display: none; }
}

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

.empty-state {
  margin: 3rem auto 0;
  max-width: 30rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 1.5px dashed var(--ink-line-strong);
  border-radius: var(--radius-md);
}
.empty-state__icon { width: 3.2rem; height: 3.2rem; color: var(--ink-soft); margin: 0 auto 1rem; }
.empty-state h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.empty-state p { margin: 0 0 1.25rem; color: var(--text-muted); font-family: 'Literata', Georgia, serif; }
.empty-state__reset {
  font: 600 0.95rem 'Space Grotesk', sans-serif;
  background: var(--ink);
  color: var(--paper-card);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out);
}
.empty-state__reset:hover { background: var(--ink-soft); }

/* ---------- Scrim + detail panel ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 31, 56, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
  z-index: 55;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.detail {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(600px, 94vw);
  background: var(--paper-card);
  box-shadow: var(--shadow-panel);
  transform: translateX(102%);
  transition: transform var(--dur, 0.38s) var(--ease-out);
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.detail.is-open { transform: translateX(0); }

.detail__scroll { overflow-y: auto; height: 100%; }

.detail__close {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1.5px solid var(--ink-line-strong);
  background: var(--paper-card);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: var(--shadow-soft);
}
.detail__close:hover { background: var(--amber); border-color: var(--amber-deep); }
.detail__close svg { width: 1.05rem; height: 1.05rem; }

.detail__photo {
  position: relative;
  height: 15rem;
  background: var(--ink);
  overflow: hidden;
}
.detail__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.85) brightness(0.82);
  mix-blend-mode: luminosity;
  opacity: 0.9;
}
.detail__photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 31, 56, 0.15) 0%, rgba(16, 31, 56, 0.65) 100%);
}

.detail__stamp {
  position: absolute;
  left: 1.5rem;
  bottom: 1.25rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 4.6rem;
  height: 4.6rem;
  border-radius: 50%;
  border: 1.5px dashed var(--amber);
  color: var(--amber);
  transform: rotate(-10deg);
  background: rgba(16, 31, 56, 0.72);
}
.detail__stamp-code { font-family: 'IBM Plex Mono', monospace; font-weight: 400; font-size: 1rem; letter-spacing: 0.05em; }
.detail__stamp-sub { font-family: 'IBM Plex Mono', monospace; font-size: 0.56rem; letter-spacing: 0.1em; margin-top: 0.15rem; }

.detail__content { padding: 1.75rem 1.75rem 3rem; }

.detail__title {
  margin: 0 0 0.6rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.55rem, 3vw, 2.05rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.detail__meta {
  margin: 0 0 1.35rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  border: 1.5px dashed var(--ink);
  background: transparent;
  color: var(--ink);
  font: 600 0.92rem 'Space Grotesk', sans-serif;
  cursor: pointer;
  margin-bottom: 1.75rem;
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), border-style var(--dur) var(--ease-out);
}
.save-toggle__icon { width: 1.05rem; height: 1.05rem; }
.save-toggle:hover { border-color: var(--amber-deep); }
.save-toggle[aria-pressed="true"] {
  background: var(--amber);
  border-style: solid;
  border-color: var(--amber-deep);
}
.save-toggle[aria-pressed="true"] .save-toggle__icon path { fill: var(--ink); }

.detail__body {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 66ch;
}
.detail__body p { margin: 0 0 1.15rem; }
.detail__body p:first-of-type::first-letter {
  font-size: 2.6em;
  font-weight: 700;
  float: left;
  line-height: 0.85;
  padding: 0.05em 0.08em 0 0;
  color: var(--amber-deep);
}

.detail__credit {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1.5px dashed var(--ink-line-strong);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

@media (max-width: 640px) {
  .detail { width: 100%; }
  .detail__photo { height: 12rem; }
  .detail__content { padding: 1.5rem 1.25rem 3rem; }
}

@media (min-width: 900px) {
  .masthead { padding: 3rem 2.5rem 1.75rem; }
  main { padding: 0 2.5rem 6rem; }
}
