/* ==========================================================================
   07 · FEATURED  (#featured) — cinematic night scene
   Giant ochre sun · black pagoda on its hill · pines · woodblock wave ·
   two pale cranes · scalloped ink mounds with gold contours · gold kumo,
   wave engraving and orbits.

   Geometry: everything in the scene hangs off a zero-size anchor placed at the
   sun's centre (.featured__poster) and is measured in "sun units":
       --u = 1% of the sun's diameter          (inline SVG silhouettes: 10 units = 1u)
   Re-composing a layout = changing --sun-d / --sun-cx / --sun-cy and a few
   per-piece offsets (--x / --y = top-left from the sun's centre, --w = width).
   CSS alone gives the final, resting composition; featured.js only adds depth.

   Two compositions:
     PORTRAIT  (base: phones, tablets, tall windows) — poster on top like the mockup panel, copy beneath
     LANDSCAPE (min-width 700px + aspect ≥ 5/4)     — full-bleed cinema frame, copy lower-left on the front mound
   ========================================================================== */

.featured {
  /* local palette (no token exists for the deeper silhouette black) */
  --featured-sky: var(--ink);
  --featured-deep: #0c0c0b;                      /* silhouettes + ground: a breath darker than the sky */
  --featured-gold: var(--gold-line);
  --featured-rim: rgba(185, 138, 62, .62);       /* --gold-line as a hairline */

  /* sun (portrait) */
  --sun-d: min(80vw, 58vh);
  --sun-cx: 50%;
  --sun-cy: calc(var(--sun-d) * .5 + clamp(3.4rem, 11vw, 6rem));
  --u: calc(var(--sun-d) / 100);

  position: relative; z-index: 0; isolation: isolate;
  color: var(--parchment);
  overflow-x: clip;
  /* art theming: gold linework, ochre sun, knock-outs to the deep black */
  --art-paper: var(--featured-deep);
  --art-gold: var(--ochre);
  --art-accent: var(--ochre);
  --art-sun: var(--ochre);
}

