/* The Stoop — editorial city magazine styles */

@font-face {
  font-family: 'DM Serif Display';
  src: url('assets/dm-serif.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Work Sans';
  src: url('assets/work-sans.ttf') format('truetype');
  font-weight: 100 900;
  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 {
  --color-bg: #f6f1e6;
  --color-surface: #fffdf8;
  --color-ink: #201b14;
  --color-muted: #6b6153;
  --color-border: #e2d7c1;
  --color-accent: #af4b2b;
  --color-accent-dark: #8a3a20;
  --color-accent-soft: #f1ded2;
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --radius: 10px;
  --max-width: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

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

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

.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;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--color-ink);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  z-index: 100;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 1rem;
}

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

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

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 2rem 1.5rem 1.5rem;
}

.masthead {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.masthead-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 0.4rem;
}

.masthead-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  margin: 0;
  letter-spacing: 0.01em;
}

.masthead-tagline {
  margin: 0.4rem 0 0;
  color: var(--color-muted);
  font-size: 1rem;
}

.controls-bar {
  max-width: var(--max-width);
  margin: 1.75rem auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 200px;
  min-width: 160px;
}

.control label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-control {
  flex: 2 1 260px;
}

input[type='search'],
select {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  background: #fff;
  color: var(--color-ink);
}

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

select {
  appearance: auto;
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-ink);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  align-self: end;
  flex: 0 0 auto;
}

.pill-toggle .bookmark-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.pill-toggle:hover {
  border-color: var(--color-accent);
}

.pill-toggle[aria-pressed='true'] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ---------- Main / list ---------- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.result-count {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  margin: 0 0 1rem;
}

.story-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.story-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.story-card .card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--color-accent-soft);
}

.story-card .card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saved-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--color-ink);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-content {
  padding: 1.1rem 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-dark);
  margin: 0;
}

.card-title {
  margin: 0;
  font-size: 1.25rem;
}

.open-item-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-family: var(--font-display);
  text-align: left;
  color: var(--color-ink);
  cursor: pointer;
  line-height: 1.25;
}

.open-item-btn:hover {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

.card-summary {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.94rem;
  flex: 1;
}

.card-meta {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--color-muted);
  font-family: var(--font-mono);
}

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

.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--color-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  margin-top: 1rem;
}

.empty-state p {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.empty-state button {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  font-weight: 600;
  cursor: pointer;
}

.empty-state button:hover {
  background: var(--color-accent-dark);
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  color: var(--color-muted);
  font-size: 0.78rem;
}

/* ---------- Detail view ---------- */

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 27, 20, 0.45);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}

.detail-backdrop[hidden] {
  display: none;
}

.detail-panel {
  background: var(--color-surface);
  width: min(720px, 100%);
  height: 100%;
  overflow-y: auto;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
}

@media (prefers-reduced-motion: no-preference) {
  .detail-panel {
    animation: slide-in 0.22s ease-out;
  }

  @keyframes slide-in {
    from {
      transform: translateX(24px);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }
}

.detail-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1rem 0;
  background: var(--color-surface);
  z-index: 2;
}

.close-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.close-btn svg {
  width: 14px;
  height: 14px;
}

.close-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.detail-body {
  padding: 0 2rem 3rem;
}

.detail-media {
  margin: 0 -2rem 1.5rem;
  aspect-ratio: 16 / 8;
  overflow: hidden;
  background: var(--color-accent-soft);
}

.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-caption {
  margin: -1.2rem -2rem 1.5rem;
  padding: 0.4rem 2rem;
  font-size: 0.72rem;
  color: var(--color-muted);
  font-style: italic;
}

.detail-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-dark);
  margin: 0 0 0.5rem;
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin: 0 0 0.6rem;
  line-height: 1.15;
}

.detail-meta {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  margin: 0 0 1.25rem;
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-accent);
  background: #fff;
  color: var(--color-accent-dark);
  border-radius: 999px;
  padding: 0.65rem 1.3rem;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  margin-bottom: 1.75rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.save-toggle .bookmark-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.save-toggle:hover {
  background: var(--color-accent-soft);
}

.save-toggle[aria-pressed='true'] {
  background: var(--color-accent);
  color: #fff;
}

.detail-text p {
  margin: 0 0 1.1rem;
  font-size: 1.03rem;
}

.detail-text p:last-child {
  margin-bottom: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .site-header {
    padding: 1.5rem 1rem 1.25rem;
  }

  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pill-toggle {
    align-self: stretch;
    justify-content: center;
  }

  main {
    padding: 1.25rem 1rem 3rem;
  }

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

  .detail-panel {
    width: 100%;
  }

  .detail-body {
    padding: 0 1.25rem 2.5rem;
  }

  .detail-media {
    margin: 0 -1.25rem 1.5rem;
  }

  .detail-caption {
    margin: -1.2rem -1.25rem 1.5rem;
    padding: 0.4rem 1.25rem;
  }
}
