/* Forma — warm editorial system */

:root {
  color-scheme: light;
  --paper: #f7f2ea;
  --card: #fffdf8;
  --ink: #26201a;
  --muted: #716453;
  --line: #e3d9c8;
  --clay: #b4552d;
  --clay-deep: #8f3f1e;
  --clay-soft: #f3e2d6;
  --moss: #4c6b4f;
  --shadow: 0 1px 2px rgba(38, 32, 26, 0.06), 0 10px 28px rgba(38, 32, 26, 0.08);
  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --toolbar-h: 4.5rem;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  overflow-x: hidden;
}

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

[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  text-wrap: balance;
  margin: 0;
}

p { text-wrap: pretty; }

button, select, input {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button { cursor: pointer; }

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

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3.5rem;
  z-index: 50;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  border-radius: 0.4rem;
  text-decoration: none;
  transition: top 160ms ease-in-out;
}
.skip-link:focus { top: 1rem; }

/* ---------- Masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem 1.5rem 1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark-dot { color: var(--clay); }
.masthead-tag {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Hero ---------- */

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1rem;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 2.5rem;
  align-items: center;
}
.hero-media {
  border-radius: 0.9rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-media img { width: 100%; height: 100%; object-fit: cover; }
.kicker {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--clay);
  font-weight: 600;
}
.hero h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); }
.hero-lede { color: var(--muted); max-width: 34rem; }
.hero-facts {
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.hero-facts li {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- Toolbar ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem 4rem; }

.toolbar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  margin-top: 2.25rem;
}
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 1.1rem;
  flex-wrap: wrap;
  padding: 0.85rem 0;
}
.field { display: flex; flex-direction: column; gap: 0.28rem; }
.field label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.field input,
.field select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.55rem 0.8rem;
  min-height: 2.6rem;
  color: var(--ink);
  background-color: var(--card);
}
.field input { width: min(320px, 100%); }
.field input::placeholder { color: #a3937e; }
.field input:hover, .field select:hover { border-color: #cfc0a8; }
.field select { padding-right: 2rem; }

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  min-height: 2.6rem;
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  color: var(--ink);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.saved-toggle:hover { border-color: var(--clay); color: var(--clay-deep); }
.saved-toggle[aria-pressed="true"] {
  background: var(--clay);
  border-color: var(--clay);
  color: #fffdf8;
}
.icon-bookmark { width: 14px; height: 14px; }

.result-count {
  margin: 0 0 0.4rem auto;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Grid & Cards ---------- */

.grid {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.6rem;
}
.grid li {
  scroll-margin-top: var(--toolbar-h);
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.grid li:hover .card {
  transform: translateY(-3px);
  box-shadow: 0 2px 3px rgba(38,32,26,0.06), 0 16px 34px rgba(38,32,26,0.12);
}
.card-media { aspect-ratio: 3 / 2; overflow: hidden; background: var(--clay-soft); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 1.1rem 1.2rem 0.4rem; flex: 1; }
.card-cat {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--clay);
  font-weight: 700;
}
.card-title { font-size: 1.35rem; }
.card-desc {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.2rem 1.1rem;
  border-top: 1px dashed var(--line);
  margin-top: 0.8rem;
}
.card-meta { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.card-price {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.card-when {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .btn { flex-shrink: 0; }

.saved-badge {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  margin: 0;
  background: var(--clay);
  color: #fffdf8;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0.55rem;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0.5rem 0.95rem;
  min-height: 2.5rem;
  font-weight: 600;
  color: var(--ink);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.btn:hover { border-color: var(--clay); color: var(--clay-deep); background: #fbf4ea; }
.btn-primary {
  background: var(--clay);
  border-color: var(--clay);
  color: #fffdf8;
}
.btn-primary:hover {
  background: var(--clay-deep);
  border-color: var(--clay-deep);
  color: #fffdf8;
}
.btn-save[aria-pressed="true"] {
  background: var(--moss);
  border-color: var(--moss);
  color: #fffdf8;
}
.btn-save[aria-pressed="true"]:hover { background: #3d5840; border-color: #3d5840; color: #fffdf8; }

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

.empty-state {
  margin-top: 3rem;
  padding: 3rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 0.9rem;
  background: var(--card);
}
.empty-state h2 { font-size: 1.5rem; }
.empty-state p { color: var(--muted); margin: 0.7rem auto 1.4rem; max-width: 30rem; }

/* ---------- Detail dialog ---------- */

.detail {
  border: none;
  padding: 0;
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  width: min(880px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  overscroll-behavior: contain;
  box-shadow: 0 24px 60px rgba(38, 32, 26, 0.28);
}
.detail::backdrop {
  background: rgba(38, 32, 26, 0.55);
}
.detail-frame {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  max-height: calc(100dvh - 2rem);
}
.detail-media {
  background: var(--clay-soft);
  min-height: 100%;
}
.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-body {
  padding: 2.2rem 2rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.detail-body h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-top: 0.35rem; }
.detail-desc { color: var(--muted); margin: 0.8rem 0 1.4rem; }

.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1.2rem;
  margin: 0 0 1.6rem;
  padding: 1.1rem 1.2rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}
.detail-facts > div { min-width: 0; }
.detail-facts dt {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.detail-facts dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

.detail-actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.btn-save { min-width: 15rem; justify-content: center; }
.shortlist-note { margin: 0; font-size: 0.78rem; color: var(--muted); }

.detail-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.42rem 0.85rem 0.42rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.detail-close:hover { border-color: var(--clay); color: var(--clay-deep); }
.detail-close svg { width: 12px; height: 12px; }

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

.footer {
  border-top: 1px solid var(--line);
  padding: 2.2rem 1.5rem 2.6rem;
  text-align: center;
  color: var(--muted);
}
.footer-word {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.4rem;
}
.footer p { margin: 0 auto; max-width: 36rem; font-size: 0.85rem; }

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

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 1.6rem; padding-top: 1.8rem; }
  .detail-frame { grid-template-columns: 1fr; overflow-y: auto; overscroll-behavior: contain; }
  .detail-media { aspect-ratio: 16 / 10; min-height: 0; }
  .detail-body { overflow: visible; padding: 1.6rem 1.4rem 1.8rem; }
}

@media (max-width: 640px) {
  .masthead-inner { padding: 0.9rem 1.1rem 0.8rem; }
  .hero, main { padding-left: 1.1rem; padding-right: 1.1rem; }
  .grid li { scroll-margin-top: 15rem; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 0.7rem; padding: 0.8rem 0 0.9rem; }
  .field input, .field select { width: 100%; }
  .saved-toggle { justify-content: center; }
  .result-count { margin: 0; }
  .grid { grid-template-columns: 1fr; gap: 1.2rem; }
  .detail-facts { grid-template-columns: 1fr 1fr; }
  .btn-save { width: 100%; }
}

/* Safe areas for full-bleed edges on notched devices */
@supports (padding: env(safe-area-inset-left)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .grid li:hover .card { transform: none; }
}
