/* ===========================================================================
   Homepage layout and components (M6-S2, site shell extracted M6-S3)

   Scope: homepage-only composition — hero, recipe library, and the "how these
   recipes are written" section. The shared site header and footer live in
   css/site.css, which every page loads.

   This file adds no color values of its own. Recipe cards carry the existing
   data-recipe-accent attribute, so each card inherits the accent role tokens
   declared in css/tokens.css in every theme state, with no token change.
   =========================================================================== */

.home {
  /* Homepage-only shell width. Shared with the recipe page shell so both
     pages sit in the same column at desktop widths. */
  --home-max-width: var(--content-width-page);
  --home-display-font: var(--font-serif);

  /* The shared shell in css/site.css centres the header and footer on
     --site-max-width. The homepage points it at the library width so the
     shell and the content sit in one column. */
  --site-max-width: var(--home-max-width);
  --section-gap: var(--space-2xl);
}

.home-main {
  max-width: var(--home-max-width);
  margin-inline: auto;
}

/* ---------------------------------------------------------------------------
   Hero
   --------------------------------------------------------------------------- */

.home-hero {
  padding-block: var(--space-2xl);
  border-bottom: 1px solid var(--color-border);
}

.home-hero-eyebrow {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.home-hero-title {
  font-family: var(--home-display-font);
  font-size: var(--font-size-display);
  line-height: 1.08;
  letter-spacing: -0.015em;
  max-width: 46rem;
  margin-bottom: var(--space-lg);
  text-wrap: balance;
  /* A display-sized word must break rather than run past the viewport. */
  overflow-wrap: break-word;
}

.home-hero-lede {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
  max-width: 34rem;
}

.home-hero-actions {
  margin-bottom: 0;
}

.home-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--control-height-lg);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--color-text);
  border-radius: var(--radius-md);
  background-color: var(--color-text);
  color: var(--color-bg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transition: background-color 180ms ease-out, color 180ms ease-out;
}

.home-cta:hover,
.home-cta:focus-visible {
  background-color: transparent;
  color: var(--color-text);
  text-decoration: none;
}

.home-cta:focus {
  outline: none;
}

.home-cta:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

.home-cta-arrow {
  transition: transform 180ms ease-out;
}

.home-cta:hover .home-cta-arrow,
.home-cta:focus-visible .home-cta-arrow {
  transform: translateX(4px);
}

/* ---------------------------------------------------------------------------
   Section headings
   --------------------------------------------------------------------------- */

.section-title {
  margin-top: 0;
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

/* ---------------------------------------------------------------------------
   Recipe library
   --------------------------------------------------------------------------- */

.recipe-library,
.home-principles {
  padding-block: var(--space-xl);
  /* An anchor target should not land flush against the viewport edge. */
  scroll-margin-top: var(--space-lg);
}

.recipe-library {
  padding-top: var(--space-2xl);
}

.recipe-grid,
.principle-grid {
  display: grid;
  gap: var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The single-column base track is explicit. An implicit auto track is sized by
   its content's min-content width, so at large text scales one long unbreakable
   recipe name could push the track — and the page — wider than the viewport. */
.recipe-grid {
  grid-template-columns: minmax(0, 1fr);
}

.recipe-grid-item,
.principle {
  margin: 0;
  display: flex;
}

/* --- Recipe card ------------------------------------------------------- */

.recipe-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: background-color 180ms ease-out, border-color 180ms ease-out,
    transform 180ms ease-out;
}

.recipe-card:hover,
.recipe-card:focus-visible {
  background-color: var(--color-accent-tint);
  border-color: var(--color-accent-soft);
  transform: translateY(-2px);
  text-decoration: none;
}

.recipe-card:focus {
  outline: none;
}

.recipe-card:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

.recipe-card-rule {
  display: block;
  width: 2.5rem;
  height: 3px;
  border-radius: var(--radius-sm);
  background-color: var(--color-accent);
  transition: width 180ms ease-out;
}

.recipe-card:hover .recipe-card-rule,
.recipe-card:focus-visible .recipe-card-rule {
  width: 3.5rem;
}

.recipe-card-index {
  display: block;
  margin-top: var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--font-size-lg);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--color-accent-strong);
}

