/* ==========================================================================
   CAREKA DIGITAL · V124.2 DUAL THEME + READABILITY MASTER
   Foreground polarity by rendered surface + premium readability floors
   ========================================================================== */

html[data-careka-theme="light"]{
  color-scheme:light;

  --cd1242-canvas:#F4F0E7;
  --cd1242-canvas-alt:#ECE6DA;
  --cd1242-surface:#FFFDF8;
  --cd1242-surface-alt:#F6F1E8;
  --cd1242-control:#FBF8F2;

  --cd1242-text:#15120E;
  --cd1242-body:#342F29;
  --cd1242-muted:#5B5349;
  --cd1242-faint:#6C6257;

  --cd1242-line:rgba(21,18,14,.19);
  --cd1242-line-strong:rgba(21,18,14,.31);

  --cd1242-gold:#7A5527;
  --cd1242-gold-hi:#68461F;
  --cd1242-gold-soft:rgba(122,85,39,.09);

  --cd1242-overlay:rgba(21,18,14,.42);
  --cd1242-shadow-sm:0 10px 34px rgba(55,42,28,.08);
  --cd1242-shadow-md:0 22px 66px rgba(55,42,28,.13);
  --cd1242-shadow-lg:0 34px 100px rgba(55,42,28,.19);
}

html[data-careka-theme="dark"]{
  color-scheme:dark;

  --cd1242-canvas:#070707;
  --cd1242-canvas-alt:#0B0B0B;
  --cd1242-surface:#101010;
  --cd1242-surface-alt:#161616;
  --cd1242-control:#121212;

  --cd1242-text:#F6F2EA;
  --cd1242-body:#DDD7CE;
  --cd1242-muted:#BDB5AA;
  --cd1242-faint:#A49B90;

  --cd1242-line:rgba(246,242,234,.19);
  --cd1242-line-strong:rgba(246,242,234,.31);

  --cd1242-gold:#D3A25D;
  --cd1242-gold-hi:#E6BD79;
  --cd1242-gold-soft:rgba(211,162,93,.11);

  --cd1242-overlay:rgba(0,0,0,.70);
  --cd1242-shadow-sm:0 10px 34px rgba(0,0,0,.30);
  --cd1242-shadow-md:0 22px 66px rgba(0,0,0,.40);
  --cd1242-shadow-lg:0 34px 100px rgba(0,0,0,.54);
}

/* --------------------------------------------------------------------------
   1 · THEME POLARITY
   Light surface => dark information.
   Dark surface => light information.
   -------------------------------------------------------------------------- */
html[data-careka-theme],
html[data-careka-theme] body{
  background:var(--cd1242-canvas)!important;
  color:var(--cd1242-text)!important;
}

html[data-careka-theme] body :where(
  h1,h2,h3,h4,h5,h6,strong,b,legend,th
){
  color:var(--cd1242-text)!important;
  text-shadow:none!important;
}

html[data-careka-theme] body :where(
  p,li,dd,dt,figcaption,label,td
){
  color:var(--cd1242-body)!important;
  text-shadow:none!important;
}

html[data-careka-theme] body :where(
  small,.muted,.meta,.eyebrow,.kicker,.section-index,
  [class*="eyebrow"],[class*="kicker"],[class*="label"],[class*="meta"]
){
  color:var(--cd1242-muted)!important;
  text-shadow:none!important;
}

/* Defeat stale V121 automatic contrast classifications when V124.2 owns it. */
html[data-careka-theme] body [data-cd1242-contrast="dark"]{
  color:#15120E!important;
  opacity:1!important;
  text-shadow:none!important;
}

html[data-careka-theme] body [data-cd1242-contrast="light"]{
  color:#F6F2EA!important;
  opacity:1!important;
  text-shadow:none!important;
}

html[data-careka-theme] body [data-cd1242-contrast][data-cd-contrast-auto]{
  opacity:1!important;
}

