/* SS Bucket Biryani website: Our Story. Loaded after site.css, whose tokens, header and footer it uses.
   Desktop values match the Figma at 1512 px; clamp() and cqw scale them down, as in site.css. */

.our-story {
  --gold-light: #F2C46B;     /* pull quotes and the year on each chapter */
  --gold-pale: #FFD9A0;      /* pull quotes on red, where the deeper gold is too faint */
  --ink-deep: #300104;       /* the ground under "No gimmicks", the colour of its photo's own ground */
  --vision-red: #D9041A;     /* the ground of Vision 2040, the colour of its photo's sky */
  --font-quote: var(--font-serif);
  --gold-edge: linear-gradient(180deg, #C9890E, #FFDC98 21%, #FAD286 47%, #FFC556 61%, #FFDB97 72%, #CAA459 85%, #BD7C00);
  background: var(--maroon-ink);
}

/* ---------- Pieces every chapter shares ---------- */
/* An arch: a rounded top, a fine gold edge and a drawing that fills it */
.story-arch { position: relative; aspect-ratio: 559 / 503; overflow: hidden; border: 2.4px solid transparent; border-radius: 999px 999px 0 0; background: linear-gradient(#4A0509, #4A0509) padding-box, var(--gold-edge) border-box; }
.story-arch img { position: absolute; inset: 0; width: 100%; height: 100% !important; object-fit: cover; }

/* Never under 24 px: at that size a quote counts as large text, which pale gold on the red grounds can carry. */
.story-quote { position: relative; max-width: 410px; margin: 0; padding-left: 19px; font-family: var(--font-quote); font-size: clamp(24px, 1.65cqw, 25px); line-height: 1.24; color: var(--quote, var(--gold-light)); }
.story-quote::before { content: ""; position: absolute; left: 0; top: .1em; bottom: .05em; width: 3px; border-radius: 2px; background: currentColor; }

/* ---------- The opening ---------- */
.story-hero { position: relative; isolation: isolate; display: grid; align-items: center; min-height: min(62.5cqw, 945px); padding: clamp(112px, 10.5cqw, 159px) var(--gutter) clamp(64px, 7.1cqw, 108px); overflow: hidden; background: var(--maroon-ink); color: var(--cream); }
.story-hero::before { content: ""; position: absolute; z-index: -1; left: calc(var(--side) + min(38.6cqw, 583px)); top: 38.3%; width: min(57.3cqw, 866px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, rgba(237, 0, 40, .28), rgba(237, 0, 40, 0) 65%); }
.story-hero__inner { display: grid; grid-template-columns: minmax(0, 507fr) minmax(0, 559fr); column-gap: clamp(24px, 2.65cqw, 40px); align-items: center; width: 100%; max-width: 1106px; margin-inline: auto; }
.story-hero__copy { display: grid; justify-items: start; }
.story-hero__title { font-family: var(--font-condensed); font-weight: 400; font-size: clamp(64px, 8.2cqw, 124px); line-height: .92; text-transform: uppercase; }
.story-hero__title .heading-line { display: block; }
.story-hero__title em { font-style: normal; color: var(--red-on-dark); }
.story-hero__lead { max-width: 440px; margin-top: var(--space-4); font-size: 16px; line-height: 25px; }
.story-hero .story-quote { margin-top: var(--space-4); }
.story-hero__cue { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-top: var(--space-3); font-family: var(--font-quote); font-size: 12px; line-height: 1; letter-spacing: .2em; text-transform: uppercase; color: var(--cream); }
.story-hero__cue::before { content: ""; width: 2px; height: 36px; background: linear-gradient(var(--gold-light), rgba(242, 196, 107, 0)); }
.story-hero__art { position: relative; }
.story-hero__flames { position: absolute; inset: 0; }
/* The live fire's canvas (src/scripts/story-fire.ts) lies over the arch's pictures, unseen until the fire is lit */
.story-hero__live { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }

/* ---------- A chapter ---------- */
/* Text on one side, its drawing on the other; "flip" chapters put the drawing first. Each chapter's ground
   comes from data-tone, and its big number stands faintly in the corner above the drawing's side. */
.chapter { position: relative; isolation: isolate; display: grid; align-items: center; min-height: min(62.5cqw, 945px); padding: clamp(56px, 6cqw, 90px) var(--gutter); overflow: hidden; background: var(--ground); color: var(--cream); }
.chapter[data-tone="maroon"] { --ground: var(--maroon); --number: rgba(255, 242, 222, .08); }
.chapter[data-tone="ink"] { --ground: var(--maroon-ink); --number: rgba(255, 242, 222, .05); }
.chapter[data-tone="deep"] { --ground: var(--ink-deep); --number: rgba(255, 242, 222, .05); }
.chapter[data-tone="red"] { --ground: var(--red); --number: rgba(255, 242, 222, .15); --quote: var(--gold-pale); }
.chapter__number { position: absolute; z-index: -1; top: -.045em; right: calc(var(--side) + min(2cqw, 30px)); font-family: var(--font-condensed); font-size: clamp(120px, 33.33cqw, 504px); line-height: 1; color: var(--number); pointer-events: none; user-select: none; }
/* The number is drawn by the stylesheet: it is decoration, not text to read or to measure for contrast. */
.chapter__number::before { content: attr(data-number); }
.chapter--flip .chapter__number { right: auto; left: calc(var(--side) + min(1.5cqw, 23px)); }
.chapter__inner { display: grid; grid-template-columns: minmax(0, 500fr) minmax(0, 559fr); column-gap: clamp(24px, 2.71cqw, 41px); align-items: center; width: 100%; max-width: 1100px; margin-inline: auto; }
.chapter--flip .chapter__inner { grid-template-columns: minmax(0, 559fr) minmax(0, 500fr); }
.chapter--flip .chapter__art { order: -1; }
.chapter__copy { display: grid; justify-items: start; }
.chapter__when { padding: 6px 17px 3px; border-radius: var(--radius-pill); background: var(--gold-light); color: var(--maroon-ink); font-family: var(--font-condensed); font-size: clamp(24px, 1.98cqw, 30px); line-height: 1; letter-spacing: .04em; }
.chapter__label { margin-top: var(--space-4); font-family: var(--font-quote); font-size: 12px; line-height: 1.2; letter-spacing: .2em; text-transform: uppercase; }
.chapter__title { margin-top: var(--space-2); font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, 3.31cqw, 50px); line-height: 1.14; font-synthesis: none; }
.chapter__body { max-width: 490px; margin-top: var(--space-4); font-size: 16px; line-height: 1.5; }
.chapter .story-quote { margin-top: var(--space-5); }
.chapter__art { position: relative; }

/* What some chapters carry besides */
.chapter__extra { position: absolute; z-index: -1; pointer-events: none; }
.chapter__rice-hand { right: 0; bottom: -1.2%; width: min(45cqw, 680px); }
.chapter__bangles { left: calc(var(--side) + min(89.15cqw, 1348px)); top: -5.2%; width: min(55.1cqw, 833px); max-width: none; }
.chapter__hand { left: var(--side); top: 0; width: min(25.07cqw, 379px); }
.chapter__packets { position: absolute; right: -5.5%; top: -1.8%; width: 32%; }
.skyline--chapter { left: calc(var(--side) - min(8.33cqw, 126px)); top: 11.85%; width: min(44.51cqw, 673px); }

/* Chapter 9: the founder's creed, with a heap of rice where a drawing would be */
.chapter--creed { align-items: start; padding-top: clamp(56px, 7.8cqw, 118px); }
.chapter--creed .chapter__inner { grid-template-columns: minmax(0, 586px); }
.chapter__rice { position: absolute; z-index: -1; right: calc(var(--side) + min(3.1cqw, 47px)); bottom: 3%; width: min(57.6cqw, 871px); -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent); mask-image: radial-gradient(closest-side, #000 72%, transparent); }
.story-quote--creed { max-width: 410px; font-size: clamp(28px, 3.17cqw, 48px); line-height: 1.08; }

/* Drawings without an arch: the thread and the packs, and the name board */
.chapter__plain { width: 93%; }
.chapter__logo { width: 98.8%; }

/* Chapter 11: the bucket itself, with its steam */
.chapter__bucket { position: relative; width: 92%; margin-inline: auto; aspect-ratio: 774 / 965; }
.chapter__bucket > img { position: absolute; }
.chapter__bucket-steam { left: 7.9%; top: 0; width: 80.7%; }
.chapter__bucket-pot { left: 0; top: 19.8%; width: 100%; }

/* Chapter 13 makes room on its left for the hand that dips the chicken */
.chapter--aside .chapter__inner { width: auto; max-width: none; margin-left: calc(var(--side) + min(24.8cqw, 375px) - var(--gutter)); margin-right: max(0px, calc(var(--side) + min(5cqw, 76px) - var(--gutter))); grid-template-columns: minmax(0, 470fr) minmax(0, 559fr); column-gap: clamp(20px, 2.12cqw, 32px); }

/* ---------- Vision 2040 ---------- */
.vision { position: relative; isolation: isolate; min-height: min(83.47cqw, 1262px); padding: clamp(56px, 6.28cqw, 95px) max(var(--gutter), calc(var(--side) + min(9.4cqw, 142px))) 0; overflow: hidden; background: var(--vision-red); color: var(--cream); --quote: var(--gold-pale); }
.vision .chapter__copy { max-width: 540px; }
.vision__title { margin-top: var(--space-2); font-family: var(--font-display); font-weight: 400; font-size: clamp(48px, 6.35cqw, 96px); line-height: 1; font-synthesis: none; }
.vision__photo { position: absolute; z-index: -1; left: 0; bottom: 0; width: 100%; -webkit-mask-image: linear-gradient(transparent, #000 22%); mask-image: linear-gradient(transparent, #000 22%); }
.story-motif { height: 32px; background: var(--cream); }
.story-motif.motif { height: clamp(24px, 2.12cqw, 32px); }

/* ---------- Every grain has a story ---------- */
.story-end { position: relative; display: grid; grid-template-columns: minmax(0, 469fr) minmax(0, 609fr); column-gap: clamp(8px, .86cqw, 13px); align-items: end; padding: clamp(56px, 5.69cqw, 86px) var(--gutter) 0 max(var(--gutter), calc(var(--side) + min(19.25cqw, 291px))); overflow: hidden; background: linear-gradient(#D4041B, #310105); color: var(--cream); }
.story-end__copy { display: grid; gap: clamp(20px, 1.8cqw, 27px); align-self: start; }
.story-end__title { font-family: var(--font-condensed); font-weight: 400; font-size: clamp(56px, 7.28cqw, 110px); line-height: .92; text-transform: uppercase; }
.story-end__title .heading-line { display: block; }
/* The Figma's red for these words is lost on the red half of the ground; gold reads on all of it (3.3:1 at least). */
.story-end__title em { font-style: normal; color: var(--gold-light); }
.story-end__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.story-end .btn-pill { min-height: 46px; padding: 8px 22px; border-width: 1.6px; font-size: 17px; font-weight: 500; }
.story-end .btn-pill--cream { background: var(--cream); color: var(--maroon); }
.story-end .btn-pill--cream:hover { background: var(--white); }
.story-end__art { position: relative; width: min(100%, 609px); aspect-ratio: 609 / 584; }
.story-end__art > img { position: absolute; }
.story-end__arch { left: 14.45%; top: 7.53%; width: 73.65%; }
.story-end__steam { left: 28.49%; top: 11.73%; width: 45.07%; }
.story-end__bucket { left: 24.71%; top: 21.32%; width: 54.19%; }

/* ---------- Narrower screens ---------- */
@container page (max-width: 1100px) {
  .chapter__bangles, .chapter__hand, .skyline--chapter { display: none; }
  .chapter--aside .chapter__inner { width: 100%; max-width: 1100px; margin-inline: auto; grid-template-columns: minmax(0, 500fr) minmax(0, 559fr); }
}

/* Tablets: the drawing stands above its text */
@container page (max-width: 900px) {
  .story-hero { min-height: 0; }
  .story-hero__inner { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-7); max-width: 560px; }
  .story-hero__art { width: min(100%, 520px); }

  .chapter, .vision { min-height: 0; padding-block: clamp(72px, 11cqw, 100px); }
  .chapter__inner, .chapter--flip .chapter__inner, .chapter--aside .chapter__inner { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-7); max-width: 560px; margin-inline: auto; }
  .chapter__art { order: -1; width: min(100%, 520px); }
  .chapter__number { top: -.06em; font-size: clamp(120px, 30cqw, 240px); }
  .chapter__rice-hand { display: none; }

  .chapter--creed { padding-bottom: 0; }
  .chapter__rice { position: relative; right: auto; bottom: auto; width: 100%; max-width: 640px; margin: var(--space-6) auto 0; }

  .vision { padding-bottom: 0; }
  .vision__photo { position: relative; display: block; margin-top: var(--space-6); width: calc(100% + 2 * var(--gutter)); max-width: none; margin-left: calc(var(--gutter) * -1); }

  .story-end { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-6); padding-inline: var(--gutter); }
  .story-end__copy { max-width: 560px; justify-self: center; width: 100%; }
  .story-end__art { justify-self: center; }
}

@container page (max-width: 760px) {
  .story-hero { padding-top: 112px; }
  .chapter__inner, .chapter--flip .chapter__inner, .chapter--aside .chapter__inner { row-gap: var(--space-6); }
  .chapter__body { max-width: none; }
}

/* ==========================================================================
   Motion (see the Motion notes in site.css: everything hangs off data-motion="on")
   ========================================================================== */

/* The opening: the arch and the hand are there from the first frame, in low light (lit); the firelight comes up as
   the flames catch, a moment after the first line of the heading.
   Its fire is alive (src/scripts/story-fire.ts), and nothing is swapped for it. While motion is on, the photo's frozen
   flames stay out: the logs glow by themselves, in a picture of them alone that comes in as the flames did, and the
   fire catches from them on a canvas that fades in over that picture and then stands in for it. Only where the fire
   cannot be lit (data-fire="out") do the frozen flames come in over the logs after all; the logs' own picture goes
   once they are in.
   Only on a screen: on paper the arch is its two photos. */
@media screen {
  [data-motion="on"] .story-hero__embers { display: block; }
  [data-motion="on"] .story-hero:not([data-fire="out"]) .story-hero__flames { display: none; }
  .story-hero[data-fire="lit"] .story-hero__live { opacity: 1; transition: opacity var(--dur-short) var(--ease-in-out); }
  /* (the logs' picture leaves by visibility, not opacity: its entrance may still be easing its opacity, and a browser
     starts no transition on what an animation is moving) */
  [data-motion="on"] .story-hero[data-fire="lit"] .story-hero__embers { visibility: hidden; transition: visibility 0s linear var(--dur-enter); }
  [data-motion="on"] .story-hero[data-fire="out"] .story-hero__embers { visibility: hidden; transition: visibility 0s linear 2s; }
}

/* Where each piece comes from. On a wide screen a chapter's drawing comes in from its own side of the page. */
[data-motion="on"] .chapter__number { --from-y: 12%; --reveal-time: var(--dur-long); }
[data-motion="on"] .chapter__art { --from-x: 5%; --from-y: 6%; }
[data-motion="on"] .chapter--flip .chapter__art { --from-x: -5%; }
[data-motion="on"] .chapter__when { --from-scale: .6; }
[data-motion="on"] .chapter__rice-hand { --from-x: 18%; }
[data-motion="on"] .chapter__bangles { --from-x: 12%; --from-turn: 8deg; }
[data-motion="on"] .chapter__hand { --from-x: -18%; --from-y: -6%; }
[data-motion="on"] .chapter__packets { --from-turn: -24deg; --from-scale: .5; }
[data-motion="on"] .chapter__rice { --from-y: 12%; }
[data-motion="on"] .chapter__bucket-pot { --from-y: 14%; --from-scale: .94; }
[data-motion="on"] .vision__photo { --from-y: 8%; }
[data-motion="on"] .story-end__bucket { --from-y: 12%; --from-scale: .93; }
[data-motion="on"] .story-end__arch { --reveal-ease: var(--ease-out); }
/* stacked, the drawing stands above its text and rises like it */
@container page (max-width: 900px) {
  [data-motion="on"] :is(.chapter__art, .chapter--flip .chapter__art) { --from-x: 0px; --from-y: 10%; }
}

/* A drawing settles into its arch while the arch arrives: it starts a little larger and comes to rest at its
   design size, so the arch never shows an empty edge. */
[data-motion="on"] .chapter__art[data-seen]:not([data-rested]) .story-arch__drawing { animation: settle-in calc(var(--reveal-time) * 1.4) var(--ease-out) var(--reveal-start) backwards; }
@keyframes settle-in { from { scale: 1.08; } }
/* Chapter 14's shop rises into its arch from below, as in the Figma, while Dubai's skyline rises beside it */
[data-motion="on"] #chapter-14 .chapter__art[data-seen]:not([data-rested]) .story-arch__drawing { animation-name: shop-rise; }
@keyframes shop-rise { from { translate: 0 49.7%; } }

/* A pull quote's bar draws down before its words arrive */
[data-motion="on"] .story-quote[data-seen]:not([data-rested])::before { animation: bar-down var(--dur-enter) var(--ease-out) var(--reveal-start) backwards; transform-origin: 50% 0; }
@keyframes bar-down { from { transform: scaleY(0); } }

/* "Scroll the story" answers a pointer: its line reaches down a little */
.story-hero__cue::before { transform-origin: 50% 0; transition: transform var(--dur-hover) var(--ease-out); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .story-hero__cue:hover::before { transform: scaleY(1.25); }
}

/* ---------- Motion: ambient loops ---------- */
/* Where the opening's fire cannot be lit, its frozen flames flicker instead: a second copy of them, added as light,
   comes and goes, slowly and never far (three soft swells in a little over three seconds). It exists only while it
   flickers. */
[data-motion="on"] .story-hero[data-live][data-fire="out"] .story-hero__flames[data-seen] + .story-hero__glow {
  display: block; position: absolute; inset: 0; opacity: 0; mix-blend-mode: screen; pointer-events: none;
  animation: flicker calc(var(--breath) * .55) var(--ease-in-out) calc(var(--dur-long) + 500ms) infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 0; }
  18% { opacity: .34; }
  34% { opacity: .1; }
  52% { opacity: .42; }
  70% { opacity: .16; }
  86% { opacity: .3; }
}

/* A light runs down the line beside "Scroll the story" */
[data-motion="on"] .story-hero[data-live] .story-hero__cue[data-seen]::after { content: ""; position: absolute; left: 0; top: 4px; width: 2px; height: 12px; border-radius: 1px; background: var(--cream); opacity: 0; animation: trickle calc(var(--breath) * .4) var(--ease-in-out) calc(var(--reveal-start) + var(--reveal-time)) infinite; }
@keyframes trickle {
  0% { opacity: 0; translate: 0 0; }
  25% { opacity: .9; }
  70%, 100% { opacity: 0; translate: 0 24px; }
}

/* The bucket's steam keeps rising, in chapter 11 and at the end: two copies half a cycle apart, as on Home */
[data-motion="on"] :is(.chapter__bucket-steam, .story-end__steam) { transform-origin: 50% 100%; }
[data-motion="on"] .story-steam-echo { display: block; opacity: 0; }
[data-motion="on"] :is(.chapter, .story-end)[data-live] :is(.chapter__bucket-steam, .story-end__steam)[data-seen]:not(.story-steam-echo) { animation: var(--entrance), steam-out calc(var(--breath) * 1.2) linear calc(var(--scene-wait, 0ms) + 1500ms) infinite; }
[data-motion="on"] :is(.chapter, .story-end)[data-live] :is(.chapter__bucket-steam, .story-end__steam)[data-seen] + .story-steam-echo { animation: steam-in calc(var(--breath) * 1.2) linear calc(var(--scene-wait, 0ms) + 1500ms) infinite; }

/* ---------- Motion: scroll-linked ---------- */
/* Each chapter's number drifts against the page as the chapter passes, so the chapters seem to slide over
   their numbers. It sits at its design place when the chapter is centred in the window. */
@supports (animation-timeline: view()) {
  @container page (min-width: 761px) {
    [data-motion="on"] :is(.chapter, .story-hero) { view-timeline: --passage block; }
    [data-motion="on"] .chapter__number { --shift: 7%; animation: parallax linear both; animation-timeline: --passage; }
    [data-motion="on"] .chapter__number[data-seen] { animation: var(--entrance), parallax linear both; animation-timeline: auto, --passage; }
  }
}

/* The pieces that exist only for motion stay out of the static page */
.story-hero__glow, .story-steam-echo, .story-hero__embers { display: none; }
