@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/dm-sans.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("fonts/playfair-display.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/playfair-display-italic.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --ink: #242821;
  --muted: #77796f;
  --faint: #a4a399;
  --tag-ink: #66685e;
  --paper: #faf9f6;
  --surface: #fff;
  --placeholder: #eeeae3;
  --line: #e7e4dc;
  --line-soft: #f0eee9;
  --line-hover: #d8c9bb;
  --accent: #a34e38;
  --accent-soft: #f3e9e2;
  --accent-ink: #713b2b;
  --focus: #c49a89;
  --focus-ring: #a34e3814;
  --shadow: #3a29100c;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Follows the browser or system preference (e.g. phone dark mode). */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9e5dc;
    --muted: #a3a095;
    --faint: #75766c;
    --tag-ink: #bdbaaf;
    --paper: #181a16;
    --surface: #22251f;
    --placeholder: #2d3029;
    --line: #363a31;
    --line-soft: #2d3029;
    --line-hover: #5c4b40;
    --accent: #e0896d;
    --accent-soft: #3d2a22;
    --accent-ink: #f2bba7;
    --focus: #8f5c49;
    --focus-ring: #e0896d26;
    --shadow: #00000066;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.site-footer {
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.site-footer a {
  text-decoration: underline;
}

.recipe-index {
  width: min(100% - 36px, 1040px);
  margin: 0 auto;
  padding: 34px 0 64px;
}

.recipe-index h1 {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.04;
}

.search-box {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.search-box > span {
  font-size: 1.5rem;
  line-height: 1;
}

.search-box input {
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.search-box:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
}

.tag-cloud-item,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--tag-ink);
  font-size: calc(1rem * var(--tag-weight, 1));
  line-height: 1.2;
}

.tag-cloud-item {
  padding: 7px 11px;
  cursor: pointer;
}

.tag-cloud-item [data-tag-count] {
  margin-left: 4px;
  color: var(--faint);
  font-size: 0.75rem;
}

.tag-cloud-item:hover,
.tag-cloud-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.recipe-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.recipe-card {
  position: relative;
  min-width: 0;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.recipe-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-hover);
  box-shadow: 0 12px 32px var(--shadow);
}

.recipe-card:hover .card-image {
  opacity: 1;
}

.recipe-card > a {
  width: 100%;
  min-width: 0;
  min-height: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
}

.card-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: stretch;
}

.recipe-card.has-image > a {
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 14px 14px 20px;
}

.recipe-card.has-image .card-body {
  padding-top: 6px;
}

.card-image {
  width: 112px;
  aspect-ratio: 1;
  flex: none;
  border-radius: 8px;
  background: var(--placeholder);
  object-fit: cover;
  opacity: 0.8;
}

.recipe-card.has-image .card-arrow {
  display: none;
}

.recipe-card.has-image h2 {
  max-width: none;
}

