/* ==========================================================================
   editorial-memoir / layout.css
   Direction A "Editorial Memoir" -- magazine-grade, warm, near-monochrome.
   Consumes only tokens from tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;          /* belt + suspenders; real fixes below */
}

/* faint engraved paper grain for atmosphere (kept very light) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(176,122,79,.05), transparent 38%),
    radial-gradient(circle at 86% 78%, rgba(201,120,142,.05), transparent 42%);
}

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

a { color: var(--rose-deep); text-decoration-thickness: 1px; text-underline-offset: .18em;
    transition: color var(--fast) var(--ease); }
a:hover { color: var(--ink); }

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

/* ---------- layout primitives ------------------------------------------ */

.bleed { width: 100%; }                 /* full-bleed band */
.wrap  { width: var(--container); margin-inline: auto; }

.band--paper2 { background: var(--paper-2); }
.band--paper3 { background: var(--paper-3); }

/* ---------- editorial kicker system ------------------------------------ */

.kicker {
  font-family: var(--body);
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: var(--tr-kicker);
  text-transform: uppercase;
  color: var(--copper);
  display: inline-flex;
  align-items: center;
  gap: .7em;
  margin: 0;
}
.kicker::before {
  content: "";
  width: 1.8rem;
  height: 1px;
  background: var(--copper);
  display: inline-block;
}
.kicker--plain::before { display: none; }

/* ---------- typography -------------------------------------------------- */

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
  color: var(--ink);
  margin: 0;
  font-optical-sizing: auto;
}

.serif-italic { font-family: var(--display); font-style: italic; font-weight: 400; }

/* ==========================================================================
   MASTHEAD / top bar
   ========================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--hair);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); padding-block: .85rem;
}
.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: var(--tr-tight);
  color: var(--ink);
  text-decoration: none;
  display: inline-flex; align-items: baseline; gap: .5rem;
}
.wordmark b { font-weight: 600; }
.wordmark span {
  font-family: var(--body); font-size: .62rem; font-weight: 600;
  letter-spacing: var(--tr-kicker); text-transform: uppercase;
  color: var(--copper); transform: translateY(-1px);
}
.topnav { display: flex; gap: clamp(1rem, 2.4vw, 2.2rem); align-items: center; }
.topnav a {
  font-size: var(--fs-meta); font-weight: 500; color: var(--ink-2);
  text-decoration: none; letter-spacing: .01em;
}
.topnav a:hover { color: var(--ink); }
.topnav a.is-cta {
  color: var(--rose-deep); font-weight: 600;
}
@media (max-width: 640px) {
  .topnav .hide-sm { display: none; }
}

/* ==========================================================================
   HERO
   ========================================================================== */

/* Split editorial hero (full-bleed section). Text sits on clean warm paper in
   the container's left half; the photo fills the right half all the way to the
   viewport edge. Overflow-proof: the section is full width and the grid simply
   divides it, no negative margins. */
.hero { position: relative; background: var(--paper); overflow: hidden; }
.hero__grid {
  display: grid;
  grid-template-columns:
    minmax(var(--gutter-l), 1fr)
    minmax(0, calc(var(--half) - var(--gutter-l)))
    minmax(0, var(--half));
  align-items: stretch;
  --half: calc(min(92%, 1680px) / 2);
  --gutter-l: calc((100% - min(92%, 1680px)) / 2);
}
.hero__text {
  grid-column: 2 / 3;
  display: grid; align-content: center; gap: clamp(1.1rem, 2.2vw, 1.8rem);
  padding-block: clamp(3rem, 8vw, 6.2rem);
  padding-right: clamp(1.5rem, 3vw, 3rem);
}
.hero__title {
  font-size: var(--fs-mast);
  font-weight: 500;
  line-height: .96;
  letter-spacing: -0.028em;
}
.hero__title em { font-style: italic; font-weight: 400; color: var(--rose-deep); }
.hero__lede {
  font-family: var(--display); font-style: italic; font-weight: 400;
  font-size: clamp(1.08rem, 1.6vw, 1.42rem);
  color: var(--ink-2); line-height: var(--lh-snug); max-width: 36ch;
  margin: 0;
}
.hero__media {
  grid-column: 3 / 4;
  position: relative; overflow: hidden;
  background: var(--paper-3);
  min-height: clamp(20rem, 40vw, 36rem);
}
.hero__media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  filter: saturate(1.04);
}
.hero__media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, var(--paper) 0%, rgba(251,248,244,0) 9%),
    radial-gradient(120% 90% at 85% 15%, transparent, rgba(43,39,36,.07) 100%);
}
.hero__credit {
  position: absolute; left: 1.1rem; bottom: 1.1rem; z-index: 2;
  font-family: var(--body); font-size: .68rem; font-weight: 600;
  letter-spacing: var(--tr-wide); text-transform: uppercase; color: var(--ink);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  padding: .3rem .7rem; border-radius: var(--r-pill); backdrop-filter: blur(4px);
}
@media (max-width: 860px) {
  .hero__grid { display: block; }
  .hero__media {
    width: 100%; min-height: clamp(15rem, 62vw, 23rem);
  }
  .hero__media::after { background: radial-gradient(120% 90% at 85% 15%, transparent, rgba(43,39,36,.07) 100%); }
  .hero__text {
    width: var(--container); margin-inline: auto;
    padding-block: clamp(1.8rem, 6vw, 3rem); padding-right: 0;
  }
}

