/* ==========================================================================
   Carafe & Gilt — home page layout
   Masthead, hero (thesis + search action), category pills, "recently added"
   grid and footer. Loaded after tokens.css and card.css. The recipe card
   itself lives in card.css (shared with the future Browse page).
   Masthead/footer intentionally mirror the recipe page (recipe.css) so the
   home page reads as the same site.
   ========================================================================== */

/* ---- Masthead (mirrors recipe.css .site-header) ------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .bar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4); max-width: var(--container); margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 0.7rem; margin-right: auto; text-decoration: none; }
.brand .name { font-family: var(--font-display); font-size: 1.3rem; color: var(--display-ink); }
.nav { display: flex; gap: var(--sp-3); }
.nav a { text-decoration: none; font-size: var(--fs-sm); color: var(--text-muted); }
.nav a:hover { color: var(--gold); }
/* Icon buttons: the sun/moon theme toggle and (mobile-only) hamburger. */
.toggle, .menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; color: var(--text); background: transparent;
  border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.toggle:hover, .menu-btn:hover { border-color: var(--gold); color: var(--gold); }
.toggle svg { width: 18px; height: 18px; }
.menu-btn { display: none; }          /* revealed at the mobile breakpoint below */
.menu-btn svg { width: 20px; height: 20px; }
.nav a[aria-current="page"] { color: var(--gold); }

/* ---- Hero --------------------------------------------------------------- */
.home-hero {
  text-align: center;
  padding: var(--sp-6) 0 var(--sp-5);
}
/* Mark + flanking rules. The mark draws itself in first (Form A entrance);
   once it finishes (~2.4s) the two gold rules trace OUTWARD from the mark
   toward each edge. */
.home-hero .markrow {
  display: flex; align-items: center; justify-content: center;
  gap: 22px; margin: 0 auto var(--sp-4);
}
.home-hero .mark { overflow: visible; display: block; }
.home-hero .mark path {
  stroke: var(--mark-ink); stroke-width: 4; fill: none; stroke-linejoin: miter;
  stroke-dasharray: 340; stroke-dashoffset: 340;
  animation: cg-draw .5s ease-in-out .3s forwards;  /* a touch slower than the .35s rules */
}
.home-hero .mark path:nth-child(2) { animation-delay: .52s; }
.home-hero .mark path:nth-child(3) { animation-delay: .74s; }
@keyframes cg-draw { to { stroke-dashoffset: 0; } }

.home-hero .line {
  height: 1px; width: 120px; background: var(--gold); opacity: 0.8;
  transform: scaleX(0);                 /* collapsed at the mark, then grows outward */
  animation: cg-line .35s ease-out .8s forwards;  /* quick trace, overlaps the mark drawing */
}
.home-hero .line--left { transform-origin: right center; }   /* traces leftward */
.home-hero .line--right { transform-origin: left center; }   /* traces rightward */
@keyframes cg-line { to { transform: scaleX(1); } }

.home-hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--display-ink);
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  line-height: 1.03;
  letter-spacing: 0.01em;
  margin: 0 auto;
  max-width: 16ch;
}
.home-lead {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  line-height: 1.6;
  color: var(--text);
  max-width: 46ch;
  margin: var(--sp-4) auto 0;
}

/* ---- Search (the hero action) ------------------------------------------- */
.home-search {
  display: flex;
  align-items: stretch;
  gap: 0;
  max-width: 540px;
  margin: var(--sp-5) auto 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  transition: border-color var(--transition);
}
.home-search:focus-within { border-color: var(--gold); }
.home-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-lg);
  padding: 0.9em 1.1em;
}
.home-search input::placeholder { color: var(--text-muted); }
.home-search input:focus { outline: none; }
.home-search button {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 0.5em;
  font-family: var(--font-caption); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: var(--fs-xs);
  background: var(--gold); color: var(--on-gold);
  border: 0; padding: 0 1.4em; cursor: pointer;
  transition: filter var(--transition);
}
.home-search button:hover { filter: brightness(1.07); }

/* ---- Category pills ----------------------------------------------------- */
.home-pills {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--sp-2);
  margin: var(--sp-4) auto 0;
}
.pill {
  font-family: var(--font-caption); text-transform: uppercase; letter-spacing: 0.16em;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.55em 1.1em;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.pill:hover { color: var(--gold); border-color: var(--gold); }
/* Active pill = solid gold fill (used on Browse when a category is selected). */
.pill.is-active {
  background: var(--gold);
  color: var(--on-gold);
  border-color: var(--gold);
}
.pill.is-active:hover { color: var(--on-gold); }

/* ---- Recently added ----------------------------------------------------- */
.home-recent {
  padding: var(--sp-6) 0 var(--sp-5);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-6);
}
.home-recent-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.home-recent-head .cg-label { margin: 0; }

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);   /* 3-up desktop */
  gap: var(--sp-4);
}
@media (max-width: 860px) {
  .recipe-grid { grid-template-columns: repeat(2, 1fr); }  /* 2-up tablet */
}
@media (max-width: 560px) {
  .recipe-grid { grid-template-columns: 1fr; }             /* 1-up mobile */
}

/* Chronological pager — home shows 15 (3×5) newest-first per page, with
   Prev/Next so visitors can walk back through the collection by date. Reused by
   the My-shelf page (also loads home.css). */
.feed-pager {
  display: flex; align-items: center; justify-content: center;
  gap: var(--sp-4); margin-top: var(--sp-5);
}
.feed-pager[hidden] { display: none; }
.feed-pager button {
  font-family: var(--font-caption); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: var(--fs-xs); color: var(--text);
  background: transparent; border: 1px solid var(--border-strong);
  padding: 0.6em 1.1em; cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.feed-pager button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.feed-pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.feed-status {
  font-family: var(--font-caption); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: var(--fs-xs); color: var(--text-muted);
}

/* "Browse all" — the gateway to filtered/searchable Browse. */
.browse-all { text-align: center; margin-top: var(--sp-5); }
.browse-all[hidden] { display: none; }

/* ---- Footer (mirrors recipe.css footer) --------------------------------- */
.home-footer { padding: var(--sp-6) 0; }

@media (max-width: 640px) {
  /* Nav collapses behind the hamburger. Open, it drops down as a full-bar panel. */
  .site-header .bar { position: relative; }
  .menu-btn { display: inline-flex; }
  .nav { display: none; }
  .site-header.menu-open .nav {
    display: flex; flex-direction: column; gap: 0;
    position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
    background: var(--surface); border: 1px solid var(--border-strong);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  }
  .site-header.menu-open .nav a {
    padding: var(--sp-3) var(--sp-4); font-size: var(--fs-lg); color: var(--text);
    border-bottom: 1px solid var(--border);
  }
  .site-header.menu-open .nav a:last-child { border-bottom: 0; }
  .site-header.menu-open .nav a:hover,
  .site-header.menu-open .nav a[aria-current="page"] { color: var(--gold); }
}

@media (prefers-reduced-motion: reduce) {
  .home-hero .mark path { animation: none; stroke-dashoffset: 0; }
  .home-hero .line { animation: none; transform: none; }
}