/* --------------------------------------------------------------------------
   2 · SMALL TEXT READABILITY
   H1-H6 sizes are deliberately untouched.
   These are visual floors, not a heading redesign.
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  .kicker,.eyebrow,.section-index,.stage-clock,
  .project-media-badge,.pillar-label,
  .service-card>span,.dialog-price span,.dialog-section>span,
  .editorial-label-row,.contact-channel>span,
  .menu-label,.ck-v75-feature__kicker,.ck-v75-cta__label,
  .ck-v75-num,.ck-v75-line-icon,.ck-v75-quickbar__label,
  .careka-legal-kicker,.careka-legal-toc span,
  .cd123-popover-title
){
  font-size:max(13px,.8125rem)!important;
  line-height:1.45!important;
}

html[data-careka-theme] body :where(
  nav a,
  .desktop-nav a,
  .menu-primary a,
  .menu-categories a,
  .menu-quick a,
  button,[role="button"],[role="tab"],summary
){
  font-size:max(14px,.875rem);
}

html[data-careka-theme] body :where(
  input,textarea,select
){
  font-size:max(16px,1rem)!important;
  line-height:1.45!important;
}

html[data-careka-theme] body :where(
  th,td
){
  font-size:max(14px,.875rem)!important;
  line-height:1.5!important;
}

/* Footer microcopy remains refined but no longer microscopic. */
html[data-careka-theme] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
) :where(
  p,a,button,small
){
  font-size:max(13px,.8125rem)!important;
  line-height:1.5!important;
}

