/*
 * BERKE DESIGN CONTRACT v1.1 — 0.22.1
 * This file is deliberately enqueued LAST. It owns invariants, not aesthetics.
 */

/* Surface contract ------------------------------------------------------- */
body.berke-system-v0200 main [data-berke-surface="dark"]{
  color:var(--berke-color-white,#fff)!important;
}
body.berke-system-v0200 main [data-berke-surface="dark"] :where(
  h1,h2,h3,h4,h5,h6,p,li,dt,dd,summary,label,legend,blockquote,
  [class*="__title"],[class*="__heading"],[class*="__lead"],[class*="__copy"]
){color:var(--berke-color-white,#fff)!important}
body.berke-system-v0200 main [data-berke-surface="dark"] :where(
  small,figcaption,[class*="__meta"],[class*="__caption"],[class*="__eyebrow"],[class*="__kicker"]
){color:#bfeaff!important}
body.berke-system-v0200 main [data-berke-surface="dark"] a:not([class*="button"]):not(.button):not([role="button"]):not([data-berke-surface="light"] *){color:#9fe8ff!important}
body.berke-system-v0200 main [data-berke-surface="light"]{
  color:var(--berke-color-text,#173f55)!important;
}
body.berke-system-v0200 main [data-berke-surface="light"] :where(h1,h2,h3,h4,h5,h6,[class*="__title"],[class*="__heading"]){color:var(--berke-color-heading,#0f2439)!important}
body.berke-system-v0200 main [data-berke-surface="light"] :where(p,li,dt,dd,summary,label,legend,small,figcaption,[class*="__meta"],[class*="__caption"]){color:var(--berke-color-text,#173f55)!important}


/* Button contrast contract ------------------------------------------------
 * Buttons are their own surface. A dark-section link rule must never recolor
 * a white/light button. Light/secondary button text stays deep navy so the
 * foreground remains readable on white and near-white fills.
 */
body.berke-system-v0200 main :where(a,button,[role="button"])[class*="button--light"],
body.berke-system-v0200 main :where(a,button,[role="button"])[class*="button--secondary"]{
  color:#123a5a!important;
  text-shadow:none!important;
}
body.berke-system-v0200 main :where(a,button,[role="button"])[class*="button--light"] :where(svg,path),
body.berke-system-v0200 main :where(a,button,[role="button"])[class*="button--secondary"] :where(svg,path){
  color:currentColor!important;
  stroke:currentColor;
}
body.berke-system-v0200 main [data-berke-surface="dark"] :where(a,button,[role="button"])[class*="button--light"],
body.berke-system-v0200 main [data-berke-surface="dark"] :where(a,button,[role="button"])[class*="button--secondary"]{
  color:#123a5a!important;
}

/* Split media/copy contract -------------------------------------------- */
@media (min-width:56.001rem){
  body.berke-system-v0200 main [data-berke-section-edge="v1"]{
    align-items:stretch!important;
  }
  body.berke-system-v0200 main [data-berke-section-edge="v1"] > *{
    align-self:stretch!important;
    min-block-size:0!important;
    margin-block-start:0!important;
    margin-block-end:0!important;
  }
  body.berke-system-v0200 main [data-berke-section-edge="v1"] > :where(figure,[class*="__visual"],[class*="__media"]){
    display:flex!important;
    flex-direction:column!important;
    block-size:100%!important;
    max-block-size:none!important;
  }
  body.berke-system-v0200 main [data-berke-section-edge="v1"] > :where(figure,[class*="__visual"],[class*="__media"]) :where(picture,img):first-child{
    flex:1 1 auto!important;
    min-block-size:0!important;
  }
  body.berke-system-v0200 main [data-berke-section-edge="v1"] > :where(figure,[class*="__visual"],[class*="__media"]) img{
    inline-size:100%!important;
    block-size:100%!important;
    max-block-size:none!important;
    object-fit:cover!important;
  }
}

/* Hero contract --------------------------------------------------------- */
@media (min-width:56.001rem){
  body.berke-system-v0200 main [data-berke-hero-contract="v3"] [data-berke-hero-grid]{align-items:stretch!important}
  body.berke-system-v0200 main [data-berke-hero-contract="v3"] :where([data-berke-hero-copy],[data-berke-hero-visual]){
    align-self:stretch!important;
    block-size:100%!important;
    margin-block:0!important;
  }
  body.berke-system-v0200 main [data-berke-hero-contract="v3"] [data-berke-hero-copy]{justify-content:flex-start!important}
  body.berke-system-v0200 main [data-berke-hero-contract="v3"] [data-berke-hero-completion]{margin-block-start:auto!important}
  body.berke-system-v0200 main [data-berke-hero-contract="v3"] [data-berke-hero-visual] img{
    block-size:100%!important;
    max-block-size:none!important;
    object-fit:cover!important;
  }
}

/* Prevent common structural regressions -------------------------------- */
body.berke-system-v0200 main img{max-inline-size:100%;height:auto}
body.berke-system-v0200 main :where(a,button,input,select,textarea){max-inline-size:100%}
@media (max-width:56rem){
  body.berke-system-v0200 main [data-berke-section-edge="v1"] > *,
  body.berke-system-v0200 main [data-berke-hero-contract="v3"] :where([data-berke-hero-copy],[data-berke-hero-visual]){
    block-size:auto!important;
    min-block-size:0!important;
  }
}

/* Admin-only runtime QA badge/panel ------------------------------------ */
.berke-design-qa-badge{display:inline-flex;align-items:center;gap:.35rem;padding:.22rem .55rem;border-radius:999px;font-size:11px;font-weight:800;cursor:pointer;border:1px solid rgba(255,255,255,.28)}
.berke-design-qa-badge.is-pass{background:#0d6b4c;color:#fff}.berke-design-qa-badge.is-fail{background:#9d2e2e;color:#fff}.berke-design-qa-badge.is-wait{background:#65551a;color:#fff}
.berke-design-qa-panel{position:fixed;z-index:999999;inset-block-start:72px;inset-inline-start:16px;inline-size:min(420px,calc(100vw - 32px));max-block-size:70vh;overflow:auto;padding:16px;background:#fff;color:#14293b;border:1px solid #cbd8e0;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.25);direction:rtl;font-family:inherit}
.berke-design-qa-panel[hidden]{display:none}.berke-design-qa-panel h3{margin:0 0 10px;color:#0f2439!important}.berke-design-qa-panel ul{margin:0;padding-inline-start:20px}.berke-design-qa-panel li{margin-block:6px;color:#25445b!important;font-size:13px!important}.berke-design-qa-panel button{margin-block-start:12px}