.recipe-card-kicker {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent-strong);
}

.recipe-card-title {
  margin: var(--space-sm) 0 0 0;
  font-family: var(--home-display-font);
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--color-text);
  text-wrap: balance;
  /* A display-sized recipe name must never outrun its card at large text
     scales. `anywhere` rather than `break-word` because this heading is a
     flex item under align-items: flex-start — its width resolves to its
     min-content size, which only `anywhere` reduces below the longest word. */
  overflow-wrap: anywhere;
}

.recipe-card-description {
  display: block;
  margin-top: var(--space-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-muted);
}

.recipe-card-meta {
  display: inline-block;
  margin-top: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.recipe-card-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  /* Pinned to the bottom so cards in a row line up regardless of copy length. */
  margin-top: auto;
  padding-top: var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent-strong);
}

.recipe-card-arrow {
  transition: transform 180ms ease-out;
}

.recipe-card:hover .recipe-card-arrow,
.recipe-card:focus-visible .recipe-card-arrow {
  transform: translateX(4px);
}

/* ---------------------------------------------------------------------------
   How these recipes are written
   --------------------------------------------------------------------------- */

.home-principles {
  border-top: 1px solid var(--color-border);
  padding-top: var(--section-gap);
}

.principle {
  flex-direction: column;
}

.principle-title {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.principle-body {
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   Responsive steps

   320 / 375 / 430 — one column
   768             — library 2 columns, principles 2 columns
   1024 / 1440     — library stays 2 columns, principles 4 columns
   --------------------------------------------------------------------------- */

@media (max-width: 374px) {
  .recipe-card {
    padding: min(var(--space-md), 4vw);
  }
}

@media (min-width: 768px) {
  .home {
    --section-gap: var(--space-3xl);
  }

  .home-hero {
    padding-block: var(--space-3xl);
  }

  .recipe-library,
  .home-principles {
    padding-block: var(--space-2xl);
  }

  .recipe-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-xl);
  }

  .principle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-xl);
  }

  .recipe-card {
    padding: var(--space-xl);
  }
}

/* `em` so the split collapses when the reader's text size makes the two
   columns too narrow for the display title, like the recipe title band. */
@media (min-width: 64em) {
  .home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    column-gap: var(--space-3xl);
    grid-template-areas:
      "eyebrow eyebrow"
      "title lede"
      "title actions";
    align-items: end;
  }

  .home-hero-eyebrow {
    grid-area: eyebrow;
  }

  .home-hero-title {
    grid-area: title;
  }

  .home-hero-lede {
    grid-area: lede;
    margin-bottom: var(--space-lg);
  }

  .home-hero-actions {
    grid-area: actions;
  }
}

@media (min-width: 75em) {
  .principle-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------------------------
   Reduced motion — transforms and transitions go; state indication stays.
   --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .home-cta,
  .home-cta-arrow,
  .recipe-card,
  .recipe-card-rule,
  .recipe-card-arrow {
    transition: none;
  }

  .recipe-card:hover,
  .recipe-card:focus-visible {
    transform: none;
  }

  .home-cta:hover .home-cta-arrow,
  .home-cta:focus-visible .home-cta-arrow,
  .recipe-card:hover .recipe-card-arrow,
  .recipe-card:focus-visible .recipe-card-arrow {
    transform: none;
  }

  .recipe-card:hover .recipe-card-rule,
  .recipe-card:focus-visible .recipe-card-rule {
    width: 2.5rem;
  }
}

/* ---------------------------------------------------------------------------
   Print — the homepage is not a print target. Keep the library legible as a
   plain list and drop the page furniture.
   --------------------------------------------------------------------------- */

@media print {
  .home-hero,
  .home-principles,
  .recipe-card-rule,
  .recipe-card-cta {
    display: none;
  }

  .recipe-grid {
    display: block;
  }

  .recipe-card {
    border: 0;
    padding: 0;
    margin-bottom: 12pt;
    page-break-inside: avoid;
  }

  .recipe-card-title {
    font-size: 14pt;
  }
}
