/* Between Stops — night-board editorial design */

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

:root {
  --bg: #122b3b;        /* harbor blue */
  --bg-2: #18374a;      /* raised */
  --bg-3: #1f445a;      /* hover */
  --ivory: #f3eee2;
  --soft: #e8e2d4;
  --dim: #a7bfc9;
  --amber: #f2a93b;
  --ink-on-amber: #14293a;
  --line: rgba(243, 238, 226, 0.18);
  --cul: #f2a93b;  /* Culture  */
  --food: #e8896b; /* Food     */
  --mov: #8fc3e8;  /* Movement */
  --peo: #9bc49a;  /* People   */
  --pla: #b9a7e0;  /* Places   */
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ivory);
  font-family: 'Literata', Georgia, serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.locked { overflow: hidden; }

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

.mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--amber);
  color: var(--ink-on-amber);
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  font-family: 'IBM Plex Mono', monospace;
  z-index: 60;
}
.skip:focus { left: 0; }

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px) 0;
}

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

.masthead {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: clamp(28px, 4vw, 56px);
  align-items: end;
  padding: clamp(36px, 6vh, 64px) 0 clamp(28px, 4vh, 44px);
}

.issue {
  margin: 0 0 14px;
  color: var(--dim);
}

.title {
  margin: 0;
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  font-size: clamp(4rem, 10.5vw, 9.25rem);
  line-height: 0.92;
  letter-spacing: -0.015em;
}
.title span { display: block; }

.tagline {
  margin: 22px 0 0;
  max-width: 34em;
  color: var(--dim);
  font-size: 1.02rem;
}

.route {
  display: block;
  width: min(240px, 40%);
  margin-top: 26px;
}
.route line, .route-end {
  stroke: var(--amber);
  fill: var(--amber);
  stroke-width: 2;
}

.cover { margin: 0; }
.cover img {
  display: block;
  width: 100%;
  height: clamp(220px, 40vh, 420px);
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.cover figcaption {
  margin-top: 10px;
  color: var(--dim);
}

/* ---------- Toolbar ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px clamp(20px, 4vw, 48px);
  margin: 0 calc(clamp(20px, 4vw, 48px) * -1);
  background: rgba(18, 43, 59, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.field { display: flex; align-items: center; gap: 10px; }
.field .mono { color: var(--dim); }

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

#search, #filter {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ivory);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
}
#search { width: 100%; }
#filter { cursor: pointer; }

.chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--ivory);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--bg-3); }

.chip[aria-pressed="true"] {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink-on-amber);
}

.count { margin: 0 0 0 auto; color: var(--dim); }

/* ---------- Story board ---------- */

.list {
  display: grid;
  gap: 14px;
  padding: 26px 0 10px;
}

.row {
  display: grid;
  grid-template-columns: 175px 1fr 132px;
  grid-template-areas: "meta main thumb";
  gap: 26px;
  align-items: center;
  padding: 24px 26px;
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.row:hover, .row:focus-within {
  background: var(--bg-3);
  border-color: var(--line);
}

.row-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--dim);
}
.cat-line { display: flex; align-items: center; gap: 8px; }
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.saved-tag {
  color: var(--amber);
  display: none;
}
.row.is-saved .saved-tag { display: inline; }

.row-main { grid-area: main; min-width: 0; }

.row-title {
  margin: 0;
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  line-height: 1.18;
  letter-spacing: 0.005em;
}
.open-item {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--ivory);
  cursor: pointer;
  text-align: left;
}
.open-item:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.row-summary {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 0.98rem;
  max-width: 58ch;
}

.row-thumb {
  grid-area: thumb;
  width: 132px;
  height: 100px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

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

.empty {
  text-align: center;
  padding: 72px 20px 80px;
}
.empty-title {
  margin: 0;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.8rem;
}
.empty-hint { margin: 10px 0 22px; color: var(--dim); }

/* ---------- Detail sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 20, 29, 0.62);
  display: flex;
  justify-content: flex-end;
}

.sheet {
  width: min(760px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  border-left: 1px solid var(--line);
  animation: sheet-in 0.28s ease;
}
@keyframes sheet-in {
  from { transform: translateX(28px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(20px, 5vw, 40px);
  background: rgba(18, 43, 59, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.sheet-label { color: var(--dim); }
.sheet-actions { display: flex; gap: 10px; }

.sheet-body {
  padding: clamp(28px, 5vh, 48px) clamp(20px, 5vw, 56px) 64px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  color: var(--dim);
}

.detail-title {
  margin: 0;
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  font-size: clamp(2rem, 4.4vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: 0.002em;
  max-width: 18em;
}

.detail-byline { color: var(--dim); margin: 16px 0 0; }

.detail-text {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  max-width: 66ch;
}
.detail-text p {
  margin: 0 0 1.15em;
  color: var(--soft);
  font-size: 1.06rem;
  line-height: 1.75;
}

.endmark { color: var(--amber); font-size: 0.7rem; margin-top: 8px; }

/* ---------- Colophon ---------- */

.colophon {
  border-top: 1px solid var(--line);
  margin-top: 56px;
  padding: 26px 0 40px;
  color: var(--dim);
  font-size: 0.78rem;
}
.colophon p { margin: 0 0 6px; max-width: 72ch; }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .masthead {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .cover { order: 2; margin-top: 6px; }
  .cover img { height: clamp(200px, 34vh, 300px); }
  .count { margin-left: 0; flex-basis: 100%; order: 5; }
}

@media (max-width: 640px) {
  .search-field { flex-basis: 100%; order: 1; }
  .field { order: 2; }
  #saved-filter { order: 3; }

  .row {
    grid-template-columns: 1fr 78px;
    grid-template-areas:
      "meta meta"
      "main thumb";
    gap: 14px;
    padding: 18px 18px;
  }
  .row-meta {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
  }
  .row-thumb { width: 78px; height: 78px; }

  .backdrop { justify-content: stretch; }
  .sheet { width: 100%; border-left: 0; }
}