/* search box */
.search {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-pill);
  padding: .5rem .5rem .5rem 1.1rem;
  max-width: 30rem;
  box-shadow: var(--shadow-card);
}
.search svg { width: 1.1rem; height: 1.1rem; color: var(--ink-3); flex: none; }
.search input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: var(--body); font-size: var(--fs-base); color: var(--ink);
  padding-block: .35rem;
}
.search input::placeholder { color: var(--ink-3); }
.search button {
  border: 0; cursor: pointer; font-family: var(--body); font-weight: 600;
  font-size: var(--fs-sm); color: var(--paper); background: var(--rose-deep);
  border-radius: var(--r-pill); padding: .55rem 1.2rem;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.search button:hover { background: var(--ink); transform: translateY(-1px); }

/* ==========================================================================
   PILL RAIL (collection chips)
   ========================================================================== */

.railband { border-block: 1px solid var(--hair); background: var(--paper); }
.pillrail {
  display: flex; gap: .55rem; align-items: center;
  padding-block: 1rem;
  overflow-x: auto; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.pillrail::-webkit-scrollbar { height: 6px; }
.pillrail::-webkit-scrollbar-thumb { background: var(--hair-strong); border-radius: 99px; }
.pill {
  flex: none; cursor: pointer; white-space: nowrap;
  font-family: var(--body); font-size: var(--fs-sm); font-weight: 500;
  color: var(--ink-2); background: var(--card);
  border: 1px solid var(--hair-strong); border-radius: var(--r-pill);
  padding: .5rem 1.05rem;
  transition: all var(--fast) var(--ease);
}
.pill:hover { color: var(--ink); border-color: var(--copper-soft); }
.pill.is-active {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.pill .dot { color: var(--copper); margin-right: .1rem; }

/* ==========================================================================
   EDITORIAL SHELVES (horizontal scroll-snap rows)
   ========================================================================== */

.shelf { padding-block: var(--block) 0; }
.shelf:last-of-type { padding-bottom: var(--block); }

.shelf__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--gap); margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--copper);
  padding-bottom: 1rem;
}
.shelf__headings { display: grid; gap: .5rem; }
.shelf__no {
  font-family: var(--display); font-style: italic; font-weight: 400;
  font-size: var(--fs-sm); color: var(--copper);
}
.shelf__title {
  font-size: var(--fs-xl); font-weight: 500; line-height: 1;
}
.shelf__dek {
  font-family: var(--display); font-style: italic; font-size: var(--fs-md);
  color: var(--ink-2); line-height: var(--lh-snug); margin: 0; max-width: 48ch;
}
.seeall {
  flex: none; font-family: var(--body); font-size: var(--fs-meta); font-weight: 600;
  letter-spacing: var(--tr-wide); text-transform: uppercase;
  color: var(--rose-deep); text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: gap var(--fast) var(--ease), color var(--fast) var(--ease);
}
.seeall:hover { color: var(--ink); gap: .7rem; }

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(min(78%, 280px), 1fr);
  gap: var(--gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: .6rem;
  margin-inline: calc(-1 * var(--gap));
  padding-inline: var(--gap);
}
.rail::-webkit-scrollbar { height: 6px; }
.rail::-webkit-scrollbar-thumb { background: var(--hair-strong); border-radius: 99px; }
.rail > * { scroll-snap-align: start; }

