@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 300 800;
  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 Serif Display";
  src: url("assets/dm-serif.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --bg-2: #efe7da;
  --surface: #fffaf2;
  --surface-2: #f7f0e4;
  --text: #1f1a14;
  --muted: #6b5f52;
  --accent: #c95a2b;
  --accent-2: #8a3f1c;
  --line: #e3d9c8;
  --focus: #1f6feb;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(31, 26, 20, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1713;
    --bg-2: #221e18;
    --surface: #26211b;
    --surface-2: #2f2922;
    --text: #f1e9dc;
    --muted: #b8a892;
    --accent: #e07a4a;
    --accent-2: #f09a6a;
    --line: #3a3228;
    --focus: #7aa7ff;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: "Work Sans", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  z-index: 100;
  transition: top 120ms ease;
}
.skip-link:focus { top: 1rem; }

.site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0.5rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: "DM Serif Display", serif;
  font-size: 1.25rem;
}
.brand-title {
  margin: 0;
  font-family: "DM Serif Display", serif;
  font-size: 1.5rem;
  line-height: 1.1;
  text-wrap: balance;
}
.brand-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.header-note { margin: 0; color: var(--muted); font-size: 0.85rem; }

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1rem;
}
.hero h2 {
  margin: 0 0 0.5rem;
  font-family: "DM Serif Display", serif;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
  text-wrap: balance;
}
.hero p { margin: 0; max-width: 58ch; color: var(--muted); }

.controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 70%, transparent);
  z-index: 5;
}
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; flex: 1 1 220px; min-width: 0; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; text-transform: uppercase; }

input[data-testid="search"], select[data-testid="filter"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  min-height: 44px;
}
select[data-testid="filter"] { appearance: auto; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.toggle-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}
.toggle[aria-pressed="true"] .toggle-dot { opacity: 1; }

.results-line { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.85rem; }

.list-section { max-width: 1200px; margin: 0 auto; padding: 0.5rem 1.25rem 3rem; }

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .item-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .item-list { grid-template-columns: 1fr; }
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow);
  transition: transform 150ms ease, box-shadow 150ms ease;
  min-width: 0;
}
.item-card:hover { transform: translateY(-2px); }

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 600;
  color: var(--text);
}
.chip.cat { background: rgba(201,90,43,0.12); border-color: rgba(201,90,43,0.3); color: var(--accent-2); }

.item-title {
  margin: 0;
  font-family: "DM Serif Display", serif;
  font-size: 1.25rem;
  line-height: 1.15;
  text-wrap: balance;
}
.item-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}
.item-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.open-item {
  margin-left: auto;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.open-item:hover { background: var(--accent-2); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty-state h3 { margin: 0 0 0.4rem; font-family: "DM Serif Display", serif; }
.empty-state p { margin: 0 0 1rem; color: var(--muted); }

.button {
  padding: 0.6rem 1.1rem;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.button-primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.55);
  backdrop-filter: blur(2px);
}
.detail {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  padding: 1.25rem;
  overscroll-behavior: contain;
  overflow-wrap: break-word;
}
.detail-header { display: flex; justify-content: flex-end; }
.icon-button {
  padding: 0.5rem 0.85rem;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.detail-content { display: flex; flex-direction: column; gap: 0.9rem; }
.detail-title {
  margin: 0.25rem 0 0.25rem;
  font-family: "DM Serif Display", serif;
  font-size: 1.8rem;
  line-height: 1.1;
  text-wrap: balance;
}
.detail-meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  font-size: 0.85rem; color: var(--muted);
}
.detail-body {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text);
}
.detail-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }
.save-item {
  padding: 0.65rem 1.1rem;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.save-item[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
.save-item .label-text { margin-left: 0.4rem; }

.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .item-card, .toggle, .open-item, .skip-link { transition: none; }
  .item-card:hover { transform: none; }
}

@media (max-width: 600px) {
  .controls { position: static; background: none; }
}
