/* chapter-hero.css: one composed opening for chapter pages.
   Replaces the stacked chapter-intro header, lead video panel, Keep reading cue and
   the bk-hero banner with a single hero on the feature ground (lavender in light,
   ink in dark). Load after reading.css, members.css and book-kit.css.

   Markup (see scripts/convert-chapter-hero.mjs, which writes it):
     <article class="chapter has-hero">
       <header class="ch-hero ink" style="--hero:#0f6cbd">
         <div class="ch-hero__grid">
           <div class="ch-hero__art" aria-hidden="true"><img class="ch-hero__logo" src alt="">...</div>   (still logo field)
           <div class="ch-hero__meta">badge + [data-reading-time-slot]</div>
           <h1 class="ch-hero__title">...</h1>
           <p class="ch-hero__sub">...</p>            (subtitle, or the bk-hero line when there is no subtitle)
           <blockquote class="ch-hero__quote">...</blockquote>
           <ul class="ch-hero__topics">chips</ul>
           <div class="ch-hero__media">                  (only with a lead video; without one add .ch-hero--art)
             <section class="ch-hero__video">bar + frame</section>
           </div>
           <a class="ch-hero__cue" data-hero-cue>Keep reading ...</a>
         </div>
       </header>
   js/chapter-hero.js refreshes the cue and fits the video to the first screen. */

/* ── Grid placement inside the chapter shell ─────────────────────────────── */
.chapter.has-hero>.ch-hero{grid-area:hero}
.chapter.has-hero{grid-template-areas:"hero" "mobiletoc" "body" "nav"}
@media (max-width:1099px){.chapter.has-hero{grid-template-areas:"hero" "mobiletoc" "body" "nav"}}
/* public previews carry the Builder's Journey bar above the hero */
.chapter.has-hero:has(>.journey-bar){grid-template-areas:"jbar" "hero" "mobiletoc" "body" "nav"}
@media (max-width:1099px){.chapter.has-hero:has(>.journey-bar){grid-template-areas:"jbar" "hero" "mobiletoc" "body" "nav"}}
/* phones: the chapter opens the page and the journey bar follows the hero, so video and cue fit the first screen */
@media (max-width:719px){.chapter.has-hero:has(>.journey-bar){grid-template-areas:"hero" "jbar" "mobiletoc" "body" "nav"}}
@media (min-width:1100px){
  .chapter.has-hero{grid-template-areas:"hero hero" "toc body" "toc nav"}
  .chapter.has-hero:has(>.journey-bar){grid-template-areas:"jbar jbar" "hero hero" "toc body" "toc nav"}
  .dashboard-content .chapter.has-hero{grid-template-areas:"hero hero" "mobiletoc toc" "body toc" "nav toc"}
  .chapter.has-hero>.ch-hero,.chapter.has-hero>.journey-bar{max-width:none}   /* journey bar and hero share one right edge */
}