/* --------------------------------------------------------------------------
   3 · VISIBILITY / OLD OPACITY STATES
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  main,section,article,aside,nav,header,footer,dialog,
  .panel,.card,.service-dialog,.all-projects-dialog,
  .cd-privacy-modal__panel,.cd123-popover
) :where(
  h1,h2,h3,h4,h5,h6,p,li,a,button,label,small,strong,b,em,
  summary,legend,th,td,
  span:not([aria-hidden="true"])
){
  filter:none!important;
  text-shadow:none!important;
}

html[data-careka-theme] body :where(
  [aria-current="page"],[aria-current="true"],
  [aria-selected="true"],[aria-checked="true"],
  details[open] > summary
){
  opacity:1!important;
}

/* --------------------------------------------------------------------------
   4 · STRUCTURAL LIGHT/DARK SURFACES
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  main,
  .scroll-scene,.hero-scene,.closing-scene,
  .page-section,.blogEditorial,.articlePage,.blogIndexPage,
  .ckContentBody,.careka-legal-page,.careka-legal-main,
  #portfolio,#pilares,#editorial,#sobre,#contato
){
  background-color:var(--cd1242-canvas)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line)!important;
}

html[data-careka-theme="light"] body.careka-v106-home :where(
  .scroll-scene,.hero-scene,.closing-scene
),
html[data-careka-theme="light"] body.careka-final-project :where(
  [data-cd121-role="project-hero"],
  main.container.hero > .panel.section:first-child,
  main.container > .panel.section:first-child
){
  background:var(--cd1242-canvas)!important;
  background-image:none!important;
  color:var(--cd1242-text)!important;
}

html[data-careka-theme="dark"] body.careka-v106-home :where(
  .scroll-scene,.hero-scene,.closing-scene
){
  background:var(--cd1242-canvas)!important;
  background-image:none!important;
}

/* --------------------------------------------------------------------------
   5 · HEADER / MENU
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  .site-header,.site-header.is-scrolled,
  .ck-header-v75,.ck-header-v75.is-scrolled,
  .topbar,.topbar.is-scrolled,
  .careka-legal-header
){
  background:var(--cd1242-surface)!important;
  color:var(--cd1242-text)!important;
  border-bottom:1px solid var(--cd1242-line-strong)!important;
  box-shadow:var(--cd1242-shadow-sm)!important;
  backdrop-filter:blur(18px) saturate(1.05)!important;
  -webkit-backdrop-filter:blur(18px) saturate(1.05)!important;
}

html[data-careka-theme] body :where(
  .site-header,.ck-header-v75,.topbar,.careka-legal-header
) :where(
  a,button,strong,b,.brand-copy strong,.brandtxt b,.ck-brand__text b
){
  color:var(--cd1242-text)!important;
}

html[data-careka-theme] body :where(
  .site-header,.ck-header-v75,.topbar,.careka-legal-header
) :where(
  small,.brand-copy small,.brandtxt small,.ck-brand__text small
){
  color:var(--cd1242-muted)!important;
}

html[data-careka-theme] body :where(
  .site-menu,.ck-mega-v75,.mega-menu
){
  background:var(--cd1242-surface)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line-strong)!important;
  box-shadow:var(--cd1242-shadow-lg)!important;
}

/* --------------------------------------------------------------------------
   6 · CARDS / PANELS / DETAILS
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  .panel,.card,.service-card,.service-details,
  .project-card,.project-slide,.story-layer,.pillar-card,.pillar-layer,
  .stat,.deliver,.ck-v75-card,.ck-v75-menu-card,
  .ckPostCard,.ckSidebarBox,.ckAnswerBox,.ckInsightBox,.ckInsightBlock,
  .ckDirectBox,.ckChecklist,.ckContentPanel,.ckAsideCard,
  .careka-legal-card,.careka-legal-contact,details
){
  background:var(--cd1242-surface)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line)!important;
}

html[data-careka-theme] body details > summary{
  background:var(--cd1242-control)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line-strong)!important;
}

html[data-careka-theme] body details[open] > summary{
  background:var(--cd1242-gold-soft)!important;
}

/* --------------------------------------------------------------------------
   7 · PREMIUM LINES / DIVIDERS
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  hr,.divider,.separator,.rule,
  [class*="divider"],[class*="separator"]
){
  opacity:1!important;
  border-color:var(--cd1242-line-strong)!important;
  background-color:var(--cd1242-line-strong)!important;
}

html[data-careka-theme] body :where(
  .section-index,.stage-clock,.editorial-label-row,
  .project-meta,.project-footer,.service-card,.pillar-nav,
  .careka-global-footer__bottom,.careka-global-footer__legal,
  .ckEditorialFooter__bottom,.menu-guide,.menu-diagnostic
){
  border-color:var(--cd1242-line-strong)!important;
}

html[data-careka-theme="light"] body.careka-v106-home :where(
  .stage-grid,.hero-grid
){
  opacity:.25!important;
}

html[data-careka-theme="dark"] body.careka-v106-home :where(
  .stage-grid,.hero-grid
){
  opacity:.38!important;
}

/* --------------------------------------------------------------------------
   8 · MODALS / DIALOGS / POPOVERS
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  dialog,.service-dialog,.all-projects-dialog,
  .cd-privacy-modal__panel,.cd123-popover,
  [role="dialog"],[role="alertdialog"],[role="listbox"]
){
  background:var(--cd1242-surface)!important;
  background-image:none!important;
  color:var(--cd1242-text)!important;
  border:1px solid var(--cd1242-line-strong)!important;
  box-shadow:var(--cd1242-shadow-lg)!important;
}

html[data-careka-theme] body :where(
  dialog,.service-dialog,.all-projects-dialog,
  .cd-privacy-modal__panel,.cd123-popover,[role="dialog"]
) :where(
  h1,h2,h3,h4,h5,h6,strong,b
){
  color:var(--cd1242-text)!important;
  opacity:1!important;
}

html[data-careka-theme] body :where(
  dialog,.service-dialog,.all-projects-dialog,
  .cd-privacy-modal__panel,.cd123-popover,[role="dialog"]
) :where(
  p,li,small,span,label
){
  color:var(--cd1242-body)!important;
  opacity:1!important;
}

html[data-careka-theme] body :where(
  .cd-privacy-modal,.dialog-backdrop,.modal-backdrop,.menu-overlay
){
  background:var(--cd1242-overlay)!important;
}

html[data-careka-theme] body dialog::backdrop{
  background:var(--cd1242-overlay)!important;
  backdrop-filter:blur(3px)!important;
}

/* --------------------------------------------------------------------------
   9 · FORMS / TABLES
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,select
){
  background:var(--cd1242-control)!important;
  color:var(--cd1242-text)!important;
  border:1px solid var(--cd1242-line-strong)!important;
  caret-color:var(--cd1242-text)!important;
}

html[data-careka-theme] body :where(input,textarea)::placeholder{
  color:var(--cd1242-faint)!important;
  opacity:1!important;
}

html[data-careka-theme] body table{
  background:var(--cd1242-surface)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line-strong)!important;
}

html[data-careka-theme] body :where(table,thead,tbody,tr,th,td){
  border-color:var(--cd1242-line)!important;
}

html[data-careka-theme] body th{
  background:var(--cd1242-surface-alt)!important;
}

/* --------------------------------------------------------------------------
   10 · PROJECTS / ARTICLE CTA
   -------------------------------------------------------------------------- */
