/**
 * Cookie consent bar — built to the supplied desktop and mobile specs.
 *
 * SELF-CONTAINED LAYOUT, TOKENISED COLOUR. The bar renders on every
 * page via wp_footer, so its styles cannot live in a conditionally
 * loaded sheet; an earlier build put them in legalpage.css and the bar
 * rendered unstyled everywhere else.
 *
 * That earlier note concluded "every value below is set explicitly
 * rather than inherited, because inheriting is what broke it". The
 * diagnosis was wrong: the bug was WHERE the rules lived, and moving
 * them into this always-enqueued sheet (plus the inline critical CSS in
 * CookieConsent.php) is what fixed it. Hardcoding the colours bought
 * nothing on top of that and cost three things — the bar drifted
 * off-brand (#6C4CFF against the real primary #6D5EF5, a difference
 * nobody can see side by side but which no re-skin could ever reach),
 * it could not follow dark mode, and it was the one component the
 * token layer did not govern.
 *
 * Colours are now tokens WITH the previous literal as the fallback, so
 * if variables.css genuinely fails to load the bar still renders
 * exactly as it did. Layout values stay explicit, as before.
 *
 * Desktop spec: title 16px semi-bold · body 14px regular · link 14px
 * medium · padding 16/24 · gap 12 · max-width 1200 · buttons 40px tall,
 * radius 8 · primary #6C4CFF · shadow 0 -2px 12px rgba(0,0,0,.08) ·
 * border-top 1px #E6E8F0 · fixed, does not push content.
 */

