/* xag-layout-rules.css: the AD AND IMAGE LAYOUT RULES (owner 2026-11-09), one reusable layout for every page. Audit: test/ad-rules.test.mjs (markup + this file) and scripts/ad-rules-sweep.mjs (computed, needs Edge).
   RULE 1  TOP of a page (above the first text block): an image or ad is a BANNER only: wide, centred, rotating allowed.     class  .xag-lead-banner  (ratio never below 2.4 : 1, or 2 : 1 on a phone)
   RULE 2  MID page (anywhere else): ONE rectangular ad, justified to the left or right edge of the content column, only when it lines up with its neighbours (same top edge, same bottom edge,
           one gap of 16 px). Beside text:   <div class="xag-side-row [xag-side-row--left]"> text + <aside class="xag-side-box"> ad </aside> </div>
   RULE 3  Where lining up with text is hard, the ad gets a partner of the OPPOSITE kind on the other side (an ad beside an image, never an ad beside an ad or an image beside an image), both
           boxes the same size:   <div class="xag-duo [xag-duo--flip]"> <div class="xs-band" data-xag-set="..."></div> <div class="xag-slot" data-xag-slot="..." hidden></div> </div>
           A pair whose advert is empty is hidden as a whole (no half pair). On a phone a pair stacks: the image first, the ad under it, both full width.
   Tokens only; spacing from --xag-sp-*. */
:root { --xag-box-gap: var(--xag-sp-3, 16px); --xag-side-w: 300px; --xag-box-radius: var(--xag-radius, 16px); }

/* RULE 1: the banner. Width = the content column, height from the ratio (never taller than 260 px), pictures cover the box. */
.xag-lead-banner { box-sizing: border-box; display: block; position: relative; width: 100%; max-width: none; margin: 0 auto var(--xag-box-gap); padding: 0; aspect-ratio: 2.4 / 1; max-height: 260px; overflow: hidden; border-radius: var(--xag-box-radius); }
.xag-lead-banner > :is(.xs-set, .xag-slot-item, .xs-house) { position: absolute; inset: 0; width: auto; height: auto; margin: 0; }
.xag-lead-banner .xs-stage, .xag-lead-banner .xs-house > .xs-ad { height: 100%; }
.xag-lead-banner .xs-stage { aspect-ratio: auto; }
.xag-lead-banner .xs-img, .xag-lead-banner .xag-slot-link img { width: 100%; height: 100%; object-fit: cover; }
.xag-lead-banner .xag-slot-link { height: 100%; }
.xag-lead-banner .xs-ad-logo { display: none; }   /* a banner is short: the headline and the button come first */
.xag-lead-banner .xs-ad-h { font-size: clamp(12px, 2.4cqw, 22px); }
.xs-band.xag-lead-banner { margin: 0 auto var(--xag-box-gap); }
.xag-slot.xag-lead-banner { max-width: none; padding: 0; margin: 0 auto var(--xag-box-gap); }
@media (max-width: 640px) { .xag-lead-banner { aspect-ratio: 2 / 1; max-height: none; } }

/* the house advert is slot > .xs-house > .xs-set > .xs-stage: every level fills the box, so the picture is as tall as the box */
:is(.xag-lead-banner, .xag-duo, .xag-side-box) .xs-house > .xs-set { height: 100%; }

/* RULE 2: one rectangular ad beside text, flush with the content edge, top and bottom edges shared with the text block */
.xag-side-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--xag-side-w); gap: var(--xag-box-gap); align-items: stretch; margin: var(--xag-sp-4, 24px) 0; }
.xag-side-row--left { grid-template-columns: var(--xag-side-w) minmax(0, 1fr); }
.xag-side-row--left > .xag-side-box { order: -1; }
.xag-side-box { box-sizing: border-box; margin: 0; padding: 0; width: 100%; max-width: none; min-width: 0; aspect-ratio: 6 / 5; max-height: 100%; overflow: hidden; border-radius: var(--xag-box-radius); align-self: start; }
.xag-side-box .xag-slot-link, .xag-side-box .xag-slot-link img, .xag-side-box .xs-house, .xag-side-box .xs-stage { height: 100%; }
.xag-side-box .xag-slot-link img { object-fit: cover; }
@media (max-width: 760px) { .xag-side-row, .xag-side-row--left { grid-template-columns: minmax(0, 1fr); } .xag-side-row--left > .xag-side-box { order: 0; } .xag-side-box { max-width: 420px; justify-self: end; } .xag-side-row--left > .xag-side-box { justify-self: start; } }

/* RULE 3: the pair. Two boxes of the same ratio side by side, one picture and one ad, ad on the right (or on the left with --ad-left). */
.xag-duo { box-sizing: border-box; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--xag-box-gap); align-items: stretch; width: 100%; max-width: 1200px; margin: var(--xag-sp-4, 24px) auto; padding: 0; }
.xag-duo > :is(.xag-slot, .xs-band) { box-sizing: border-box; position: relative; min-width: 0; min-height: 0; width: 100%; max-width: none !important; margin: 0 !important; padding: 0 !important; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--xag-box-radius); }
.xag-duo > :is(.xag-slot, .xs-band) > :is(.xs-set, .xs-house, .xag-slot-item) { position: absolute; inset: 0; width: auto; height: auto; margin: 0; }
.xag-duo .xs-stage, .xag-duo .xs-house > .xs-ad, .xag-duo .xag-slot-link { height: 100%; aspect-ratio: auto; }
.xag-duo .xag-slot-link img { width: 100%; height: 100%; object-fit: cover; }
.xag-duo .xag-slot-more { position: absolute; right: 8px; bottom: 6px; margin: 0; text-align: right; }
.xag-duo--flip > .xag-slot { order: -1; }
.xag-duo:has(> .xag-slot[hidden]) { display: none; }
@media (max-width: 760px) { .xag-duo { grid-template-columns: minmax(0, 1fr); } .xag-duo--flip > .xag-slot { order: 0; } }
@media print { .xag-lead-banner, .xag-side-row, .xag-duo { display: none !important; } }
