/* ===== Modernize-aligned Klaro overrides ===== */

/* Remove #klaro from document flow so its injection doesn't cause CLS.
   Klaro's children (.cookie-notice, .cm-wrapper) handle their own positioning. */
#klaro {
    position: fixed;
    z-index: 2147483000;
    /* The app's body type (MUI CssBaseline body1), which the notice would
       otherwise inherit only once the app has booted: on a page painted before
       that (the homepage placeholder) it would grow at the first interaction. */
    font-size: .875rem;
    line-height: 1.334rem;
}

/* Typography + container */
.klaro, .cm-wrapper {
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: #0b1a39!important; /* Modernize dark text */
  }

  .klaro .cookie-modal p, .klaro .cookie-modal strong, .klaro .cookie-modal h1, .klaro .cookie-modal h2, .klaro .cookie-modal ul, .klaro .cookie-modal li, .klaro .context-notice p, .klaro .context-notice strong, .klaro .context-notice h1, .klaro .context-notice h2, .klaro .context-notice ul, .klaro .context-notice li, .klaro .cookie-notice p, .klaro .cookie-notice strong, .klaro .cookie-notice h1, .klaro .cookie-notice h2, .klaro .cookie-notice ul, .klaro .cookie-notice li {
    color: #0b1a39!important; /* Modernize dark text */
  }
  
  /* Bottom LEFT on desktop: the bottom-right corner belongs to the "Ask
     Justee" launcher (PublicFabStack) on every public page, and the notice
     used to sit on top of it. Klaro's own stylesheet pins the notice right;
     both offsets are set so the override wins whichever rule loads last.
     Scoped to Klaro's own desktop breakpoint: below 1024px the notice is a
     full-width bar (and the phone rule further down keeps it so). */
  @media (min-width: 1024px) {
    .klaro .cookie-notice:not(.cookie-modal-notice) {
      left: 20px!important;
      right: auto!important;
    }
  }
  #klaro-cookie-notice {
    margin-right: 0!important;
  }

  /* Mobile responsive positioning for cookie notice */
  @media (max-width: 768px) {
    #klaro-cookie-notice {
      margin-right: 10px!important;
      margin-left: 10px!important;
      max-width: calc(100vw - 20px)!important;
    }
    .klaro .cookie-notice:not(.cookie-modal-notice) {
      max-width: 100%!important;
      left: 10px!important;
      right: 10px!important;
      width: auto!important;
    }
  }

  .klaro .cookie-modal .cm-list-label .cm-switch {
    margin:5px!important;
  }
  /* Modal */
  .klaro .cm-modal {
    border-radius: 16px !important;              /* Modernize rounded-xl */
    box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
    max-width: 780px !important;
    border: 1px solid #eef2ff !important;        /* subtle border like Modernize cards */
    background: #ffffff !important;
  }
  .klaro .cookie-notice:not(.cookie-modal-notice) {
    background-color: #2a3548!important;
    border-radius: 12px!important;
  }
  /* Text in dark cookie notice banner should be white */
  .klaro .cookie-notice:not(.cookie-modal-notice) p,
  .klaro .cookie-notice:not(.cookie-modal-notice) .cn-body,
  .klaro .cookie-notice:not(.cookie-modal-notice) .cn-changes {
    color: #ffffff !important;
  }
  /* Links in dark banner: white + underline */
  .klaro .cookie-notice:not(.cookie-modal-notice) a {
    color: #ffffff !important;
    text-decoration: underline !important;
  }
  /* The brand blue: white button text needs 4.5:1 and gets 5.2:1 (the old
     #5D87FF was 3.3:1 and failed Lighthouse colour-contrast). */
  .klaro .cookie-notice .cm-btn {
    background-color: #395FDA!important;
  }
  .klaro a {
    color:#395FDA!important;
  }
  .cm-header h1, .cm-header h2, .cm-header h3 {
    font-size: 22px !important;
    font-weight: 700 !important;
    margin-bottom: 8px !important;
  }
  .cm-description {
    color: #4a5568 !important;                   /* muted body */
    line-height: 1.55 !important;
  }
  
  /* Lists (purposes/services) */
  .cm-purpose, .cm-service {
    border-radius: 12px !important;              /* rounded-lg */
    border: 1px solid #eef2ff !important;
    background: #fafbff !important;
  }
  
  /* Toggles */
  .cm-switch input:checked + .cm-switch__slider {
    background: #395FDA !important;              /* Modernize primary */
    border-color: #395FDA !important;
  }
  .cm-switch__slider {
    transition: background-color .2s, border-color .2s, transform .2s !important;
  }

  .klaro #id-cookie-notice {
    color: white !important;
  }

  .klaro .cookie-modal .cm-list-input:checked+.cm-list-label .slider, .klaro .context-notice .cm-list-input:checked+.cm-list-label .slider, .klaro .cookie-notice .cm-list-input:checked+.cm-list-label .slider {
    background-color:#395FDA !important;
    }
  
  /* Buttons */
  .cm-btn {
    border-radius: 9999px !important;            /* pill */
    padding: 10px 16px !important;
    font-weight: 600 !important;
    border-width: 1px !important;
    transition: filter .15s, box-shadow .15s !important;
  }
  .cm-btn-accept, .cm-btn-save {
    background: #395FDA !important;
    border-color: #395FDA !important;
    color: #ffffff !important;
  }
  .cm-btn-decline, .cm-btn-back {
    background: #f3f6ff !important;
    border-color: #e5e9f6 !important;
    color: #0b1a39 !important;
  }
  .cm-btn:hover { filter: brightness(0.96); }
  /* The app theme's ring (theme/Components.tsx MuiButtonBase). The old 35%
     tint box-shadow was ~1.4:1 on white and read as no focus at all (2.4.7). */
  .cm-btn:focus-visible {
    outline: 2px solid #395FDA !important;
    outline-offset: 2px !important;
  }
  
  /* Banner */
  .cm-banner {
    border-top: 1px solid #e5e9f6 !important;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.08) !important;
    background: #ffffff !important;
  }
  .cm-banner .cm-btn-accept {
    background: #395FDA !important;
    color: #fff !important;
  }
  
  /* Links. Those inside the dialog's text are underlined: against the text
     around them colour alone is too faint a cue (WCAG 1.4.1). */
  .cm-link, .cm-content a {
    color: #395FDA !important;
  }
  .cm-link { text-decoration: none !important; }
  .cm-content a { text-decoration: underline !important; }
  .cm-link:hover { text-decoration: underline !important; }
  
  /* Z-index guard — must beat MUI AppBar (1100), Drawer (1200), Modal (1300).
     Klaro's built-in CSS sets .cookie-notice to z-index:999 which loses to all of them. */
  #klaro,
  .cm-wrapper,
  .cm-modal,
  .cm-banner,
  .klaro .cookie-notice,
  .klaro .cookie-modal { z-index: 2147483000 !important; }

  .klaro .cookie-modal .cm-btn.cm-btn-success, .klaro .context-notice .cm-btn.cm-btn-success, .klaro .cookie-notice .cm-btn.cm-btn-success {
    background-color: #395FDA!important;
  }