.jdev-consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-consent);
  background: var(--color-white, #FFFFFF);
  border-top: 1px solid var(--color-border, #E6E8F0);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  padding: 16px 24px;
}

.jdev-consent__inner {
  max-width: 1200px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---- Icon -------------------------------------------------------------- */

.jdev-consent__icon {
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-code-inline-bg, #F1EFFE);
  color: var(--color-primary-text, #6C4CFF);
}

/* ---- Copy -------------------------------------------------------------- */

.jdev-consent__copy {
  flex: 1 1 auto;
  min-width: 0;
}

.jdev-consent__title {
  margin: 0 0 2px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: normal;
  color: var(--color-ink, #0F172A);
}

.jdev-consent__text {
  margin: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: normal;
  color: var(--color-ink-soft, #475569);
  max-width: 68ch;
}

.jdev-consent__policy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-primary-text, #6C4CFF);
  text-decoration: none;
}

.jdev-consent__policy:hover,
.jdev-consent__policy:focus-visible {
  text-decoration: underline;
}

/* ---- Actions ------------------------------------------------------------ */

.jdev-consent__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.jdev-consent__actions form {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}

/* Own scale, not the global .btn — that one is sized for page CTAs.
   Reject and Accept share every dimension so rejection is never the
   harder choice; only the fill differs. */
.jdev-consent__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.jdev-consent__btn--accept {
  background: var(--color-primary, #6C4CFF);
  border-color: var(--color-primary, #6C4CFF);
  color: var(--color-white, #FFFFFF);
}

.jdev-consent__btn--accept:hover,
.jdev-consent__btn--accept:focus-visible {
  background: var(--color-primary-deep, #5A3BE8);
  border-color: var(--color-primary-deep, #5A3BE8);
}

.jdev-consent__btn--reject {
  background: var(--color-white, #FFFFFF);
  border-color: var(--color-border-control, #D8DCE6);
  color: var(--color-ink, #1E293B);
}

.jdev-consent__btn--reject:hover,
.jdev-consent__btn--reject:focus-visible {
  border-color: var(--color-primary, #6C4CFF);
  color: var(--color-primary-text, #6C4CFF);
}

/* Customise is FIRST in the DOM (wireframe: Customise · Reject ·
   Accept on desktop). On mobile it moves to the end — see the ≤767
   block, where order:3 puts it below the two stacked buttons. */
.jdev-consent__link {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-primary-text, #6C4CFF);
  text-decoration: underline;
}

/* Dismiss is mobile-only, per the spec. */
.jdev-consent__dismiss {
  display: none;
}

.jdev-consent__btn:focus-visible,
.jdev-consent__link:focus-visible,
.jdev-consent__policy:focus-visible,
.jdev-consent__dismiss:focus-visible {
  outline: 2px solid var(--color-primary, #6C4CFF);
  outline-offset: 2px;
}

/* ---- 768–1023: copy above, actions right ------------------------------- */

@media (max-width: 1023px) {
  .jdev-consent__inner {
    flex-wrap: wrap;
  }

  .jdev-consent__copy {
    flex: 1 1 calc(100% - 60px);
  }

  .jdev-consent__actions {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
}

/* ---- ≤767: the mobile card ---------------------------------------------
   Spec: padding 16/16/20/16 · gap 10 · buttons 48px · Accept first,
   then Reject, then Customise · dismissible. */

@media (max-width: 767px) {
  .jdev-consent {
    padding: 0 12px 12px;
    background: transparent;
    border-top: 0;
    box-shadow: none;
  }

  /* A card rather than a full-width bar, as drawn. */
  .jdev-consent__inner {
    position: relative;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 16px 20px;
    border-radius: 14px;
    background: var(--color-white, #FFFFFF);
    border: 1px solid var(--color-border, #E6E8F0);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.10);
    max-height: 70vh;
    overflow-y: auto;
  }

  .jdev-consent__icon {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
  }

  .jdev-consent__copy {
    flex: 1 1 calc(100% - 100px);
  }

  .jdev-consent__text {
    max-width: none;
  }

  .jdev-consent__actions {
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .jdev-consent__actions form {
    flex-direction: column;
    gap: 10px;
  }

  .jdev-consent__btn {
    width: 100%;
    height: 48px;
    /* Accept first, Reject second — both full width and the same
       height, so order does not make one easier to press. */
    order: 2;
  }

  .jdev-consent__btn--accept {
    order: 1;
  }

  .jdev-consent__link {
    order: 3;
    text-align: center;
    padding: 4px 0;
  }

  .jdev-consent__dismiss {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-neutral, #64748B);
    cursor: pointer;
  }

  .jdev-consent__dismiss:hover {
    background: var(--color-surface, #F1F5F9);
  }
}

/* ---- Saved state -------------------------------------------------------
   The script sets data-consent-done, then removes the bar on a timer.
   These rules are decoration on top of that: if they are ever missing,
   the bar still leaves. An earlier build depended on transitionend
   firing here, so deleting these rules silently broke the buttons. */

.jdev-consent {
  transition: opacity 240ms ease, transform 240ms ease;
}

.jdev-consent[data-consent-done] {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

/* Announcement region: available to screen readers, out of the layout. */
.jdev-consent__live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .jdev-consent {
    transition: none;
  }

  .jdev-consent[data-consent-done] {
    transform: none;
  }
}

/* ==================================================================
   Desktop: one line, ~58px (8.143.0)

   The bar was a three-line block — title, sentence, policy link — in a
   16px/24px box, which came to about 110px and covered whatever the
   visitor had scrolled to. A consent bar is a utility, not a section
   of the page, so on a pointer-sized screen it collapses to a single
   row and gives the height back.

   Nothing is removed from the DOM. The title stays for anyone reading
   the markup and for narrow screens; the region's accessible name is
   the aria-label on .jdev-consent, not this heading, so hiding it
   visually costs nothing.
   ------------------------------------------------------------------ */
@media (min-width: 1024px) {
  .jdev-consent { padding: 10px 24px; }

  .jdev-consent__inner {
    max-width: 1280px;
    gap: 12px;
  }

  .jdev-consent__icon {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .jdev-consent__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* Sentence and policy link share the row. */
  .jdev-consent__copy {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 14px;
  }

  .jdev-consent__text {
    font-size: 13px;
    line-height: 1.4;
    max-width: none;
  }

  .jdev-consent__policy {
    margin-top: 0;
    font-size: 13px;
  }

  .jdev-consent__btn,
  .jdev-consent__link {
    min-height: 36px;
    font-size: 13px;
  }
}