/* ── The hero surface ────────────────────────────────────────────────────── */
.ch-hero{
  container-type:inline-size;
  position:relative;isolation:isolate;overflow:hidden;
  width:100%;margin:0 0 1.5rem;
  border:1px solid var(--ink-line);border-radius:var(--r-card,22px);
  background:
    radial-gradient(70% 90% at 100% 40%,color-mix(in srgb,var(--purple) 12%,transparent),transparent 65%),
    radial-gradient(60% 80% at 0% 100%,color-mix(in srgb,var(--hero,#0f6cbd) 10%,transparent),transparent 70%),
    var(--ink);
}
.ch-hero__grid{
  display:grid;grid-template-columns:minmax(0,1fr);
  grid-template-areas:"meta" "title" "sub" "media" "quote" "topics" "cue";
  padding:clamp(1.1rem,3.4cqi,2.25rem) clamp(1rem,3.4cqi,2.25rem) 0;
}

/* Text */
.ch-hero__meta{grid-area:meta;display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;margin:0 0 .9rem}
.ch-hero .badge{white-space:nowrap}
.ch-hero .badge--purple{background:var(--ink-2);border-color:color-mix(in srgb,var(--purple) 32%,transparent);color:var(--link)}
.ch-hero__time{font-size:.82rem;font-weight:560;color:var(--ink-muted);font-variant-numeric:tabular-nums}
.ch-hero__title{grid-area:title;margin:0;font-family:var(--sans);font-weight:760;letter-spacing:-.035em;line-height:1.02;
  font-size:clamp(2rem,7.4cqi,3.4rem);color:var(--ink-text);text-wrap:balance}
.ch-hero__sub{grid-area:sub;margin:.55rem 0 0;font-size:clamp(1.05rem,2.2cqi,1.2rem);line-height:1.45;color:var(--ink-muted);max-width:42ch;text-wrap:pretty}
.ch-hero__quote{grid-area:quote;margin:1.25rem 0 0;padding:0;border:0;max-width:46ch}
.ch-hero__quote p{margin:0;font-size:1rem;line-height:1.6;font-style:italic;font-weight:400;color:var(--ink-text);text-wrap:pretty}
.ch-hero__topics{grid-area:topics;list-style:none;display:flex;flex-wrap:wrap;gap:.4rem;margin:1.1rem 0 0;padding:0}
.ch-hero__topics li{display:inline-flex;align-items:center;height:28px;padding:0 .7rem;border-radius:99px;border:1px solid var(--ink-line);
  background:var(--ink-2);color:var(--ink-muted);font-size:.8rem;font-weight:620;white-space:nowrap}

/* Media: the lead video, clean on its own */
.ch-hero__media{grid-area:media;position:relative;z-index:1;display:grid;place-items:center;justify-self:center;width:100%;margin:1.25rem 0 .25rem}
.ch-hero__video{position:relative;width:100%;padding:8px;border-radius:var(--r-surface,20px);background:var(--ink-2);border:1px solid var(--ink-line);
  box-shadow:var(--shadow-exhibit,0 30px 60px -40px rgba(23,21,31,.35),0 2px 6px -2px rgba(23,21,31,.08))}
.ch-hero__bar{display:flex;align-items:center;gap:.45rem;min-height:36px;margin:0 0 6px;padding:0 .2rem 0 .35rem;font-size:.88rem;font-weight:620;color:var(--ink-muted);line-height:1.25}
.ch-hero__bar .i{width:16px;height:16px;flex:none;color:var(--link)}
.ch-hero__bar .video-all{margin-left:auto;flex:none;font-size:.85rem;font-weight:620;color:var(--link)!important;text-decoration:none;border-radius:8px}
@media (hover:hover) and (pointer:fine){.ch-hero__bar .video-all:hover{text-decoration:underline;text-underline-offset:3px}}
.ch-hero__frame{position:relative;width:100%;aspect-ratio:16/9;border-radius:14px;overflow:hidden;background:#0b0a12}
.ch-hero__frame iframe{position:absolute;inset:0;width:100%;height:100%;border:0}

/* Logo cluster: a still composition of the chapter's products beside the title. One
   dominant logo (the chapter's primary product) and up to two supporting logos set apart
   from it as a loose triangle: the main logo on the right, the two smaller ones to its
   left, one above and one below its centre line, with clear space between all three (no
   touching, no stacking). It lives in a strip reserved at the right of the badge, title and
   lede (none of them runs into it), vertically centred on that block, so no letter ever
   sits on a logo. Same placement, ratios, spacing and opacity tiers in every chapter; only
   the products change. No motion, no script, nothing clipped, nothing under the video.
     sizes      1 : .52 : .4 of --d, with .26 of --d of air between logos
     opacity    light .24 / .16 / .13     dark .18 / .13 / .10
     place      right edge of the text column beside the title and lede, reaching into the gap
                before the video but stopping 12px short of the video card */
.ch-hero{--t1:.24;--t2:.16;--t3:.13}
.ch-hero__grid{--d:9cqi;--reach:0px;--cw:calc(var(--d) * 1.78 + 1rem - var(--reach))}   /* cqi resolves against the hero, so these live on the grid */
:root[data-theme="dark"] .ch-hero{--t1:.18;--t2:.13;--t3:.1}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .ch-hero{--t1:.18;--t2:.13;--t3:.1}}
.ch-hero__grid{position:relative}
.ch-hero__meta,.ch-hero__title,.ch-hero__sub,.ch-hero__quote,.ch-hero__topics{position:relative;z-index:1}
.ch-hero__title{max-width:calc(100% - var(--cw))}
.ch-hero__sub{max-width:min(42ch,calc(100% - var(--cw)))}
.ch-hero__art{position:absolute;z-index:0;grid-column:title;grid-row:title-start/sub-end;inset:0;pointer-events:none}   /* starts under the meta row, so the badge and reading time keep one line */
.ch-hero__logo{position:absolute;top:50%;height:auto;aspect-ratio:1;object-fit:contain;max-width:none}
.ch-hero__logo:nth-child(1){right:calc(-1 * var(--reach));width:var(--d);transform:translateY(-50%);opacity:var(--t1)}
.ch-hero__logo:nth-child(2){right:calc(var(--d) * 1.26 - var(--reach));width:calc(var(--d) * .52);transform:translateY(calc(var(--d) * -.65));opacity:var(--t2)}
.ch-hero__logo:nth-child(3){right:calc(var(--d) * 1.32 - var(--reach));width:calc(var(--d) * .4);transform:translateY(calc(var(--d) * .13));opacity:var(--t3)}
.ch-hero__logo:nth-child(n+4){display:none}

/* Chapters without a lead video: one text column; the title block and its logo strip keep to
   600px so the constellation stays close to short titles instead of drifting right */
.ch-hero--art .ch-hero__art{right:auto;width:min(100%,600px)}
.ch-hero--art .ch-hero__title{max-width:calc(min(100%,600px) - var(--cw))}
.ch-hero--art .ch-hero__sub{max-width:min(42ch,calc(min(100%,600px) - var(--cw)))}
.ch-hero--art .ch-hero__quote{max-width:min(60ch,100%)}

/* Keep reading cue, anchored to the hero's bottom edge */
.ch-hero__cue{grid-area:cue;display:flex;align-items:center;gap:.75rem;margin:1rem calc(-1 * clamp(1rem,3.4cqi,2.25rem)) 0;
  padding:.85rem clamp(1rem,3.4cqi,2.25rem);border-top:1px solid var(--ink-line);background:color-mix(in srgb,var(--ink-2) 55%,transparent);
  color:var(--ink-text);text-decoration:none;font-size:.95rem;line-height:1.35;transition:background-color 200ms ease}
.chapter .ch-hero__cue,.chapter .ch-hero__cue:hover{color:var(--ink-text);border-bottom:0}
.ch-hero__cue-icon{flex:none;width:32px;height:32px;border-radius:50%;display:grid;place-items:center;background:var(--accent-soft);color:var(--link);transition:transform 200ms var(--ease-out)}
.ch-hero__cue-icon .i{width:17px;height:17px}
.ch-hero__cue-text{min-width:0}
.ch-hero__cue b{font-weight:680;transition:color 160ms ease}
.ch-hero__cue em{margin-left:auto;flex:none;font-style:normal;font-size:.85rem;font-weight:600;color:var(--ink-muted);font-variant-numeric:tabular-nums}
.ch-hero__cue:active .ch-hero__cue-icon{transform:scale(.94)}
@media (hover:hover) and (pointer:fine){
  .ch-hero__cue:hover{background:var(--ink-2)}
  .ch-hero__cue:hover b{color:var(--link)}
  .ch-hero__cue:hover .ch-hero__cue-icon{transform:translateY(2px)}
}
@media (prefers-reduced-motion:no-preference){.ch-hero__cue-icon .i{animation:ch-hero-bob 1.8s var(--ease-in-out) infinite}}
@keyframes ch-hero-bob{0%,100%{transform:translateY(-1px)}50%{transform:translateY(2px)}}
.ch-hero :focus-visible{outline:2px solid var(--focus-g);outline-offset:3px}
.ch-hero__cue:focus-visible{outline-offset:-3px;border-radius:0 0 var(--r-card,22px) var(--r-card,22px)}

/* Phones: tighter art, the count drops under the title of the next section */
@container (max-width:520px){
  .ch-hero__grid{padding-top:1rem}
  .ch-hero__meta{margin-bottom:.7rem;row-gap:.35rem}
  /* phones: the dominant logo alone */
  .ch-hero__grid{--d:19cqi;--cw:calc(var(--d) + .75rem)}   /* reach stays 0 */
  .ch-hero__logo:nth-child(n+2){display:none}
  .ch-hero__art{grid-row:title}                         /* only the title makes room for it here */
  .ch-hero__meta,.ch-hero__sub{max-width:none}
  .ch-hero__topics{display:none}                        /* the chips repeat What You'll Learn; the first screen needs the room */
  .ch-hero__bar{font-size:.82rem}
  .ch-hero__media{margin:1rem 0 0}
  .ch-hero__quote{margin-top:1rem}
  .ch-hero__quote p{font-size:.95rem;line-height:1.55}
  .ch-hero__topics{margin-top:.8rem}
  .ch-hero__cue{margin-top:.9rem;padding-block:.7rem;flex-wrap:wrap;row-gap:.1rem}
  .ch-hero__cue-text{flex:1 1 calc(100% - 3rem)}
  .ch-hero__cue em{margin-left:calc(32px + .75rem)}
}

/* Wide: text over its logo field left, video right, cue across the bottom */
@container (min-width:680px){
  .ch-hero__grid{
    --gap:clamp(2.5rem,5cqi,4rem);--reach:calc(var(--gap) - 12px);
    grid-template-columns:minmax(0,1.08fr) minmax(0,1fr);column-gap:var(--gap);
    grid-template-rows:1fr auto auto auto auto auto 1fr auto;
    grid-template-areas:". media" "meta media" "title media" "sub media" "quote media" "topics media" ". media" "cue cue";
  }
  .ch-hero__media{margin:0;padding-block:clamp(1.25rem,3cqi,2rem)}
  .ch-hero__title{font-size:clamp(2rem,5.6cqi,3.4rem)}
  .ch-hero__grid .ch-hero__title--long{font-size:clamp(1.6rem,3cqi,2.15rem)}
  .ch-hero__cue{margin-top:.5rem}
}
@container (min-width:680px) and (max-width:959px){
  /* tablet two column: a slightly smaller meta row so the badge and reading time share one line */
  .ch-hero .badge{font-size:.72rem;padding:.15rem .55rem}
  .ch-hero__time{font-size:.76rem}
  .ch-hero__meta{column-gap:.5rem}
}
@container (min-width:960px){
  .ch-hero__grid{grid-template-columns:minmax(0,.92fr) minmax(0,1.3fr)}
}
/* no video: a single text column at every width (after the wide rules so it wins) */
.ch-hero--art .ch-hero__grid{--reach:0px;grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-template-areas:"meta" "title" "sub" "quote" "topics" "cue";padding-top:clamp(1.5rem,4cqi,2.75rem)}

/* Print: the hero becomes a plain title block */
@media print{
  .ch-hero{border:0;background:none;overflow:visible}
  .ch-hero__media,.ch-hero__art,.ch-hero__cue{display:none}
}
.ch-hero__sub span{color:var(--ink-text);font-weight:620}
.ch-hero__title--long{font-size:clamp(1.5rem,6cqi,2.5rem)}