/* While the notice is up it covers the bottom of the viewport (a 160px card at
   >=1024px, a taller full-width bar below): keep focused elements scrolled
   clear of it (WCAG 2.4.11). See the scroll-padding base in react_landing.html.
   Capped by the viewport height so a short (landscape phone) window keeps room
   to show the focused element at all. */
html:has(#klaro-cookie-notice:not(.cookie-notice-hidden)){scroll-padding-bottom:min(200px,30vh)}
@media (max-width: 1023px){
  html:has(#klaro-cookie-notice:not(.cookie-notice-hidden)){scroll-padding-bottom:min(280px,40vh)}
  /* The full-width bar sits over the Ask Justee / scroll-to-top buttons
     (PublicFabStack): hide them until the notice is answered, so Tab does not
     land on a control nobody can see. */
  html:has(#klaro-cookie-notice:not(.cookie-notice-hidden)) .public-fab{visibility:hidden}
}


/* OQ-7: the notice steps aside while a dialog is open (MUI marks #klaro
   aria-hidden, so screen readers already skip it) and while a full-window
   signing or preparing view shows (EsignFrameShell sets body
   data-esign-frame): a cross-origin frame cannot be scrolled clear of it.
   It returns unchanged when they close. Visibility only: nothing is chosen
   and no consent is written. */
#klaro[aria-hidden="true"],
body[data-esign-frame] #klaro{visibility:hidden!important}
/* And while the app's notice line shows (NoticeSnackbar, data-notice-line).
   A rule of its own: a browser without :has() drops only this one. */
html:has([data-notice-line]) #klaro{visibility:hidden!important}
