/* ==========================================================================
   CARTA MAGNA — Home page
   The crest hero (shared with the Carta digital page) plus the zigzag
   sections that open the product pages: Carta digital, Reserva de mesa,
   Pedidos, Agente WhatsApp and Recepcionista IA.

   Each section pairs one animated character (the same transparent head
   videos used on the Carta digital page) with a number/eyebrow, a title, a
   short description and a link. The sides alternate down the page, so the
   eye zigzags from one product to the next.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Hero — same as the Carta digital hero, with a cue to the sections below.
   -------------------------------------------------------------------------- */
.home-hero__cue {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 4vh, 44px);
  /* On portrait screens the first section rises into the hero and its
     character appears right below this cue; keep the cue on top of it. */
  z-index: 3;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition:
    color var(--d-rapido) var(--ease-ola),
    opacity 300ms var(--ease-ola),
    transform 420ms var(--ease-ola);
}
/* The first scroll is the answer to the cue, so it leaves: it fades and sinks
   with the gesture. `is-away` is set by home.js (initHeroCue). */
.home-hero__cue.is-away {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}
.home-hero__cue:hover,
.home-hero__cue:focus-visible {
  color: var(--magna-600);
}
.home-hero__cue svg {
  transform: rotate(90deg);
  animation: home-cue 2.4s var(--ease-ola) infinite;
}
@keyframes home-cue {
  0%,
  100% {
    transform: rotate(90deg) translateX(0);
  }
  50% {
    transform: rotate(90deg) translateX(6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .home-hero__cue svg {
    animation: none;
  }
  /* Hide on the spot: no fade, no drift. */
  .home-hero__cue {
    transition: color var(--d-rapido) var(--ease-ola);
  }
  .home-hero__cue.is-away {
    transform: translateX(-50%);
  }
}

/* Short viewports: the cue would crowd the hero, so it steps aside. */
@media (max-height: 699px) {
  .home-hero__cue {
    display: none;
  }
}

/* Phones: the cue is a quiet hint, not a second title. */
@media (max-width: 620px) {
  .home-hero__cue {
    gap: 8px;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
  }
  .home-hero__cue svg {
    width: 14px;
    height: 14px;
  }
  .home-hero__cta .btn {
    padding: 0 24px;
    font-size: 14px;
  }
}

/* The hero's demo buttons leave with the cue: once the visitor scrolls, the
   hero has done its job and the sections take over. */
.home-hero__cta {
  position: relative;
  /* The next section climbs into the hero with a negative margin. Lift the
     buttons above that overlap so they stay clickable at the top. */
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  transition:
    opacity 300ms var(--ease-ola),
    transform 420ms var(--ease-ola);
}
.home-hero__cta.is-away {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .home-hero__cta {
    transition: none;
  }
  .home-hero__cta.is-away {
    transform: none;
  }
}

/* The hero speaks in the same display voice as the section titles and the
   Carta digital claims: Anton, condensed and set in capitals. */
.home-hero .bn-hero__claim {
  font-family: "Anton", var(--font-ui);
  font-weight: 400;
  font-size: clamp(1.9rem, 0.4rem + 6vw, 6.4rem);
  line-height: 0.96;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  /* The hero is the first poster of the site: same pair as the Carta
     digital claims — the constant line in Rojo Magna, the accent in Mar.
     paintTitles() (home.js) then repaints the words in the full tone
     cycle (see .tw-- below), so these two colours are the no-JS fallback:
     the first line is a marked phrase and reads as a selection, and the
     accent line is a combination of the poster tones. */
  color: var(--title-a);
}
.home-hero .bn-hero__accent {
  color: var(--title-b);
  font-style: normal;
}

/* On a phone the crest is the whole first impression, so it takes more of the
   screen. The shared rule (see .bn-hero__logo in home-chrome.css) starts at
   26vw, which on any phone falls under its own 168px floor — the crest was
   therefore pinned at the same small size from 320px to 645px, while the
   claim below it kept growing with the screen.

   Here it scales with the phone instead: about 58% of the width, with 46vh
   keeping it in check on short screens. The 240px cap is what makes it hand
   back over to the shared rule at 900px without a jump (234px there). */
@media (max-width: 900px) {
  .home-hero .bn-hero__logo {
    width: clamp(184px, min(58vw, 46vh), 240px);
  }
}

/* --------------------------------------------------------------------------
   Sections — the zigzag rows
   -------------------------------------------------------------------------- */
.home-access {
  position: relative;
  /* The section's own breathing room, top and bottom. */
  --home-access-y: clamp(64px, 9vw, 132px);
  /* The breath between the hero copy and the first row is measured at
     runtime by home.js and rewritten into --home-access-climb; the value
     below is the no-JS fallback only (a share of the screen minus 40px). */
  --home-access-climb: clamp(0px, 14svh - 40px, 320px);
  /* --home-gap is the base rhythm between sections: home.js reads the rows'
     row-gap and uses it (plus --home-hero-gap-extra) to match the climb.
     --home-row-gap is the breath between the rows themselves; it starts equal
     (one rhythm) and only tightens on the large screens below. The rows take
     the difference back as a negative margin, so row-gap — and therefore the
     measured first breath — is left untouched. */
  --home-gap: clamp(64px, 10vw, 150px);
  --home-row-gap: var(--home-gap);
  /* Extra air between the hero claim and the first row. The row rhythm keeps
     the rest of the sections together; this only opens the hand-over from
     the hero to the Carta digital row. Kept as a plain px value because
     home.js reads it back to solve the climb. */
  --home-hero-gap-extra: 40px;
  padding-block: var(--home-access-y);
  margin-top: calc(-1 * (var(--home-access-y) + var(--home-access-climb)));
}

.home-access__rows {
  /* Height of each media stage. The videos are sized to fill it, see
     --char-h on .home-row__media below. */
  --stage-h: clamp(380px, 48vw, 660px);
  display: grid;
  gap: var(--home-gap);
}
/* Rows after the first sit at --home-row-gap instead: the difference against
   the grid's row-gap is taken back as a negative margin, which pulls the row
   up without changing the gap home.js measures for the first breath.

   --home-row-lead is the extra each row needs so the artwork inside its clip
   ends up the same distance from the artwork above it: the clips are fitted,
   not filled, so each one carries its own blank band inside the stage, and
   the row that follows takes that band back as extra lead. home.js
   measures it from the clips and writes it here (see applyHomeGaps); with JS
   off it stays 0 and the rows simply share the base rhythm. */
.home-access__rows > .home-row:not(:first-child) {
  margin-top: calc(var(--home-row-gap) - var(--home-gap) + var(--home-row-lead, 0px));
}

/* One product. Two columns: the character and the copy. The media column is
   wider so the video keeps presence; `grid-template-areas` swaps the two
   sides on every even row (the zigzag). */
.home-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  grid-template-areas: "media body";
  align-items: center;
  gap: clamp(20px, 4vw, 64px);
}
.home-access__rows > .home-row:nth-child(even) {
  grid-template-areas: "body media";
  /* The sides swap, but the media keeps the wider track: the copy moves to
     the 1fr column and the media to the 1.6fr one. Otherwise an even row
     would hand the video the narrow column and it would shrink to half. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
}
.home-row__media {
  grid-area: media;
}
.home-row__body {
  grid-area: body;
}

/* --- Media stage ---------------------------------------------------------
   The clips come in square and 3:2 frames, but the animation only occupies a central slice of
   the frame (~40–76% of the width, ~70–95% of the height) and each clip is
   framed a little differently. So instead of a fixed width, every clip is
   normalised by its own content height (--char-h, measured per animation):
   the video is made as tall as it needs to be for the character to fill the
   stage, the stage clips the transparent frame that spills out, and its edges
   fade into the page field. A warm bulb glow blooms behind. */
.home-row__media {
  position: relative;
  /* The stage carries its own link, and that link has to sit above the
     row-wide overlay the CTA stretches over the section. The media is already
     a stacking context (isolation, for the glow), so this lifts the whole
     stage — link included — over that overlay. */
  z-index: 2;
  /* Flex (not grid) so an oversized clip overflows equally on both sides
     instead of being pushed off to the right. */
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--stage-h);
  isolation: isolate;
  overflow: clip;
  /* the stage itself is decorative; its link re-enables the pointer */
  pointer-events: none;
  /* Dissolve the stage edges so the oversized clip never cuts hard. */
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 7%, #000 93%, transparent),
    linear-gradient(to bottom, transparent, #000 5%, #000 95%, transparent);
  mask-image:
    linear-gradient(to right, transparent, #000 7%, #000 93%, transparent),
    linear-gradient(to bottom, transparent, #000 5%, #000 95%, transparent);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
/* The stage as a link of its own: it fills the media box, so the clip is
   clickable as a link instead of just sitting under the row-wide overlay.
   Filling the box is also what gives the clip a definite width and height to
   measure its max-width/max-height against. */
.home-row__media-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}
.home-row__glow {
  position: absolute;
  inset: 8% 10%;
  z-index: -1;
  border-radius: 50%;
  background: var(--grad-bulb);
  opacity: 0.85;
  pointer-events: none;
}
.home-row__video {
  display: block;
  /* --char-h is the share of the clip's height the character fills, set per
     row from measurements of each animation. The 0.82 keeps the character
     filling the stage while leaving room for the float and for the props that
     reach out from the character's silhouette. */
  height: calc(var(--stage-h) * 0.82 / var(--char-h, 0.85));
  width: auto;
  max-width: none;
  filter: drop-shadow(0 34px 40px rgba(64, 38, 22, 0.26)) drop-shadow(0 8px 12px rgba(64, 38, 22, 0.16));
  animation: home-row-float 9s var(--ease-ola) infinite alternate;
}
/* A scene clip is a whole composition rather than a single character — here
   the customer, the phone she is scanning with and the QR with its sparks,
   which together span 96% of the frame's width. Sizing that by the
   character's height (as the rows above do) would blow the clip past the
   stage and crop the props on both sides, so it is fitted instead: as large
   as it goes while staying inside the stage, both ways. Nothing is cropped,
   and the framing it was authored with is kept whole.

   Both limits are needed. Width alone would overflow on the stacked layouts,
   where the stage is wide and short (at 768px the clip would be 121% of the
   stage and lose the top of the head and the phone). */
.home-row__media--scene .home-row__video {
  width: auto;
  height: auto;
  /* --scene-scale lets a single scene clip sit smaller inside its stage
     without cropping it (default 1 = full fit, as the Carta digital clip). */
  max-width: calc(100% * var(--scene-scale, 1));
  max-height: calc(100% * var(--scene-scale, 1));
}
/* The reserva clip was authored with a wider margin than the other scenes, so
   it is scaled down inside the desktop two-column stage. */
.home-row__media--reserva {
  --scene-scale: 0.824;
}

/* The scene clip rests on the bottom of its stage.

   It is fitted rather than filling the stage, so it sat centred with an empty
   band underneath — and that band is what stood between the art and the copy.
   Nudging the clip down to the bottom closes the gap without moving anything
   else: the stage keeps its height, so the body text (and every row below it)
   stays exactly where it was, and the art is not lifted towards the section
   above either.

   Below 561px is where that letterbox actually is. From 561 to 900 the clip
   is already tall enough to fill the stage, so the rule simply finds nothing
   to do; above 900 the two-column layout keeps it centred. */
@media (max-width: 900px) {
  .home-row__media--scene .home-row__media-link {
    align-items: flex-end;
  }
  /* On the stacked layout the stage is wide and short, so the width is what
     limits the clip and the reserva scene reads smaller than the Carta digital
     and Pedidos ones. Let it fill the stage there instead of keeping the
     desktop margin. */
  .home-row__media--reserva {
    --scene-scale: 1;
  }
}

/* A still artwork (the Agente de WhatsApp illustration) travels as a rounded
   card rather than a cut-out: its flat colour field needs a frame of its own
   instead of the stage's edge dissolve. Sized square and centred, warm shadow
   and float kept from the clips. */
.home-row__media--card {
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}
.home-row__media--card .home-row__video {
  /* The clip is a square tile rather than a cut-out character, so it is sized
     by its height like the others and nearly fills the stage. */
  height: calc(var(--stage-h) * 0.94);
  width: auto;
  max-width: 96%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-lg);
}
@media (max-width: 560px) {
  .home-row__media--card .home-row__video {
    height: auto;
    width: min(92%, calc(var(--stage-h) * 0.94));
  }
}
/* On the stacked layouts the video sits above its copy. The WhatsApp card is a
   framed tile, so the stage's fixed height leaves an empty band under it — and
   that band is all the gap the eye reads between the art and its text. Let the
   stage hug the card there, so the copy tucks right under it. The clip also
   carries a transparent band under the art and the float lifts the card away
   from the copy, so hold it still and pull it down over that band. */
@media (max-width: 900px) {
  .home-row__media--card {
    height: auto;
  }
  .home-row__media--card .home-row__video {
    margin-bottom: -12px;
    animation: none;
  }
}

@keyframes home-row-float {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, -14px, 0);
  }
}

/* --- Copy --------------------------------------------------------------- */
.home-row__eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-inscription);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--magna-600);
}
.home-row__eyebrow::before {
  content: "";
  width: 34px;
  height: 1.5px;
  background: currentColor;
}
.home-row__title {
  margin: 16px 0 0;
  /* Same display voice as the Carta digital claims: Anton, condensed and
     set in capitals — and their colour pair, the changing word in Mar.
     Sized at poster scale so each row reads like the Carta digital ones
     instead of a small caption. It lives in the narrower copy column (about
     300–450px from 900px up), which is what sets the ceiling: the longest
     word ("restaurante") stays inside the column and its gutter at every
     width — the row's gap gives the last few pixels of headroom. */
  font-family: "Anton", var(--font-ui);
  font-weight: 400;
  font-size: clamp(2.2rem, 1.2rem + 4vw, 5rem);
  line-height: 0.94;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  overflow-wrap: break-word;
  color: var(--title-b);
  text-wrap: balance;
}
/* The title is a link as well, so the section's own words are the anchor text
   of the link (`paintTitles` paints the coloured words inside it). Its colour
   comes from those painted spans, so the link only has to keep out of the way. */
