:root {
  --bg: #f4f1ea;
  --paper: #fbfaf5;
  --clay: #b66a3d;
  --clay-deep: #9a4f2c;
  --ink: #2b241f;
  --ink-soft: #5c554e;
  --sage: #7d8a72;
  --sage-deep: #5e6a55;
  --line: #d9d2c9;
  --font-display: "Iowan Old Style", "Georgia", "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

body {
  min-height: 100vh;
}

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

button, select, input {
  font: inherit;
  color: inherit;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--clay-deep);
  margin: 0;
}

.brand small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.field input[type="search"] {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.4rem 0.6rem;
  border-radius: 0;
  min-width: 12rem;
}

.field select {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.4rem 0.6rem;
  border-radius: 0;
  cursor: pointer;
}

/* Save filter toggle */
.save-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--clay);
  background: var(--paper);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--clay-deep);
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.save-filter[aria-pressed="true"] {
  background: var(--clay);
  color: var(--paper);
}

.save-filter svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Hero */
.hero {
  position: relative;
  min-height: 40vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.hero-overlay {
  position: relative;
  z-index: 1;
  padding: 3rem 1.5rem 2rem;
  background: linear-gradient(180deg, rgba(43,36,31,0) 0%, rgba(43,36,31,0.7) 60%, rgba(43,36,31,0.9) 100%);
  width: 100%;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.05;
  max-width: 20ch;
  letter-spacing: -0.02em;
}

.hero-sub {
  color: rgba(255,255,255,0.9);
  margin: 1rem 0 0;
  max-width: 45ch;
  font-size: 1.1rem;
}

/* Main list */
main {
  padding: 2rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-heading {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  margin-left: 1rem;
}

.count {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 400;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
}

.card:hover,
.card:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px -12px rgba(0,0,0,0.25);
}

.card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--line);
}

.card-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
}

.category-tag {
  color: var(--clay-deep);
  font-weight: 600;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}

.card-desc {
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.4;
  margin: 0;
  flex: 1;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.price {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.open-item {
  border: 1px solid var(--ink);
  background: transparent;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease;
}

.open-item:hover,
.open-item:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--ink-soft);
  max-width: 40ch;
  margin: 0 auto;
}

.empty-state h2 {
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.empty-state button {
  margin-top: 1.5rem;
  border: 1px solid var(--clay);
  background: var(--clay);
  color: var(--paper);
  padding: 0.6rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Detail drawer */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43,36,31,0.55);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.detail-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(460px, 100vw);
  background: var(--paper);
  z-index: 21;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px -12px rgba(0,0,0,0.3);
}

.detail-drawer.open {
  transform: translateX(0);
}

.detail-close {
  align-self: flex-end;
  margin: 0.75rem;
  border: none;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.4rem 0.6rem;
  line-height: 1;
}

.detail-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.detail-content {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.detail-meta div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
}

.detail-meta span:last-child {
  color: var(--ink);
  font-weight: 600;
}

.detail-body {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.save-item {
  flex: 1;
  border: 1px solid var(--clay-deep);
  background: var(--paper);
  color: var(--clay-deep);
  padding: 0.7rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.save-item[aria-pressed="true"] {
  background: var(--clay-deep);
  color: var(--paper);
}

.save-item svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.price-lg {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 2rem;
}

@media (max-width: 600px) {
  .controls {
    justify-content: flex-start;
    width: 100%;
  }
  .field input[type="search"] {
    min-width: 0;
    flex: 1;
  }
  .save-filter {
    margin-top: 0.5rem;
  }
  .hero-title {
    font-size: 2.25rem;
  }
  .section-heading::after {
    display: none;
  }
  .card-title {
    font-size: 1.15rem;
  }
  .detail-title {
    font-size: 1.6rem;
  }
}
