/* ————————————————————————————————————————————————
   Side Street — a journal of everyday city life
   Palette: warm paper, ink, burnt-sienna accent
   ———————————————————————————————————————————————— */

:root {
  --paper: #f6f1e6;
  --paper-raised: #fbf8f0;
  --ink: #201b14;
  --ink-soft: #4d463b;
  --muted: #6f6654;
  --accent: #a8491c;
  --accent-deep: #8a3a14;
  --rule: #d8d0bc;
  --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-text: "Literata", Georgia, "Times New Roman", serif;
  --font-ui: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --measure: 40rem;
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

button, select, input, a { touch-action: manipulation; }

/* Focus */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ——— Masthead ——— */
.masthead {
  padding: 0 clamp(1rem, 4vw, 3rem);
  text-align: center;
}

.masthead-topline {
  border-top: 1px solid var(--ink);
  margin-top: 1.25rem;
}

.masthead-meta {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--ink);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.brand {
  margin: 1.2rem 0 0.1rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 8.5vw, 6.2rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

.brand a {
  text-decoration: none;
}

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

.masthead-tagline {
  margin: 0.35rem 0 1.1rem;
  font-style: italic;
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  text-wrap: balance;
}

.masthead-double-rule {
  border-top: 3px double var(--ink);
}

/* ——— Toolbar ——— */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 1.25rem;
  align-items: end;
  flex-wrap: wrap;
  padding: 0.7rem clamp(1rem, 4vw, 3rem) 0.85rem;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

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

.toolbar-search { flex: 1 1 14rem; min-width: 12rem; }

.field-label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="search"],
select {
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  background-color: var(--paper-raised);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.5rem 0.7rem;
  min-height: 2.7rem;
}

input[type="search"] { width: 100%; }

select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23201b14' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

/* Buttons */
.btn,
.toggle-btn {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.55rem 0.95rem;
  min-height: 2.7rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn:hover,
.toggle-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.icon { width: 1em; height: 1em; }

.icon-bookmark { fill: none; stroke: currentColor; stroke-width: 1.6; }

.toggle-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.toggle-btn[aria-pressed="true"] .icon-bookmark { fill: currentColor; stroke: none; }

.saved-count {
  font-variant-numeric: tabular-nums;
  background: var(--accent);
  color: var(--paper);
  padding: 0.05em 0.45em;
  border-radius: 999px;
  font-size: 0.72em;
}

/* ——— List view ——— */
.list-view {
  padding: 0 clamp(1rem, 4vw, 3rem) 3rem;
}

.results-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-top: 1.6rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
}

.results-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.results-count {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.story-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem 2.75rem;
}

/* Featured story spans the full width */
.story.featured {
  grid-column: 1 / -1;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

.story { scroll-margin-top: 5.5rem; }

.story-link {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  text-decoration: none;
  min-width: 0;
}

.featured .story-link {
  flex-direction: row-reverse;
  gap: 2.25rem;
  align-items: center;
}

.featured .story-media { flex: 0 0 42%; }

.featured .story-body { flex: 1; }

.story-media {
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--rule);
}

.story-media img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  filter: sepia(0.22) saturate(0.88) contrast(1.03);
  transition: transform 0.35s ease;
}

.featured .story-media img { aspect-ratio: 3 / 2; }

.story-link:hover .story-media img { transform: scale(1.025); }

.story-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.story-kicker {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.story-kicker .kicker-sep { color: var(--rule); }

.story-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  font-size: 1.32rem;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

.featured .story-title { font-size: clamp(1.7rem, 3vw, 2.4rem); }

.story-summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  text-wrap: pretty;
}

.featured .story-summary { font-size: 1.05rem; }

.story-meta {
  margin: 0.15rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.story:not(.featured) {
  border-top: 2px solid var(--ink);
  padding-top: 0.85rem;
}

.story-link:hover .story-title { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

/* Saved marker on cards */
.story-saved-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.story-saved-mark .icon-bookmark { fill: currentColor; stroke: none; }

/* ——— Empty state ——— */
.empty-state {
  padding: 4rem 1rem 3rem;
  text-align: center;
}

.empty-title {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
}

.empty-hint {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

/* ——— Detail view ——— */
.detail-view {
  padding: 0 clamp(1rem, 4vw, 3rem) 4rem;
  animation: detail-in 0.25s ease;
}

@keyframes detail-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

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

.detail-bar .toggle-btn .toggle-label { text-transform: none; letter-spacing: 0.03em; font-size: 0.85rem; }

.detail-article {
  max-width: 44rem;
  margin: 0 auto;
}

.detail-kicker {
  margin: 0 0 0.9rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.detail-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.1;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

.detail-byline {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0 0 1.4rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.detail-figure { margin: 0 0 2rem; }

.detail-figure .story-media { border-width: 1px; }

.detail-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  filter: sepia(0.22) saturate(0.88) contrast(1.03);
}

.detail-caption {
  margin: 0.45rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.detail-body { font-size: 1.12rem; line-height: 1.85; }

.detail-body p { margin: 0 0 1.35em; text-wrap: pretty; }

.detail-body > p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 3.1em;
  float: left;
  line-height: 0.78;
  padding: 0.06em 0.12em 0 0;
  color: var(--accent);
}

.detail-end {
  text-align: center;
  color: var(--accent);
  font-size: 1.4rem;
  margin: 2rem 0 0.5rem;
}

/* Read next */
.detail-next {
  max-width: 44rem;
  margin: 3.5rem auto 0;
  padding-top: 1.4rem;
  border-top: 3px double var(--ink);
}

.detail-next-heading {
  margin: 0 0 1rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.next-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }

.next-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  min-width: 0;
}

.next-link .story-kicker { font-size: 0.62rem; }

.next-link .next-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.2;
  text-wrap: balance;
}

.next-link:hover .next-title { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

/* ——— Colophon ——— */
.colophon {
  padding: 1.8rem clamp(1rem, 4vw, 3rem) 2.5rem;
  border-top: 3px double var(--ink);
}

.colophon-brand {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent);
}

.colophon-text {
  margin: 0;
  max-width: 46rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.colophon-text a { color: var(--ink-soft); }

/* ——— Responsive ——— */
@media (max-width: 1020px) {
  .story-list { grid-template-columns: repeat(2, 1fr); gap: 2rem 2.25rem; }
}

@media (max-width: 760px) {
  .toolbar { gap: 0.75rem; }

  .toolbar-search { flex-basis: 100%; }

  .toolbar-field:not(.toolbar-search) { flex: 1 1 auto; }

  .toolbar-saved { margin-left: auto; }

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

  .featured .story-link { flex-direction: column; gap: 0.8rem; align-items: stretch; }

  .featured .story-media { flex: none; }

  .results-line { flex-direction: column; gap: 0.1rem; padding-top: 1.1rem; }
}

@media (max-width: 480px) {
  .masthead-meta { font-size: 0.6rem; gap: 0.5rem; }
  .detail-bar { flex-wrap: wrap; }
}

/* ——— Reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .story-link:hover .story-media img { transform: none; }
}
