@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: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('assets/dm-sans.ttf') format('truetype');
  font-weight: 400 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 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3ede3;
  --paper: #fbf7f0;
  --ink: #1c1a17;
  --muted: #5b554c;
  --line: #d8cfc0;
  --accent: #b23a2b;
  --accent-soft: #f0d9d4;
  --shadow: 0 18px 40px -24px rgba(28, 26, 23, 0.35);
  --radius: 14px;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 237, 227, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.masthead-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  font-family: 'DM Serif Display', serif;
  border-radius: 8px;
  font-size: 15px;
}
.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  letter-spacing: 0.2px;
}
.masthead-nav { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.masthead-nav a:hover { color: var(--ink); }

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 56px 24px 40px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}
.kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--accent);
  margin: 0 0 14px;
}
.hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  margin: 0 0 18px;
  font-weight: 400;
}
.hero-lede {
  font-family: 'Literata', serif;
  font-size: 18px;
  color: var(--muted);
  max-width: 52ch;
  margin: 0;
}
.hero-figure {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 4/3;
}
.hero-figure img {
  width: 100%; height: 100%; object-fit: cover;
  filter: saturate(0.9) contrast(1.05);
}

.browse {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 24px 64px;
}
.browse-head { margin-bottom: 22px; }
.browse-head h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 30px;
  margin: 0 0 6px;
  font-weight: 400;
}
.browse-sub { color: var(--muted); margin: 0; font-size: 15px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin-bottom: 28px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; min-width: 180px; }
.field-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}
input[type="search"], select {
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="search"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle .toggle-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--line);
}
.toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.toggle[aria-pressed="true"] .toggle-dot { background: var(--accent); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
}
.card-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  line-height: 1.15;
  margin: 0;
  font-weight: 400;
}
.card-summary {
  font-family: 'Literata', serif;
  font-size: 15px;
  color: var(--muted);
  margin: 0;
  flex: 1;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.byline { font-size: 13px; color: var(--muted); }
.open-btn {
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.open-btn:hover { opacity: 0.85; }
.open-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
}
.empty-state h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  margin: 0 0 6px;
  font-weight: 400;
}
.empty-state p { color: var(--muted); margin: 0 0 16px; }

.btn {
  font: inherit;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; }
.btn-save {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-save[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.about {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 24px 48px;
  border-top: 1px solid var(--line);
}
.about h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  font-weight: 400;
  margin: 0 0 10px;
}
.about p { max-width: 70ch; color: var(--muted); }

.footer {
  border-top: 1px solid var(--line);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Detail */
.detail[hidden] { display: none; }
.detail {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 26, 23, 0.55);
  backdrop-filter: blur(4px);
}
.detail-panel {
  position: relative;
  z-index: 1;
  width: min(780px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--paper);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
}
.detail-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  background: var(--paper);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.detail-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin: 0 0 10px;
}
.detail-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  margin: 0 0 20px;
  font-weight: 400;
}
.detail-body p {
  font-family: 'Literata', serif;
  font-size: 18px;
  line-height: 1.7;
  margin: 0 0 16px;
  color: var(--ink);
}
.detail-body p:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; padding-top: 32px; }
  .hero-figure { aspect-ratio: 16/9; }
  .masthead-nav { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .detail-panel { padding: 20px; max-height: 92vh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .btn, input, select { transition: none; }
  .card:hover { transform: none; }
}