@media (min-width: 760px) {
  .rail { grid-auto-columns: minmax(0, 1fr); grid-template-columns: repeat(4, 1fr);
          grid-auto-flow: row; overflow: visible; margin-inline: 0; padding-inline: 0; }
  .rail.shelf--five { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1280px) {
  .rail.shelf--six { grid-template-columns: repeat(6, 1fr); }
}

/* ==========================================================================
   CARD (shared by shelves + grid)
   ========================================================================== */

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: transparent;
  text-decoration: none; color: inherit;
  border-radius: var(--r-md);
}
.card__frame {
  position: relative; overflow: hidden;
  border-radius: var(--r-md);
  aspect-ratio: var(--crop);
  background: var(--paper-3);
  box-shadow: var(--shadow-card);
}
.card__frame img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform var(--base) var(--ease);
}
.card__rank {
  position: absolute; top: .7rem; left: .7rem; z-index: 2;
  font-family: var(--display); font-weight: 500; font-size: 1.4rem;
  line-height: 1; color: var(--paper);
  text-shadow: 0 1px 6px rgba(43,39,36,.5);
}
.card__fav {
  position: absolute; top: .7rem; right: .7rem; z-index: 2;
  width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border-radius: 50%; color: var(--rose-deep);
  box-shadow: var(--shadow-card);
}
.card__fav svg { width: 1rem; height: 1rem; }
.card__cuisine {
  position: absolute; left: .7rem; bottom: .7rem; z-index: 2;
  font-family: var(--body); font-size: .68rem; font-weight: 600;
  letter-spacing: var(--tr-wide); text-transform: uppercase;
  color: var(--ink); background: color-mix(in srgb, var(--paper) 90%, transparent);
  padding: .25rem .6rem; border-radius: var(--r-pill);
  backdrop-filter: blur(4px);
}
.card__body { padding: .9rem .1rem 0; display: grid; gap: .35rem; }
.card__title {
  font-family: var(--display); font-weight: 500; font-size: var(--fs-lg);
  line-height: var(--lh-snug); letter-spacing: var(--tr-tight); color: var(--ink);
}
.card__dek {
  font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__meta {
  display: flex; flex-wrap: wrap; gap: .35rem .85rem; align-items: center;
  font-size: var(--fs-meta); color: var(--ink-3); margin-top: .15rem;
}
.card__meta .star { color: var(--copper); }
.card__meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--copper-soft); }

/* hover lift -- the signature interaction */
.card:hover .card__frame img { transform: scale(1.045); }
.card:hover .card__frame { box-shadow: var(--shadow-lift); }
.card { transition: transform var(--base) var(--ease); }
.card:hover { transform: translateY(-6px); }

/* ==========================================================================
   BROWSE-ALL GRID
   ========================================================================== */

.browse { padding-block: var(--block); }
.browse__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--gap); margin-bottom: 1.6rem; flex-wrap: wrap;
}
.browse__head .shelf__title { font-size: var(--fs-2xl); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: clamp(1.2rem, 2.4vw, 2.4rem) var(--gap);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer { background: var(--paper-3); border-top: 1px solid var(--hair-strong); }
.footer__inner {
  display: grid; gap: clamp(2rem, 4vw, 3rem);
  grid-template-columns: 1.3fr 1fr;
  padding-block: var(--block);
}
@media (max-width: 760px) { .footer__inner { grid-template-columns: 1fr; } }
.footer h3 { font-size: var(--fs-lg); margin-bottom: .8rem; }
.footer__note {
  font-family: var(--display); font-style: italic; font-size: var(--fs-md);
  color: var(--ink-2); line-height: var(--lh-snug); max-width: 40ch;
}
.footer__cats { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.footer__cats a {
  font-size: var(--fs-meta); color: var(--ink-2); text-decoration: none;
  border: 1px solid var(--hair-strong); border-radius: var(--r-pill);
  padding: .35rem .8rem; background: var(--card);
  transition: all var(--fast) var(--ease);
}
.footer__cats a:hover { color: var(--ink); border-color: var(--copper-soft); }
.footer__sig {
  margin-top: 2.5rem; padding-top: 1.4rem; border-top: 1px solid var(--hair);
  font-size: var(--fs-meta); color: var(--ink-3);
  display: flex; flex-wrap: wrap; gap: .4rem 1rem; justify-content: space-between;
}

/* ==========================================================================
   PAGE-LOAD reveal (staggered)
   ========================================================================== */

/* Reveal is opt-in + fail-safe: elements are only hidden once JS adds the
   `armed` class, and a JS fallback reveals anything still pending. Without JS
   (or if the observer misses), everything stays fully visible. */
@media (prefers-reduced-motion: no-preference) {
  .reveal.armed { opacity: 0; transform: translateY(14px); }
  .reveal.armed.in { opacity: 1; transform: none;
    transition: opacity .6s var(--ease), transform .6s var(--ease); }
}

/* ==========================================================================
   skeleton placeholder while JSON loads
   ========================================================================== */
.sk { background: linear-gradient(100deg, var(--paper-2) 30%, var(--paper-3) 50%, var(--paper-2) 70%);
      background-size: 200% 100%; animation: sk 1.3s infinite linear; border-radius: var(--r-md); }
@keyframes sk { to { background-position: -200% 0; } }