.home-row__title-link {
  color: inherit;
  text-decoration: none;
}
/* --- A poster of many colours -------------------------------------------
   The home page is the site's poster wall, so its display titles are painted
   piece by piece by paintTitles() (home.js), cycling the Carta digital
   tones: Rojo Magna → Mar de Tarde → Terracota, then back. Both the section
   titles and the hero claim take part (the claim's lines carry .cm-paint);
   the .tw-- classes come from the script. With JS off they keep the single
   colour from the stylesheet and the text is never altered. */
.home-row__title .tw--magna,
.bn-hero__claim .tw--magna {
  color: var(--title-a);
}
.home-row__title .tw--mar,
.bn-hero__claim .tw--mar {
  color: var(--title-b);
}
.home-row__title .tw--terracota,
.bn-hero__claim .tw--terracota {
  color: var(--title-c);
}
/* A phrase in a title (or in the hero claim) can be marked: the page red under
   cream type — the very
   pair the site uses for a text selection (see ::selection in styles.css), so
   it reads as if the reader had selected exactly that bit and nothing else.
   No padding and no radius: a selection has none either.

   The red is painted as a short band, not as the whole inline box. Anton's
   own box is much taller than the title's tight 0.94 line-height, so a plain
   background spilled over the lines above and below. The band is kept centred
   on the line and given a little air above and below: 1.15em around Anton's
   0.859em cap height (roughly 0.15em of red past the caps each way). Tune the
   1.15em to taste — it is centred, so the type itself never moves.

   It sits on the element in the markup (a <mark>) and paintTitles() rebuilds
   an equivalent wrapper around the painted words, so it survives the painting
   and works with JS off as well. This rule has to come after the .tw-- tones:
   inside the mark one colour wins, whichever colour the cycle had given the
   words. */
