/* The public home page, course finder and memo landing page have native
   Studio templates. They can render without a Pages et formations shortcode. */
@layer s3pages-studio {
  @scope (:is(.hv3, .studio-finder-page, .s3ff, .s3ff-dialog, .studio-memo))
      to ([data-cm-app], .cm-training-page, iframe, object, embed, .s3ff-reader, .s3ff-transcript) {
    :scope {
      --cm-page-text: #f2f5fa;
      --cm-page-muted: #c3cbd3;
      --cm-page-mint: #64e5d4;
      --cm-page-font: "3SAFE Pages Barlow", Barlow, "Segoe UI", sans-serif;
      --cm-page-face: linear-gradient(132deg, #343d46, #292e35 22%, #20232a 65%, #2d2932);
      --cm-page-edge: linear-gradient(122deg, #667980, #8cbcc2 5%, #668bab 13%, #455054 22%,
        #709585 32%, #434947 42%, #303139 54%, #8e80ab 68%, #67576e 78%, #a87988 85%, #bb967c 92%, #605d62);
      font-family: Inter, "Segoe UI", sans-serif !important;
      color: var(--cm-page-text) !important;
    }

    :is(h1,h2,h3,h4,h5,h6, .s3ff-title, .hv3-topic-caption strong, .hv3-roles strong) {
      font-family: var(--cm-page-font) !important;
      font-weight: 600 !important;
      color: var(--cm-page-text) !important;
      text-shadow: none !important;
    }
    :is(h1,h2,h3,h4) :is(span,strong,b,a) { color: inherit !important; }
    .hv3-hero h1 em, .hv3-eyebrow, .s3ff-family { color: #a8ebdf !important; }
    :is(.hv3-lead, .hv3-topic-caption span, .s3ff-meta, .s3ff-summary) { color: var(--cm-page-muted) !important; }
    :scope.hv3, :scope.studio-finder-page { background: #191a1b !important; }

    :is(.hv3-hero, .hv3-topic-grid a, .hv3-roles a, .s3m-card, .hv3-credentials li,
        .hv3-method li, .hv3-modes li, .hv3-questions details, .hv3-review-link,
        .s3ff-card, .s3ff form), :scope.studio-memo {
      background: var(--cm-page-face) padding-box, var(--cm-page-edge) border-box !important;
      border: 1px solid transparent !important;
      border-radius: 14px !important;
      clip-path: none !important;
      box-shadow: inset 0 1px 0 #d9e8ef29, inset 0 -1px 0 #b5a2c01f !important;
    }
    .hv3-hero-art { background-color: #20232a !important; }
    .hv3-hero-art img, .hv3-topic-photo img, .s3ff-cover img { filter: none; }
    .hv3-topic-caption { background: #23272e !important; }
    .hv3-topic-caption i { color: var(--cm-page-mint) !important; }
    :is(.hv3-hero, .hv3-topic-grid a, .hv3-roles a, .s3ff-card)::after { opacity: .65; }

    /* Center each short text group as a unit. The tallest card sizes its row,
       so an extra line in one description never pushes text off-centre in its neighbours. */
    :is(.hv3-modes > li, .hv3-method > li, .hv3-roles > li > a, .hv3-credentials > li,
        .s3m-card .s3m-info, .s3ff-card-copy) {
      display: flex !important;
      flex-direction: column !important;
      justify-content: center !important;
      align-items: center !important;
      gap: .45rem !important;
      box-sizing: border-box !important;
      padding: clamp(1rem, 2vw, 1.45rem) !important;
      text-align: center !important;
    }
    :is(.hv3-modes, .hv3-method, .hv3-roles, .hv3-credentials, .s3m-info, .s3ff-card-copy)
        :is(h3, p, strong, .hv3-role-icon) {
      margin: 0 !important;
      text-align: center !important;
    }
    :is(.hv3-roles strong, .s3m-info h3) { padding-inline: 0 !important; }
    .hv3-roles .hv3-role-icon { align-self: center !important; }
    .hv3-modes p, .hv3-method p { max-inline-size: 34ch; text-wrap: pretty; }
    .hv3-modes h3, .hv3-method h3 { text-wrap: balance; }
    .hv3-topic-caption {
      position: relative;
      flex: 1;
      flex-direction: column !important;
      align-items: center !important;
      justify-content: center !important;
      text-align: center !important;
      box-sizing: border-box;
      padding: .8rem 1rem 1rem !important;
    }
    .hv3-topic-caption > i { position: absolute; inset: .65rem .65rem auto auto; }
    .hv3-topic-caption > div { max-inline-size: 34ch; }
    .hv3-topic-caption strong, .hv3-topic-caption span, .s3m-info h3 > a { text-align: center !important; }
    .s3m-info h3 > a { justify-content: center !important; }
    .hv3-review-link > span { justify-content: center !important; text-align: center !important; }
    .hv3-review-link > span i { margin-inline-start: .45em !important; }

    :is(.hv3-btn, .hv3-text-link, .hv3-expand button, .hv3-gallery-controls button,
        .s3ffbtn, .s3ff-dialog-head button, .atlas-cta, .s3ff-more button) {
      font-family: var(--cm-page-font) !important;
      font-weight: 600 !important;
      color: #e8f4f3 !important;
      background: linear-gradient(#30363e, #252b32) !important;
      border: 1px solid #718088 !important;
      border-radius: 7px !important;
      text-shadow: none !important;
    }
    :is(.hv3-btn--primary, .studio-contact-cta--quote, .s3ffbtn.primary, .atlas-cta) {
      color: #c4fff2 !important;
      background: linear-gradient(125deg,#2c4243,#263437) !important;
      border-color: #76b8b0 !important;
    }
    :is(input[type="search"], input[type="text"], select) {
      color: var(--cm-page-text) !important;
      background-color: #252a31 !important;
      border-color: #6b777f !important;
      color-scheme: dark;
    }
    input::placeholder { color: #b6c1cb !important; opacity: 1; }
    :is(.hv3-btn, .s3ffbtn, .atlas-cta, .hv3-topic-grid a, .hv3-roles a):is([aria-disabled="true"],:disabled) {
      color: #a8b0bb !important;
      border-color: #586168 !important;
      background: #25292f !important;
    }
    :is(a,button,summary,input,select,textarea):focus-visible {
      outline: 3px solid var(--cm-page-mint) !important;
      outline-offset: 3px !important;
    }
    :is(.s3ffbtn, .hv3-btn)[aria-pressed="true"] {
      color: #d7fff5 !important;
      border-color: var(--cm-page-mint) !important;
      box-shadow: inset 3px 0 0 var(--cm-page-mint) !important;
    }
    @media (hover: hover) {
      :is(.hv3-btn, .hv3-text-link, .hv3-expand button, .hv3-gallery-controls button,
          .s3ffbtn, .s3ff-dialog-head button, .atlas-cta, .s3ff-more button):hover:not(:disabled,[aria-disabled="true"]) {
        color: #e9fff9 !important;
        background: #334649 !important;
        border-color: var(--cm-page-mint) !important;
      }
      :is(.hv3-topic-grid a,.hv3-roles a,.hv3-review-link):hover,
      :is(.s3ff-card,.s3m-card):focus-within {
        box-shadow: inset 0 0 0 1px #8cd8cd99, 0 3px 12px #080c1070 !important;
      }
    }
    @media (prefers-reduced-motion: no-preference) {
      :is(.hv3-btn, .hv3-topic-grid a, .hv3-roles a, .hv3-review-link, .s3ffbtn, .s3ff-card, .atlas-cta) {
        transition: color .14s ease, border-color .14s ease, box-shadow .14s ease !important;
      }
    }
    @media (prefers-reduced-motion: reduce) {
      :is(.hv3-btn, .hv3-topic-grid a, .hv3-roles a, .hv3-review-link, .s3ffbtn, .s3ff-card, .atlas-cta) {
        transition: none !important;
        transform: none !important;
      }
    }
    @media (forced-colors: active) {
      :is(.hv3-btn, .s3ffbtn, .atlas-cta, .hv3-topic-grid a, .hv3-roles a) { border-color: ButtonText !important; }
      :focus-visible { outline-color: Highlight !important; }
    }
  }
}

/* Theme-owned editorial fragments used alongside 3SAFE's training pages. */
@layer cybermo-pages-editorial {
  @media screen {
    :where(body.s3pages-editorial .studio-content-surface, .studio-entry > .s3v3-gallery,
           .studio-entry .s3m-grid, .studio-entry .studio-statistics) {
      --s3ep-ink: #f2f5fa;
      --s3ep-muted: #c4cdd4;
      --s3ep-mint: #91e8d9;
      --s3ep-edge: linear-gradient(137deg,#849ba3 0%,#82a4b7 10%,#526570 23%,#61746d 39%,#4c5158 52%,#81758c 72%,#a08a83 91%,#5f666b);
      --s3ep-glass: linear-gradient(124deg,#38424a 0%,#2c3339 17%,#252a2f 51%,#2d2b33 85%,#322f32);
    }

    @scope (body.s3pages-editorial .studio-content-surface) to (.cm-training-page,[data-cm-app],.s3ql-app,.safe3-qcm-library,.sqb-front,iframe) {
      :scope {
        color:var(--s3ep-ink)!important;
        background-color:#191a1b!important;
        font-family:"Segoe UI",Inter,system-ui,sans-serif!important;
      }
      .studio-editorial-head {border-color:#536268!important;}
      .studio-title,
      .studio-entry > section > :is(h2,h3),
      .studio-entry [data-s3prog-card] :is(h2,h3),
      .studio-entry .elementor-widget-heading .elementor-heading-title {
        font-family:"3SAFE Pages Barlow",Barlow,"Segoe UI",sans-serif!important;
        font-weight:600!important;
        color:var(--s3ep-ink)!important;
        text-shadow:none!important;
      }
      .studio-entry > section > :is(p,ul,ol), .studio-entry [data-s3prog-card] :is(p,li),
      .studio-entry .elementor-widget-text-editor {color:var(--s3ep-muted)!important;}
      .studio-entry > section > p > a:not(.s3v3-doc),
      .studio-entry .elementor-widget-text-editor a {color:var(--s3ep-mint)!important;text-underline-offset:.18em;}
      .studio-entry [data-s3prog-card] {
        position:relative;
        border:1px solid transparent!important;
        border-radius:12px!important;
        background:var(--s3ep-glass) padding-box,var(--s3ep-edge) border-box!important;
        box-shadow:inset 0 1px 0 #dcefff1a,0 5px 15px #1012144d!important;
        clip-path:none!important;
      }
      .studio-entry [data-s3prog-card] > :is(h3,p) {
        box-sizing:border-box;padding-inline:clamp(.85rem,2vw,1.35rem)!important;text-align:center!important;
      }
      .studio-entry [data-s3prog-card] .s3prog-action {
        padding:.55em .9em!important;
        border:1px solid #66958d!important;
        border-radius:8px!important;
        background:#294446!important;
        color:#e4fffa!important;
        font:600 1rem/1.3 "3SAFE Pages Barlow",Barlow,"Segoe UI",sans-serif!important;
        text-decoration:none!important;
      }
      .studio-entry [data-s3prog-card] .s3prog-action:is(:hover,:focus-visible) {
        background:#345052!important;
        border-color:#84e3d6!important;
      }
      :is(.studio-entry [data-s3prog-card] a,.studio-entry > section > p > a):focus-visible {
        outline:2px solid #79e7d5!important;outline-offset:3px!important;
      }
    }

    /* A gallery can be appended by the theme after a shortcode has already rendered. */
    @scope (.studio-entry > .s3v3-gallery) {
      :scope {color:var(--s3ep-ink)!important;font-family:"Segoe UI",Inter,system-ui,sans-serif!important;}
      :scope :is(h2,h3,summary), .s3v3-doc span {
        font-family:"3SAFE Pages Barlow",Barlow,"Segoe UI",sans-serif!important;
        font-weight:600!important;color:var(--s3ep-ink)!important;
      }
      :scope details {border-color:#52616a!important;background-color:#22272c!important;}
      :scope summary {cursor:pointer;}
      :scope summary::marker {color:var(--s3ep-mint)!important;}
      .s3v3-doc {
        position:relative;
        border:1px solid transparent!important;
        border-radius:11px!important;
        background:var(--s3ep-glass) padding-box,var(--s3ep-edge) border-box!important;
        color:var(--s3ep-ink)!important;
        clip-path:none!important;
        box-shadow:inset 0 1px 0 #daf5ff1c,0 4px 12px #1113164d!important;
        text-decoration:none!important;
      }
      .s3v3-doc:is(:hover,:focus-visible) {border-color:#8ad9ce!important;background:#334247!important;}
      :is(.s3v3-doc,summary):focus-visible {outline:2px solid #79e7d5!important;outline-offset:3px!important;}
      .s3v3-doc img {background-color:#e8ebea!important;border-radius:4px!important;object-fit:contain!important;}
      .s3v3-doc > span {box-sizing:border-box;padding:.35rem .55rem!important;text-align:center!important;}
    }

    /* The IPRP hub upgrades its eight module cards after WordPress processes the shortcode. */
    @scope (.studio-entry .s3m-grid) {
      .s3m-card {
        position:relative;border:1px solid transparent!important;border-radius:12px!important;
        background:var(--s3ep-glass) padding-box,var(--s3ep-edge) border-box!important;
        color:var(--s3ep-ink)!important;clip-path:none!important;
        box-shadow:inset 0 1px 0 #daf5ff1c,0 4px 12px #1113164d!important;
      }
      .s3m-info h3,.s3m-info h3 > a {
        color:var(--s3ep-ink)!important;
        font-family:"3SAFE Pages Barlow",Barlow,"Segoe UI",sans-serif!important;font-weight:600!important;
      }
      .s3m-info h3 > a:is(:hover,:focus-visible),.s3m-info h3 > a span {color:var(--s3ep-mint)!important;}
      .s3m-info {padding:clamp(.85rem,1.6vw,1.15rem)!important;background:transparent!important;}
      .s3m-info h3,.s3m-info h3 > a {text-align:center!important;justify-content:center!important;}
      .s3m-points,.s3m-points li {color:var(--s3ep-muted)!important;font-family:"Segoe UI",Inter,system-ui,sans-serif!important;}
      .s3m-points li::marker {color:var(--s3ep-mint)!important;}
      .s3m-info a:focus-visible {outline:2px solid #79e7d5!important;outline-offset:3px!important;}
    }

    /* These native statistics also appear outside the surrounding plugin's HTML. */
    @scope (.studio-entry .studio-statistics) to ([data-cm-app],iframe) {
      :scope {font-family:"Segoe UI",Inter,system-ui,sans-serif!important;}
      :scope :is(h2,h3,h4), .s3st-card > strong {
        color:var(--s3ep-ink)!important;font-family:"3SAFE Pages Barlow",Barlow,"Segoe UI",sans-serif!important;
        font-weight:600!important;
      }
      .s3st :is(.s3st-card,.s3st-panel,.s3st-act-small) {
        border:1px solid transparent!important;border-radius:12px!important;
        background:var(--s3ep-glass) padding-box,var(--s3ep-edge) border-box!important;
        color:var(--s3ep-ink)!important;
      }
      .s3st :is(.s3st-note,.s3st-theme-name,.s3st-bar-label,.s3st-group-name,.s3st-axis) {color:var(--s3ep-muted)!important;}
      .s3st-period {border-color:#57766f!important;background:#283a3b!important;color:#c0ece4!important;}
      .s3st .s3st-card {
        align-items:center!important;justify-content:center!important;text-align:center!important;
        padding:clamp(.8rem,1.5vw,1.15rem)!important;
      }
      :scope a {color:var(--s3ep-mint)!important;}
    }
  }
}
