/* The Longer Way — a magazine of everyday city life */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --paper: #e9ece7;
  --paper-raised: #f2f4f0;
  --ink: #1c2a33;
  --ink-soft: #4a5b64;
  --amber: #b4731e;
  --amber-deep: #8a5511;

  --c-culture: #5b3e86;
  --c-food: #a04a1f;
  --c-movement: #1f5c74;
  --c-people: #8e3340;
  --c-places: #336639;

  --display: "Space Grotesk", "Trebuchet MS", sans-serif;
  --reading: "Literata", Georgia, serif;

  --gutter: clamp(1.1rem, 4vw, 3rem);
  --measure: 66ch;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

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

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

.masthead {
  padding: clamp(1.4rem, 3vw, 2.4rem) var(--gutter) 0;
}

.masthead-tag {
  margin: 0 0 .5rem;
  font-family: var(--reading);
  font-style: italic;
  font-size: .95rem;
  color: var(--ink-soft);
}

.masthead-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 1.1rem;
}

.masthead-name {
  margin: 0;
  font-size: clamp(2.5rem, 6.5vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.terminus {
  display: inline-block;
  width: .28em;
  height: .28em;
  margin-left: .14em;
  border-radius: 50%;
  background: var(--amber);
  vertical-align: baseline;
}

.masthead-issue {
  margin: 0;
  font-size: .9rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- Page + toolbar ---------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) 4rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto auto;
  gap: 1.2rem 1.6rem;
  align-items: end;
  padding: 1.5rem 0 .4rem;
}

.field { display: flex; flex-direction: column; gap: .3rem; }

.field label,
.field-label {
  font-size: .82rem;
  color: var(--ink-soft);
  letter-spacing: .01em;
}

.field-search input,
.field-topic select {
  font: inherit;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: .45rem 1rem;
  min-height: 2.6rem;
}

.field-search input { width: 100%; max-width: 26rem; }
.field-search input::placeholder { color: var(--ink-soft); opacity: .8; }

.field-topic select { cursor: pointer; }

.saved-toggle {
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: .5rem 1.1rem;
  min-height: 2.6rem;
  font-weight: 500;
  background: var(--paper-raised);
  transition: background .15s ease, color .15s ease;
}
.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.toolbar-count {
  grid-column: 1 / -1;
  margin: .3rem 0 0;
  font-size: .85rem;
  color: var(--ink-soft);
}

/* ---------- Story list ---------- */

.stories { padding-top: 1.2rem; }

.story { position: relative; }

.story-topic {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .55rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--c, var(--ink-soft));
}

.dot {
  width: .62rem;
  height: .62rem;
  border-radius: 50%;
  background: var(--c, var(--ink-soft));
  flex: none;
}

.story-title {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.12;
  text-align: left;
  color: var(--ink);
  display: inline;
}
.story-title:hover { text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 3px; text-underline-offset: 5px; }

.story-summary {
  font-family: var(--reading);
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink);
  margin: .6rem 0 .7rem;
  max-width: var(--measure);
}

.story-meta {
  margin: 0;
  font-size: .85rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.story-saved-flag {
  display: inline-block;
  margin-left: .5rem;
  padding: .05rem .55rem;
  border: 1px solid var(--amber);
  border-radius: 999px;
  color: var(--amber-deep);
  font-weight: 500;
}

/* Lead story: the first result gets the full-width treatment */

.story-lead {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(1.2rem, 3vw, 2.6rem);
  align-items: end;
  padding-bottom: 2.4rem;
}

.story-lead .story-topic { font-size: 1rem; }
.story-lead .story-title {
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.028em;
}
.story-lead .story-summary { font-size: 1.12rem; }

.story-lead-figure {
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 5 / 4;
}
.story-lead-figure img { width: 100%; height: 100%; object-fit: cover; }
.story-lead-figure figcaption {
  font-size: .75rem;
  color: var(--ink-soft);
  padding-top: .4rem;
}

/* Remaining stories: quiet two-column typographic list */

.story-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.2rem 3rem;
  border-top: 2px solid var(--ink);
  padding-top: 2rem;
}

.story-grid .story-title { font-size: 1.42rem; }

.story-grid .story { padding-bottom: .4rem; }

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

.empty {
  border: 1.5px dashed var(--ink-soft);
  border-radius: 8px;
  padding: 2.4rem;
  margin-top: 2rem;
  max-width: 34rem;
}

.empty-title { margin: 0 0 .4rem; font-size: 1.35rem; letter-spacing: -0.02em; }
.empty-text {
  font-family: var(--reading);
  margin: 0 0 1.2rem;
  color: var(--ink-soft);
}

.empty-reset {
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: .5rem 1.2rem;
  background: var(--paper-raised);
  font-weight: 500;
}
.empty-reset:hover { background: var(--ink); color: var(--paper); }

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

.colophon {
  border-top: 2px solid var(--ink);
  margin-top: 1rem;
  padding: 1.4rem var(--gutter) 2.4rem;
  font-size: .85rem;
  color: var(--ink-soft);
}
.colophon p { margin: 0; max-width: 70ch; }
.colophon strong { color: var(--ink); font-weight: 600; }

/* ---------- Detail dialog ---------- */

.detail {
  border: none;
  border-radius: 8px;
  padding: 0;
  width: min(760px, 94vw);
  max-height: min(880px, 92vh);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(15, 25, 32, .35);
}

.detail::backdrop {
  background: rgba(16, 26, 33, .55);
}

.detail-inner {
  max-height: min(880px, 92vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.6rem;
  background: var(--paper);
  border-bottom: 1.5px solid var(--ink);
}

.detail-topic {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  font-size: .9rem;
  font-weight: 500;
  color: var(--c, var(--ink-soft));
}

.detail-actions { display: flex; gap: .6rem; }

.save-btn,
.close-btn {
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: .38rem .95rem;
  font-weight: 500;
  background: var(--paper-raised);
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.save-btn:hover,
.close-btn:hover { background: var(--ink); color: var(--paper); }

.save-btn[aria-pressed="true"] {
  background: var(--amber-deep);
  border-color: var(--amber-deep);
  color: #fff;
}
.save-btn[aria-pressed="true"]:hover { background: #6f430d; }

.detail-content { padding: 1.8rem clamp(1.2rem, 4vw, 2.6rem) 2.6rem; }

.detail-title {
  margin: 0 0 .7rem;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  max-width: var(--measure);
}

.detail-meta {
  margin: 0 0 1.4rem;
  font-size: .88rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.detail-figure { margin: 0 0 1.6rem; border-radius: 6px; overflow: hidden; }
.detail-figure img { width: 100%; height: auto; max-height: 320px; object-fit: cover; }
.detail-figure figcaption { font-size: .78rem; color: var(--ink-soft); padding-top: .45rem; }

.detail-body {
  font-family: var(--reading);
  font-size: 1.08rem;
  line-height: 1.75;
  max-width: var(--measure);
}
.detail-body p { margin: 0 0 1.15rem; }
.detail-body p:last-child { margin-bottom: 0; }

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .toolbar {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .field-search input { max-width: none; }

  .story-lead {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .story-lead-figure { order: -1; aspect-ratio: 16 / 10; }

  .story-grid { grid-template-columns: 1fr; gap: 2rem; }

  .detail {
    width: 100vw;
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }
  .detail-inner { max-height: 100dvh; }

  .detail-bar { padding: .8rem 1rem; gap: .6rem; }
  .detail-actions { gap: .4rem; }
  .save-btn,
  .close-btn { padding: .32rem .7rem; font-size: .85rem; }
  .detail-topic { font-size: .82rem; }
}