.home-row__title-mark {
  background-color: transparent;
  background-image: linear-gradient(var(--magna-600), var(--magna-600));
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: 100% 1.15em;
  color: var(--surface-light);
}
.home-row__title-mark .tw {
  color: inherit;
}
.home-row__text {
  margin: 16px 0 0;
  max-width: 48ch;
  font-size: var(--fs-body-l);
  line-height: 1.55;
  color: var(--text-muted);
  text-wrap: pretty;
}

/* The row's CTA is the site's own button: `.btn` with the same markup as the
   CTAs on the section pages, so it is the same red pill, the same size and
   the same hover as all of them (`.bn-page .btn` gives it the pill radius
   the rest of the home page uses).

   It only adds two things: the spacing it needs inside the copy column, and
   the trick that keeps the whole section clickable.

   That trick used to be a plain `::after` overlay on the link, and it cannot
   live next to `.btn` as-is: `.btn` is positioned and clipped, which would
   anchor that overlay to the button instead of the row and cut it off. So the
   link is put back to `static`/`visible`, and `.btn`'s own hover highlight
   line — the very same pseudo-element — is turned into the overlay.

   The overlay being a child of the link means hovering anywhere in the row
   still hovers the button, so `.btn:hover` does the rest on its own. */
.home-row__more {
  margin-top: clamp(20px, 3vw, 30px);
}
.home-row__more.btn {
  position: static;
  overflow: visible;
}
.home-row__more.btn::after {
  inset: 0;
  height: auto;
  background: none;
  opacity: 1;
  z-index: 1;
  border-radius: var(--r-lg);
}

