/* ---------- tokens ---------- */
:root {
  --ink: #14161a;
  --ink-soft: #52565f;
  --paper: #eef0f2;
  --surface: #ffffff;
  --line: rgba(20, 22, 26, 0.12);
  --line-strong: rgba(20, 22, 26, 0.22);
  --accent: #c0264f;
  --accent-ink: #ffffff;
  --shadow-color: 20, 22, 26;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  --max-width: 1280px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f1ee;
    --ink-soft: #b7bac2;
    --paper: #101114;
    --surface: #18191d;
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.22);
    --accent: #ff6f96;
    --accent-ink: #14161a;
    --shadow-color: 0, 0, 0;
  }
}

/* ---------- reset ---------- */
* {
  box-sizing: border-box;
}

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, p, dl, dd {
  margin: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

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

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

/* ---------- layout helpers ---------- */
.header-inner,
.hero-inner,
.catalog,
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.header-tagline {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .header-tagline {
    display: none;
  }
}

/* ---------- hero ---------- */
.hero {
  padding-top: 48px;
  padding-bottom: 56px;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
}

.hero-copy h1 {
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero-copy p {
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 42ch;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  margin-top: 28px;
  padding: 13px 26px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  box-shadow: 0 8px 20px -8px rgba(var(--shadow-color), 0.4);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.hero-media {
  position: relative;
}

.hero-media::before {
  content: "";
  position: absolute;
  inset: 20px -20px -20px 20px;
  background: var(--accent);
  border-radius: var(--radius-lg);
  z-index: 0;
}

.hero-media img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 340px;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .hero-media::before {
    inset: 14px -14px -14px 14px;
  }

  .hero-media img {
    height: 240px;
  }
}

/* ---------- catalog ---------- */
.catalog {
  padding-bottom: 80px;
}

.catalog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.catalog-head h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.results-count {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 32px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field-search {
  flex: 1 1 240px;
}

.field-filter {
  flex: 0 1 200px;
}

.field input,
.field select {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: var(--font-sans);
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field input::placeholder {
  color: var(--ink-soft);
  opacity: 0.85;
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.pill-toggle .icon-heart {
  width: 16px;
  height: 16px;
}

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

.pill-toggle:active {
  transform: scale(0.97);
}

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

.pill-toggle[aria-pressed="true"] .icon-heart path {
  fill: currentColor;
}

@media (max-width: 640px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .field-filter {
    flex-basis: auto;
  }

  .pill-toggle {
    justify-content: center;
  }
}

/* ---------- empty state ---------- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  margin-bottom: 32px;
}

.empty-state p {
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.empty-state button {
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
}

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

/* ---------- grid / cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  opacity: 0;
  animation: cardIn 0.4s ease-out forwards;
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px -18px rgba(var(--shadow-color), 0.35);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.card:hover .card-media img {
  transform: scale(1.04);
}

.card-icon {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--shadow-color), 0.55);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-pill);
  color: #fff;
}

.card-icon svg {
  width: 18px;
  height: 18px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  flex: 1;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.card-desc {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-facts {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
}

.card-facts dt {
  font-size: 0.68rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-open {
  margin-top: auto;
  padding-top: 14px;
  border: none;
  background: none;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}

.btn-open::after {
  content: "\2192";
  transition: transform 0.15s ease;
}

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

.btn-open:hover::after {
  transform: translateX(3px);
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0 48px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.brand-name-small {
  color: var(--ink);
  font-size: 1rem;
}

.copyright {
  margin-left: auto;
}

/* ---------- detail dialog ---------- */
.detail {
  width: min(680px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}

.detail::backdrop {
  background: rgba(var(--shadow-color), 0.55);
}

.detail-inner {
  max-height: min(88vh, 760px);
  overflow-y: auto;
}

@media (prefers-reduced-motion: no-preference) {
  .detail[open] .detail-inner {
    animation: detailIn 0.28s ease-out;
  }
}

@keyframes detailIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-pill);
  background: rgba(var(--shadow-color), 0.55);
  color: #fff;
  cursor: pointer;
  z-index: 2;
}

.detail-close svg {
  width: 16px;
  height: 16px;
}

.detail-media {
  aspect-ratio: 16 / 9;
}

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

.detail-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-category {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.detail-body h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 16px;
  padding: 16px;
  background: var(--paper);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.detail-facts dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

.detail-facts dd {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
}

@media (max-width: 480px) {
  .detail-facts {
    grid-template-columns: repeat(2, 1fr);
  }
}

.detail-desc {
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 60ch;
}

#saveItemBtn {
  align-self: flex-start;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

#saveItemBtn:hover {
  border-color: var(--accent);
}

#saveItemBtn:active {
  transform: scale(0.97);
}

#saveItemBtn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

#saveItemBtn[aria-pressed="true"] .icon-heart path {
  fill: currentColor;
}

.icon-heart {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ---------- reduced motion override ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .card {
    opacity: 1;
  }
}