html[data-careka-theme] body.careka-final-project :where(
  [data-cd121-role="project-hero"],
  main.container.hero > .panel.section:first-child,
  main.container > .panel.section:first-child
),
html[data-careka-theme] body :where(
  [data-cd121-role="article-final-cta"],
  .ckMidCta
){
  background:var(--cd1242-surface)!important;
  background-image:none!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line-strong)!important;
}

/* --------------------------------------------------------------------------
   11 · FOOTER THEME OWNERSHIP
   -------------------------------------------------------------------------- */
html[data-careka-theme="light"] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
){
  background:#ECE6DA!important;
  background-image:none!important;
  color:#15120E!important;
  border-color:rgba(21,18,14,.24)!important;
}

html[data-careka-theme="light"] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
) :where(
  h1,h2,h3,h4,strong,b,a,button
){
  color:#15120E!important;
}

html[data-careka-theme="light"] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
) :where(
  p,small,span
){
  color:#5B5349!important;
}

html[data-careka-theme="dark"] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
){
  background:#0B0B0B!important;
  background-image:none!important;
  color:#F6F2EA!important;
  border-color:rgba(246,242,234,.20)!important;
}

html[data-careka-theme="dark"] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
) :where(
  h1,h2,h3,h4,strong,b,a,button
){
  color:#F6F2EA!important;
}

html[data-careka-theme="dark"] body :where(
  footer,.careka-global-footer,.ckEditorialFooter,.case-site-foot,.site-footer
) :where(
  p,small,span
){
  color:#BDB5AA!important;
}

/* --------------------------------------------------------------------------
   12 · LANGUAGE / APPEARANCE CONTROLS + OPTIONAL DOCK
   -------------------------------------------------------------------------- */
html[data-careka-theme] body .cd123-footer-right,
html[data-careka-theme] body .cd123-footer-right.cd123-dock{
  background:var(--cd1242-surface)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line-strong)!important;
  box-shadow:var(--cd1242-shadow-md)!important;
}

html[data-careka-theme] body :where(
  .cd123-control,.cd123-option,.cd123-dock-peek
){
  background:var(--cd1242-control)!important;
  color:var(--cd1242-text)!important;
  border-color:var(--cd1242-line-strong)!important;
}

html[data-careka-theme] body .cd123-option-copy strong{
  color:var(--cd1242-text)!important;
}

html[data-careka-theme] body :where(
  .cd123-option-copy small,.cd123-popover-title,.cd123-footer-tagline
){
  color:var(--cd1242-muted)!important;
}

/* --------------------------------------------------------------------------
   13 · FOCUS / ACCESSIBILITY
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  a,button,[role="button"],[role="tab"],summary,
  input,textarea,select
):focus-visible{
  outline:2px solid var(--cd1242-gold)!important;
  outline-offset:3px!important;
  box-shadow:0 0 0 4px var(--cd1242-gold-soft)!important;
}

/* --------------------------------------------------------------------------
   14 · MEDIA IS NEVER THEME-WASHED
   -------------------------------------------------------------------------- */
html[data-careka-theme] body :where(
  img,picture,video,canvas,
  .media,.project-media,.story-visual,.hero-media,.hero-video,
  .portfolio-media,.case-media,.image-wrap,.video-wrap
){
  filter:none!important;
}

/* Runtime surface fallback. */
html[data-careka-theme="light"] body [data-cd1242-surface="light"]{
  background:#FFFDF8!important;
  background-image:none!important;
  color:#15120E!important;
  border-color:rgba(21,18,14,.19)!important;
}

html[data-careka-theme="dark"] body [data-cd1242-surface="dark"]{
  background:#101010!important;
  background-image:none!important;
  color:#F6F2EA!important;
  border-color:rgba(246,242,234,.19)!important;
}

/* --------------------------------------------------------------------------
   15 · MOBILE
   -------------------------------------------------------------------------- */
@media(max-width:760px){
  html[data-careka-theme] body :where(
    button,[role="button"],[role="tab"],summary,
    .cd123-control,.cd123-option
  ){
    min-height:42px;
  }

  html[data-careka-theme] body :where(
    dialog,.service-dialog,.all-projects-dialog,.cd-privacy-modal__panel
  ){
    max-width:calc(100vw - 20px)!important;
  }
}

@media(prefers-reduced-motion:reduce){
  html[data-careka-theme] body *,
  html[data-careka-theme] body *::before,
  html[data-careka-theme] body *::after{
    transition-duration:.01ms!important;
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    scroll-behavior:auto!important;
  }
}