/* ---------- scene ---------- */
.featured__scene {
  position: absolute; inset: 0; z-index: -1;          /* inside the section's own stacking context: below the copy */
  background: var(--featured-sky);
  overflow: hidden; overflow: clip;
  pointer-events: none; user-select: none;
  /* organic top edge: level on the left, the horizon falls away to the right (SVG clipPath, bounding-box units) */
  -webkit-clip-path: url(#featured-horizon-tall); clip-path: url(#featured-horizon-tall);
}
.featured--flat-top .featured__scene { -webkit-clip-path: none; clip-path: none; }
.featured--flat-top .featured__edge { display: none; }
.featured__defs { position: absolute; }

/* hairline echo of the top edge: same curve, a few px inside */
.featured__edge { position: absolute; left: 0; top: 10px; width: 100%; height: 100%; overflow: visible; z-index: 3; }
.featured__edge path { fill: none; stroke: var(--featured-gold); stroke-width: 1px; vector-effect: non-scaling-stroke; opacity: .55; }
.featured__edge .featured__edge-bead { stroke-width: 5px; stroke-linecap: round; opacity: .9; }
.featured__edge--echo { top: 21px; }
.featured__edge--echo path { opacity: .3; stroke-dasharray: 1 7; stroke-linecap: round; }
.featured__edge-wide { display: none; }

/* stars */
.featured .featured__stars { position: absolute; inset: 0; color: var(--parchment); opacity: .55; }
.featured__twinkles { position: absolute; inset: 0; }
.featured__spark {
  position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  color: var(--parchment); opacity: .85; overflow: visible;
  animation: featured-twinkle var(--t, 6s) var(--ease-in-out) var(--dl, 0s) infinite;
  animation-play-state: paused;
}
.featured__spark--gold { color: var(--ochre); }
.featured.is-inview .featured__spark { animation-play-state: running; }
@keyframes featured-twinkle {
  0%, 46%, 70%, 100% { opacity: .85; transform: scale(1); }
  58% { opacity: .1; transform: scale(.5) rotate(20deg); }
}

/* poster anchor = the sun's centre */
.featured__poster { position: absolute; left: var(--sun-cx); top: var(--sun-cy); width: 0; height: 0; }
.featured__layer { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
/* every piece: --x/--y = top-left offset from the sun's centre, --w = width (sun units) */
.featured__layer > * { position: absolute; max-width: none; left: calc(var(--u) * var(--x)); top: calc(var(--u) * var(--y)); width: calc(var(--u) * var(--w)); height: auto; }

/* orbits */
/* halo: one hairline ring + one dotted ring + three beads, concentric with the sun */
.featured__halo { --w: 140; --x: -70; --y: -70; overflow: visible; fill: none; }
.featured__halo circle { vector-effect: non-scaling-stroke; }
.featured__halo-ring { stroke: var(--featured-gold); stroke-width: 1px; opacity: .55; }
.featured__halo-dots { stroke: var(--featured-gold); stroke-width: 1.6px; stroke-linecap: round; stroke-dasharray: .1 13; opacity: .42; }
.featured__halo-bead { fill: var(--featured-gold); stroke: none; opacity: .9; }
.featured__halo-bead--sun { fill: var(--ochre); }

/* the sun */
.featured__sun {
  --w: 100; --x: -50; --y: -50;
  height: calc(var(--u) * 100) !important;
  border-radius: 50%;
  background: var(--ochre);
  box-shadow: inset 0 0 0 1px rgba(126, 80, 10, .35), inset 0 0 calc(var(--u) * 9) rgba(150, 92, 12, .22);
}
/* with the procedural woodblock disc mounted, its hand-cut edge becomes the sun's edge;
   a slightly smaller ochre-deep disc shows through the print's mottle, grain and salt */
.featured.has-sun-art .featured__sun { background: radial-gradient(closest-side, var(--ochre-deep) 0 94%, transparent 94.4%); box-shadow: none; }
.featured__sun-art { position: absolute; inset: 0; }
.featured__sun-art > svg { overflow: visible; }
.featured__sun-cracks { position: absolute; inset: 0; width: 100%; height: 100%; color: #7a4a0c; opacity: .22; }

/* inline silhouettes (10 SVG units = 1u; sun r = 500 at 0,0) */
.featured__sil { overflow: visible; }
/* the ranges dissolve toward the far left instead of ending on a hard vertical cut */
.featured__sil--far, .featured__sil--mid .featured__sil-rim { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16%, #000 86%, transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 16%, #000 86%, transparent 100%); }
.featured__sil--far { --w: 260; --x: -150; --y: 10; fill: var(--featured-deep); opacity: .3; }
.featured__sil--mid { --w: 260; --x: -150; --y: -48; }
.featured__sil-ink { fill: var(--featured-deep); }
.featured__sil-rim path { fill: none; stroke: var(--featured-gold); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.featured__sil-rim { opacity: .75; }
.featured__sil-bells { fill: none; stroke: var(--featured-deep); stroke-width: 1.6; }
.featured__sil-lit { fill: var(--ochre); opacity: .94; }

/* wave */
.featured__wave { --w: 58; --x: -68; --y: -12; aspect-ratio: 1670 / 1520; }
.featured__wave img { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ground */
.featured__ground { position: absolute; left: -150vw; width: 300vw; top: calc(var(--u) * 60); height: 400vh; background: var(--featured-deep); }
.featured__ground--right { left: calc(var(--u) * 109.5); width: 300vw; top: calc(var(--u) * 49.2); }   /* continues the hill beyond its right end */
.featured__mound {
  aspect-ratio: 1; border-radius: 50%; box-sizing: border-box;
  background: var(--featured-deep); border: 1px solid var(--featured-rim);
}
.featured__mound::before, .featured__mound::after {
  content: ""; position: absolute; border-radius: 50%; border: 1px solid var(--featured-rim);
  inset: calc(var(--u) * 3.4); opacity: .55;
}
.featured__mound::after { inset: calc(var(--u) * 6.8); opacity: .26; }
.featured__mound--l { --w: 170; --x: -150; --y: 36; }
.featured__mound--r { --w: 150; --x: 6; --y: 44; }
.featured__mound--c { --w: 120; --x: -66; --y: 58; }

/* gold engraving */
.featured__engrave { opacity: .5; }
.featured__engrave--l { --w: 86; --x: -64; --y: 98; opacity: .3; }
.featured__engrave--r { --w: 70; --x: -2; --y: 58; transform: scaleX(-1); opacity: .7; }

/* gold kumo */
.featured .featured__cloud { color: var(--featured-gold); opacity: .85; }
.featured__cloud--a { --w: 38; --x: -70; --y: -44; }
.featured__cloud--b { --w: 32; --x: 30; --y: 9; }
.featured__cloud--c { --w: 50; --x: -58; --y: 40; opacity: .55; }

/* THE FLOCK — three cranes on one straight line, moved as one group.
   sizes  : 100% / 90% / 80% of --crane-w (base.css)            → arithmetic progression, step −10%
   anchors: bird 1 sits near the RIGHT EDGE of the screen, crossing the night's top edge (--ax, --ay);
            bird 3 sits on the sun's right shoulder (--bx, --by, in sun units)
   gaps   : arithmetic progression in step with the sizes — every gap is proportional to the mean size of
            the two birds beside it (gap 1→2 : gap 2→3 = .95 : .85). Centre distances then split the line
            in the same ratio, so bird 2 sits at t = .95 / (.95 + .85) = .5278 between the anchors —
            true at every viewport, no script needed. */
.featured__flock {
  --ax: calc(50vw - var(--crane-w) * .5 - 2.5vw);        /* portrait: sun-cx = 50% → this is the right screen edge minus a margin */
  --ay: calc(var(--sun-cy) * -1 + var(--crane-w) * .18);  /* centre just below the section's top edge: the bird crosses it */
  --bx: calc(var(--u) * 38); --by: calc(var(--u) * -7);
  --t: .5278;
  position: absolute; z-index: 1; left: var(--sun-cx); top: var(--sun-cy); width: 0; height: 0;
  pointer-events: none; will-change: transform;
}
.featured__flock .featured__crane { position: absolute; translate: -50% -50%; }
.featured__flock .featured__crane img { display: block; width: 100%; height: auto; rotate: 172deg; }
.featured__crane--1 { width: var(--crane-w); left: var(--ax); top: var(--ay); }
.featured__crane--2 { width: calc(var(--crane-w) * .9); left: calc(var(--ax) + (var(--bx) - var(--ax)) * var(--t)); top: calc(var(--ay) + (var(--by) - var(--ay)) * var(--t)); }
.featured__crane--3 { width: calc(var(--crane-w) * .8); left: var(--bx); top: var(--by); }
.featured.is-inview .featured__flock .featured__crane img { animation: featured-glide 12s var(--ease-in-out) infinite alternate; }   /* in unison */
@keyframes featured-glide {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(calc(var(--u) * .9), calc(var(--u) * -1.3), 0); }
}

/* brushed foot (the edge-brush piece has its torn side up, so it is flipped to tear downward) */
.featured__foot { position: absolute; z-index: 3; left: 0; right: 0; top: calc(100% - 2px); height: clamp(28px, 4.6vw, 78px); color: var(--featured-deep); transform: scaleY(-1); pointer-events: none; }
.featured__foot > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.theme-dark .featured__foot.art { color: var(--featured-deep); }

/* ---------- content (portrait) ---------- */
.featured__inner {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: minmax(0, 1fr); row-gap: clamp(2.4rem, 7vw, 3.5rem);
  padding-top: calc(var(--sun-cy) + var(--u) * 66);
  padding-bottom: clamp(4.5rem, 14vw, 7rem);
}
.featured__title {
  font-size: clamp(3rem, 14.2vw, 7.75rem);
  line-height: 1.03; letter-spacing: -.03em; font-weight: 400;
  /* light-on-dark at poster size: a lower optical size keeps the Bodoni hairlines from dissolving */
  font-optical-sizing: none; font-variation-settings: "opsz" 26;
  color: var(--cream); text-wrap: nowrap; white-space: nowrap;
}
.featured__title em { display: inline-block; font-size: 1.15em; line-height: 1; letter-spacing: -.03em; padding-right: .08em; font-variation-settings: "opsz" 22; }
.featured__actions { display: grid; justify-items: start; gap: 1.5rem; margin-top: clamp(1.9rem, 6vw, 3rem); }
.featured__cta { justify-content: space-between; }

/* label stack: on portrait it becomes one tracked line under a hairline */
.featured__aside { display: grid; gap: 1.1rem; color: var(--paper-80); }
.featured__aside-line { display: none; }
.featured__aside-rule { order: -1; height: 1px; background: linear-gradient(90deg, var(--featured-gold), var(--line-dark) 55%); position: relative; }
.featured__aside-rule::before { content: ""; position: absolute; left: 0; top: -3px; width: 7px; height: 7px; background: var(--featured-gold); transform: rotate(45deg); }
.featured__stack { display: flex; flex-wrap: wrap; gap: .5em 1.15em; font-size: .62rem; }
.featured__stack span:nth-child(2)::after { content: "✦"; margin-left: 1.15em; color: var(--ochre); letter-spacing: 0; }

/* ---- small phones ---- */
@media (max-width: 479px) {
  .featured__cta { width: 100%; }
}

/* ---- tablets / roomy portrait: stack returns to the right edge, beside the copy ---- */
@media (min-width: 600px) {
  .featured { --sun-d: min(72vw, 54vh); --sun-cx: 47%; }
  .featured__flock { --ax: calc(53vw - var(--crane-w) * .5 - 3vw); --bx: calc(var(--u) * 41); --by: calc(var(--u) * -9); }
  .featured__inner { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .featured__title { font-size: clamp(4.5rem, 12vw, 8.5rem); }
  .featured__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.4rem 2.4rem; }
  .featured__aside { grid-template-columns: auto auto; align-items: start; gap: 0 1.5rem; margin-top: calc(var(--u) * -34); }
  .featured__aside-line { display: block; grid-row: 1 / span 2; width: 1px; height: clamp(9rem, 22vw, 14rem); background: var(--featured-gold); position: relative; opacity: .8; }
  .featured__aside-line::after { content: ""; position: absolute; left: 50%; bottom: -3px; width: 7px; height: 7px; margin-left: -3.5px; background: var(--featured-gold); transform: rotate(45deg); }
  .featured__stack { display: grid; gap: 1.15em; padding-top: 1.2rem; font-size: .64rem; }
  .featured__stack span:nth-child(2)::after { content: none; }
  .featured__aside-rule { order: 0; grid-column: 2; width: 3.4rem; margin-top: 1.6rem; background: var(--line-strong); }
  .featured__aside-rule::before { content: none; }
}

/* ==========================================================================
   LANDSCAPE — the cinema frame
   ========================================================================== */
@media (min-width: 700px) and (min-aspect-ratio: 5/4) {
  .featured {
    --H: max(54vh, 21rem);                       /* client: quote strip (26vh) + this scene (54vh) = 80vh together */
    --sun-d: min(45vw, calc(var(--H) * .66));
    --sun-cx: 63.5%;
    --sun-cy: calc(var(--H) * .455);
    min-height: var(--H);
    display: grid; align-items: end;
  }
  .featured__scene { -webkit-clip-path: url(#featured-horizon-wide); clip-path: url(#featured-horizon-wide); }
  .featured__edge-wide { display: block; }
  .featured__edge-tall { display: none; }

  .featured__inner {
    position: static;                              /* the aside anchors to the section, next to the sun */
    grid-template-columns: minmax(0, 1fr);
    padding-top: clamp(1.5rem, 4vh, 4rem);
    padding-bottom: clamp(1.4rem, 4.2vh, 3.6rem);
  }
  .featured__title { font-size: clamp(2.2rem, min(5.2vw, 7.6vh), 6rem); line-height: 1.04; }
  .featured__actions { margin-top: clamp(1rem, 2.6vh, 2.2rem); }

  .featured__aside { position: absolute; right: var(--gutter); top: calc(var(--sun-cy) - var(--u) * 13); margin-top: 0; }
  .featured__aside-line { height: clamp(5rem, 15vh, 10rem); }

  /* poster offsets for the wide frame */
  .featured__cloud--a { --w: 38; --x: -104; --y: -42; }                /* left shoulder: balances the flock on the right */
  .featured__flock { --ax: calc(36.5vw - var(--crane-w) * .5 - 2.2vw); --bx: calc(var(--u) * 47); --by: calc(var(--u) * -14); }
  .featured__cloud--b { --w: 30; --x: 31; --y: 9; }
}
@supports (height: 100svh) {
  @media (min-width: 700px) and (min-aspect-ratio: 5/4) {
    .featured { --H: max(54svh, 21rem); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .featured__spark, .featured.is-inview .featured__flock .featured__crane img { animation: none; }
}