.recipe-card h2 {
  max-width: calc(100% - 28px);
  overflow-wrap: anywhere;
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.card-excerpt {
  overflow: hidden;
  align-self: stretch;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  position: absolute;
  top: 17px;
  right: 19px;
  color: var(--faint);
  font-size: 1rem;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.tag {
  display: inline-block;
  padding: 5px 9px;
  font-size: 1rem;
}

.recipe-card .tag {
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 3px 8px;
  font-size: 0.8rem;
}

.recipe-card .recipe-tags {
  align-self: stretch;
  min-width: 0;
}

@media (max-width: 480px) {
  .recipe-card {
    min-height: 0;
  }

  .recipe-card.has-image > a {
    gap: 12px;
    padding: 10px 12px;
    align-items: stretch;
  }

  .recipe-card.has-image .card-body {
    padding-top: 2px;
  }

  .card-image {
    width: 88px;
    aspect-ratio: auto;
  }

  .recipe-card h2 {
    margin-bottom: 4px;
    font-size: 1.75rem;
  }

  .card-excerpt {
    margin-bottom: 8px;
  }

  .recipe-card .tag {
    padding: 2px 7px;
  }
}

.recipe-page {
  width: min(100% - 36px, 760px);
  margin: 0 auto;
  padding: 14px 0 60px;
}

.detail-nav {
  display: flex;
  justify-content: space-between;
  width: min(100% - 36px, 760px);
  margin: 0 auto;
  padding-top: 12px;
}

.detail-nav a {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 1.25rem;
}

.recipe h1 {
  margin: 14px 0 14px;
  font-family: var(--serif);
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.04;
}

.recipe-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 28px;
}

.recipe-properties {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin: 0 0 0 5px;
  flex: 1 1 auto;
}

.recipe-meta-row .recipe-tags {
  justify-content: flex-end;
  margin: 0 0 0 auto;
}

.ingredients-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recipe-property {
  display: grid;
  gap: 1px;
}

.recipe-property dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.recipe-property dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.ingredients {
  margin: 0 0 32px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.ingredients-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.simple-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
}

.simple-toggle[hidden] {
  display: none;
}

.simple-toggle input {
  position: relative;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: 10px;
  background: var(--line);
  appearance: none;
  cursor: pointer;
  transition: background 0.15s;
}

.simple-toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.15s;
}

.simple-toggle input:checked {
  background: var(--accent);
}

.simple-toggle input:checked::after {
  transform: translateX(16px);
}

.simple-toggle input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.simple-toggle input:checked + span {
  color: var(--ink);
}

.servings {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 1.3rem;
}

.servings button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
}

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

.servings > span {
  min-width: 32px;
  text-align: center;
}

#ingredient-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

#ingredient-list li {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 1rem;
}

.recipe-content {
  font-size: 1rem;
}

.recipe-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.recipe-content a:hover {
  text-decoration-thickness: 3px;
}

.recipe-content h1,
.recipe-content h2,
.recipe-content h3 {
  margin: 30px 0 10px;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.recipe-content em {
  font-style: normal;
  font-weight: 500;
}

.recipe-content p {
  margin: 0 0 16px;
}

.recipe-content li {
  margin: 5px 0;
}

.recipe-content [data-ingredient] {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.recipe-main-image {
  overflow: hidden;
  margin: 0 0 32px;
  border-radius: 10px;
  background: var(--placeholder);
}

.recipe-main-image img {
  width: 100%;
  height: clamp(220px, 45vw, 420px);
  display: block;
  object-fit: cover;
  object-position: center;
}

/* Column masonry: images keep their natural ratio, no cropping, no blank space.
   Multi-column layout as the baseline, CSS grid-lanes where supported (keeps reading order). */
.recipe-step-images,
.recipe-gallery {
  column-gap: 12px;
}

.recipe-step-images {
  margin: 4px 0 12px;
}

.recipe-gallery {
  margin: 30px 0 18px;
}

.recipe-step-images figure,
.recipe-gallery figure {
  overflow: hidden;
  margin: 0 0 12px;
  border-radius: 10px;
  background: var(--placeholder);
  break-inside: avoid;
}

.recipe-step-images img,
.recipe-gallery img {
  width: 100%;
  height: auto;
  display: block;
}

@supports (display: grid-lanes) {
  .recipe-step-images,
  .recipe-gallery {
    display: grid-lanes;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .recipe-step-images {
    margin-bottom: 24px;
  }

  .recipe-gallery {
    margin-bottom: 30px;
  }

  .recipe-step-images figure,
  .recipe-gallery figure {
    margin: 0;
  }
}

.visually-hidden {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (min-width: 680px) {
  .recipe-index {
    padding-top: 52px;
  }

  .recipe-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .recipe-page {
    padding-top: 30px;
  }

  .ingredients {
    padding: 22px 26px;
  }

  #ingredient-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
  }

  /* Two columns only when there is more than one image. */
  .recipe-step-images:has(figure + figure),
  .recipe-gallery:has(figure + figure) {
    columns: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
