/* ============================================================================
 * Botanica — CONTROL LAYER (round 4, R4-01)
 *
 * WHY THIS FILE EXISTS
 * Three defects across rounds 2 and 3 shared one shape: legacy theme CSS beat a
 * component that exposes a control to the client, while getComputedStyle happily
 * reported success.
 *   round 2 — cover overlay span at 0x0: darkening set, painted nothing
 *   round 2 — Parisienne had no @font-face, silently fell back
 *   round 3 — `color:#FBF7EF!important` beat every hero colour swatch
 * Catching the fourth one is not a plan. This file makes the class impossible.
 *
 * HOW IT WORKS
 * CSS cascade layers invert for `!important`: among author important
 * declarations, EARLIER layers win, and unlayered important ranks LOWEST.
 * So an important declaration inside the first-declared layer cannot be beaten
 * by any unlayered rule in the theme, in GeneratePress or in WooCommerce —
 * regardless of specificity, source order, or its own `!important`.
 *
 * Only the whole theme staying UNLAYERED makes this safe: layering everything
 * would push theme normal declarations below unlayered plugin CSS. This file is
 * therefore deliberately narrow — it protects the controllable properties and
 * nothing else.
 *
 * WHAT BELONGS HERE
 * Only properties a client-facing control writes to. Adding a rule here means
 * "the owner controls this and the theme may not argue". Everything structural
 * (position, z-index, overflow, transitions) stays in style.css.
 *
 * Proof that it holds lives in the control-effectiveness suite (R4-02):
 *   python3 scratchpad/r4_controls.py
 * which injects a hostile `!important` rule per property and asserts the control
 * still wins by PAINTED result.
 * ========================================================================== */

@layer bc-control;