/* --------------------------------------------------------------------------
   The hero and the first section hand over
   While the hero still shows its "Descubre cómo" cue the first section is
   held back: it is the row that climbs into the hero (see the portrait rule
   below), so at the very top of the page it would otherwise peek in around
   the claim. It arrives with the first scroll, at the same moment the cue
   leaves — one hands over to the other.

   The flag lives on <html> (set by home.js, initHeroCue), so it also
   survives the seamless section swaps; with JS off nothing is hidden. */
html.is-hero-top .home-access .home-row:first-child {
  opacity: 0;
  visibility: hidden;
}

/* --------------------------------------------------------------------------
   Responsive — stack each row (video on top, copy below) and drop the float
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .home-row,
  .home-access__rows > .home-row:nth-child(even) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "media"
      "body";
    gap: clamp(16px, 4vw, 28px);
  }
}

@media (max-width: 560px) {
  .home-access__rows {
    --stage-h: clamp(300px, 88vw, 420px);
  }
  /* On a narrow phone the stage can be taller than a width-limited scene.
     The clip then rests on the bottom of the stage and the band left above it
     is read as extra space before the section — a different space for each
     clip. Let the stage hug the clip here, so the blank above is only the
     clip's own (a few pixels) and every section keeps the same room. */
  .home-row__media--scene {
    height: auto;
  }
}

/* --------------------------------------------------------------------------
   Large screens — the zigzag runs tighter
   From 1024px the rows used the widest gap of the whole scale (10vw, up to
   150px), which left the sections reading as separate screens instead of one
   column of posters. The gap steps down here and then grows very gently, so
   it stays proportional to the row — about 13% of its height at every width
   on this side of the breakpoint. */
@media (min-width: 1024px) {
  .home-access {
    --home-gap: clamp(64px, 6vw, 96px);
    /* The first breath (hero → row 1) keeps its measured value; the rows
       after it can sit closer, so the zigzag reads as one column of posters
       instead of separate screens. */
    --home-row-gap: clamp(44px, 4vw, 64px);
    --home-hero-gap-extra: 64px;
  }
}

/* --------------------------------------------------------------------------
   Portrait screens — the hero owns a full screen with its claim centred, so
   its lower half is empty and would read as a hole between the claim and the
   first row. The no-JS fallback climbs further into it here; home.js
   overrides the value with the exact one that matches --home-gap (see
   .home-access).

   Measured in svh so it shrinks with the hero, which is sized in svh too. */
@media (orientation: portrait) {
  .home-access {
    --home-access-climb: clamp(0px, 24svh - 40px, 410px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-row__video {
    animation: none;
  }
}