@layer bc-control {

  /* ---- hero: the text block's position, width and alignment --------------
     Controls: drag-to-position, "Teksto pločio riba", "Lygiavimas". */
  .botanica .bc-hero.bh .bh__block{
    --bh-w-eff:max(var(--bh-maxw,74%),min(240px,100% - 2*var(--pad,20px)))!important;
    left:clamp(calc(var(--bh-w-eff) / 2), var(--bh-x,50%), calc(100% - var(--bh-w-eff) / 2))!important;
    top:clamp(var(--bh-halfy,25%), var(--bh-y,50%), calc(100% - var(--bh-halfy,25%)))!important;
    width:var(--bh-w-eff)!important;
    /* max-width must be protected too: a hostile max-width constrains the box
       even when width itself is protected (found by the R4-02 hostile control). */
    max-width:calc(100% - 2*var(--pad,20px))!important;
    text-align:var(--bh-align,center)!important;
    align-items:var(--bh-items,center)!important;
    /* ---- hero: text plate (R9). Control "Teksto fonas". The photo is never
           touched, so this panel is the only thing standing between cream type
           and a bright photograph — it has to be un-overridable like the rest. */
    background:var(--bh-plate,none)!important;
    -webkit-backdrop-filter:var(--bh-plate-blur,none)!important;
    backdrop-filter:var(--bh-plate-blur,none)!important;
    padding:var(--bh-plate-pad,0)!important;
    /* R-LOOP3 (HARD GATE #14): the block sizes tightly to its children with
       zero headroom, so the LAST visible line's descender ink (title, when
       lead/button are hidden — e.g. About) gets clipped by the overflow:
       hidden containment backstop in style.css. Fixing that in style.css
       alone did nothing: this layer's `padding` shorthand above is
       !important and always wins the bottom side too, regardless of
       specificity or source order (that IS this file's whole job — see the
       file header). So the safety margin has to be added HERE, as an
       !important override of just padding-bottom, using --bh-block-pb
       (hero-model.php) which is always a single valid scalar length (unlike
       --bh-plate-pad, which is sometimes a 2-value shorthand and cannot be
       fed into calc()). This still fully protects the plate's own vertical
       padding — --bh-block-pb already includes it when a plate is active. */
    padding-bottom:var(--bh-block-pb,12px)!important;
  }

  /* ---- hero: height. Control "Hero aukštis". ---------------------------- */
  .botanica .bc-hero.bh{
    height:var(--bh-h,660px)!important;
    min-height:var(--bh-h,660px)!important;
  }

  /* ---- hero: overlay strength + direction. Control "Nuotraukos
         patamsinimas". This is the property whose 0x0 box started it all. --- */
  .botanica .bc-hero.bh > .wp-block-cover__background{
    position:absolute!important;inset:0!important;display:block!important;
    background:var(--bh-overlay)!important;
    opacity:1!important;
  }

  /* ---- hero: photo framing (R10). Controls "Nuotraukos vieta" + "Priartinimas".
         The whole point is that the constant that used to live in the stylesheet
         is now hers, so nothing in a stylesheet may take it back. */
  .botanica .bc-hero .bc-hero__img{
    object-position:var(--bh-img-x,50%) var(--bh-img-y,50%)!important;
    scale:var(--bh-img-z,1)!important;
  }

  /* ---- hero: per-line typography. Controls: šriftas, storis, dydis, tarpai
         tarp raidžių, eilučių tarpai, spalva, rodyti/slėpti.
         `color` here is the exact declaration round 3 found being overridden. */
  .botanica .bc-hero.bh .bh__eyebrow{
    display:var(--bh-eyebrow-d,block)!important;
    font-family:var(--bh-eyebrow-ff)!important;font-weight:var(--bh-eyebrow-fw)!important;
    font-style:var(--bh-eyebrow-fi)!important;
    font-size:min(var(--bh-eyebrow-fs),calc(var(--bh-h,660px) * .05),max(3.6vw,0px))!important;
    letter-spacing:var(--bh-eyebrow-ls)!important;line-height:var(--bh-eyebrow-lh)!important;
    color:var(--bh-eyebrow-c)!important;
  }
  .botanica .bc-hero.bh .bh__script{
    display:var(--bh-script-d,block)!important;
    font-family:var(--bh-script-ff)!important;font-weight:var(--bh-script-fw)!important;
    font-style:var(--bh-script-fi)!important;
    font-size:min(var(--bh-script-fs),calc(var(--bh-h,660px) * .16),max(11vw,0px))!important;
    letter-spacing:var(--bh-script-ls)!important;line-height:var(--bh-script-lh)!important;
    color:var(--bh-script-c)!important;
  }
  .botanica .bc-hero.bh .bh__title{
    display:var(--bh-title-d,block)!important;
    font-family:var(--bh-title-ff)!important;font-weight:var(--bh-title-fw)!important;
    font-style:var(--bh-title-fi)!important;
    font-size:min(var(--bh-title-fs),calc(var(--bh-h,660px) * .22),max(13vw,0px))!important;
    letter-spacing:var(--bh-title-ls)!important;line-height:var(--bh-title-lh)!important;
    color:var(--bh-title-c)!important;
  }
  .botanica .bc-hero.bh .bh__lead{
    display:var(--bh-lead-d,block)!important;
    font-family:var(--bh-lead-ff)!important;font-weight:var(--bh-lead-fw)!important;
    font-style:var(--bh-lead-fi)!important;
    font-size:min(var(--bh-lead-fs),calc(var(--bh-h,660px) * .055),max(4.6vw,0px))!important;
    letter-spacing:var(--bh-lead-ls)!important;line-height:var(--bh-lead-lh)!important;
    color:var(--bh-lead-c)!important;
  }
  .botanica .bc-hero.bh .bh__button{display:var(--bh-button-d,block)!important;}
  .botanica .bc-hero.bh .bh__button .wp-block-button__link{
    font-family:var(--bh-button-ff)!important;font-weight:var(--bh-button-fw)!important;
    font-size:min(var(--bh-button-fs),calc(var(--bh-h,660px) * .04),max(3.6vw,0px))!important;
    letter-spacing:var(--bh-button-ls)!important;
  }

  /* ---- section background tone + show/hide (SE-02). --------------------- */
  .botanica .is-style-tone-light{background:#FFFFFF!important;}
  .botanica .is-style-tone-cream{background:var(--surface,#F4EFE4)!important;}
  .botanica .is-style-tone-dark{background:var(--ink,#2A2723)!important;}
  .botanica .is-style-tone-dark,
  .botanica .is-style-tone-dark h1,.botanica .is-style-tone-dark h2,
  .botanica .is-style-tone-dark h3,.botanica .is-style-tone-dark h4,
  .botanica .is-style-tone-dark p,.botanica .is-style-tone-dark li,
  .botanica .is-style-tone-dark .bc-eyebrow,.botanica .is-style-tone-dark .bc-meta{
    color:#FBF7EF!important;
  }

  /* ---- trust-icon sizing (SE-03). The normaliser guarantees the artwork;
         this guarantees the box it is drawn into. --------------------------- */
  .botanica .bc-iconstrip img{
    height:calc(var(--bi) * var(--benefit-scale,1))!important;
    width:calc(var(--bi) * var(--benefit-scale,1))!important;
    object-fit:contain!important;
  }
}
