/* Renéra · Cookie consent banner (Issue #38)
   Non-modal dialog: desktop = fixed card centred along the bottom edge,
   ≤640px = bottom sheet.
   Tokens only (design-system.css). z-index 9000: above header (50–60) and
   toasts (100), below the mobile menu (9999) and the cart drawer (10000).

   TWO THEME-WIDE RULES REPAINT BARE <button> ELEMENTS, and every control in this
   banner is a <button>. Both must be out-ranked or the banner stops looking like
   the rest of the site:

     1. brand-base.css — `button, [type="button"], [type="submit"], [type="reset"]`
        sets colour/border to the olive fallback, and `button:hover` fills it
        terracotta. `[type="button"]` is an attribute selector: specificity
        (0,1,0), a TIE with a single component class, so this file only wins by
        loading later (see reneranutrition_consent_enqueue, priority 23).
     2. Each page template inlines `body.rn-*-page button { font-family: inherit }`
        — specificity (0,2,1), which NO single class can beat at any load order.

   So the properties those two touch (colour, background, border-colour, font)
   are pinned below under the `#rn-consent` id scope (1,1,0). Keep new controls
   inside that scope, and give every hover state an explicit background — the
   inherited `button:hover` fill is otherwise what paints a text link.
   --------------------------------------------------------------------- */
.rn-consent {
  position: fixed;
  /* Horizontally centred: auto margins against left/right 0 split the leftover
     space evenly. Deliberately NOT translateX(-50%) — .is-entering owns the
     transform property for the slide-up, and the two would clobber each other. */
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  /* --rn-consent-lift = height of the PDP sticky buy bar while it is on (set by JS),
     so the card sits above it instead of covering the add-to-cart button (AC6). */
  bottom: calc(var(--renera-sp-5) + var(--rn-consent-lift, 0px));
  z-index: 9000;
  box-sizing: border-box;
  width: calc(100% - (var(--renera-sp-5) * 2));
  max-width: 440px;
  padding: var(--renera-sp-4) var(--renera-sp-4) var(--renera-sp-3);
  background: var(--renera-paper);
  color: var(--renera-fg);
  border: 1px solid var(--renera-clay-300);
  border-radius: var(--renera-r-lg);
  box-shadow: var(--renera-shadow-lift);
  font-family: var(--renera-font-sans);
  font-size: var(--renera-fs-sm);
  line-height: var(--renera-lh-normal);
  letter-spacing: var(--renera-track-sans);
  opacity: 1;
  transform: none;
  transition: opacity var(--renera-dur-base) var(--renera-ease),
              transform var(--renera-dur-base) var(--renera-ease);
}
.rn-consent[hidden] { display: none; }
.rn-consent.is-entering { opacity: 0; transform: translateY(12px); }
.rn-consent * { box-sizing: border-box; }

.rn-consent__text {
  margin: 0 0 var(--renera-sp-3);
  text-align: left;
  hyphens: manual;
  color: var(--renera-fg);
}
.rn-consent__text[hidden] { display: none; }

/* "Cookie settings" view — status line only, no toggles (AC5) */
.rn-consent__panel {
  margin: 0 0 var(--renera-sp-3);
  padding: var(--renera-sp-2) 0 0;
  border-top: 1px solid var(--renera-clay-300);
}
.rn-consent__panel[hidden] { display: none; }
.rn-consent__cats { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px var(--renera-sp-3); }
.rn-consent__cats dt {
  margin-top: var(--renera-sp-2);
  font-family: var(--renera-font-mono);
  font-size: var(--renera-fs-eyebrow);
  letter-spacing: var(--renera-track-eyebrow);
  text-transform: uppercase;
  color: var(--renera-mute);
}
.rn-consent__cats dd { margin: 0; color: var(--renera-fg); }
.rn-consent__status {
  font-family: var(--renera-font-mono);
  font-size: var(--renera-fs-eyebrow);
  letter-spacing: var(--renera-track-eyebrow);
  text-transform: uppercase;
  color: var(--renera-accent);
}

/* Twin buttons — one rule set, identical size/weight/contrast (AC5) */
.rn-consent__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--renera-sp-2);
  margin: 0 0 var(--renera-sp-3);
}
.rn-consent__btn {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  height: 44px;
  padding: 0 var(--renera-sp-3);
  background: var(--renera-btn-bg);
  color: var(--renera-btn-fg);
  border: 1px solid var(--renera-btn-bg);
  border-radius: var(--renera-r-sm);
  font-family: var(--renera-font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
  transition: background var(--renera-dur-fast) var(--renera-ease),
              color var(--renera-dur-fast) var(--renera-ease),
              border-color var(--renera-dur-fast) var(--renera-ease);
}
.rn-consent__btn:hover {
  background: var(--renera-btn-bg-hover);
  color: var(--renera-btn-fg-hover);
  border-color: var(--renera-btn-bg);
}
/* Pin (see the header note): the id scope out-ranks both brand-base's
   `[type="button"]` colour and the templates' inline `body.rn-* button` font. */
#rn-consent .rn-consent__btn {
  background: var(--renera-btn-bg);
  color: var(--renera-btn-fg);
  border-color: var(--renera-btn-bg);
  font-family: var(--renera-font-mono);
}
#rn-consent .rn-consent__btn:hover {
  background: var(--renera-btn-bg-hover);
  color: var(--renera-btn-fg-hover);
  border-color: var(--renera-btn-bg-hover);
}

/* Text links — mono eyebrow style */
.rn-consent__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--renera-sp-1) var(--renera-sp-4);
  margin: 0;
}
.rn-consent__link {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  font-family: var(--renera-font-mono);
  font-size: var(--renera-fs-eyebrow);
  letter-spacing: var(--renera-track-eyebrow);
  text-transform: uppercase;
  color: var(--renera-link);
  text-decoration: underline;
  text-decoration-color: var(--renera-link-underline);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color var(--renera-dur-fast) var(--renera-ease);
}
.rn-consent__link:hover { color: var(--renera-link-hover); }
.rn-consent__link[aria-expanded="true"] { color: var(--renera-link-hover); }
/* Pin: a text link never takes a fill — brand-base's `button:hover` would
   otherwise paint "Cookie settings" as a terracotta block on hover. */
#rn-consent .rn-consent__link {
  background: none;
  border: 0;
  color: var(--renera-link);
  font-family: var(--renera-font-mono);
}
#rn-consent .rn-consent__link:hover,
#rn-consent .rn-consent__link[aria-expanded="true"] {
  background: none;
  color: var(--renera-link-hover);
}

.rn-consent__live {
  margin: var(--renera-sp-2) 0 0;
  min-height: 0;
  font-family: var(--renera-font-mono);
  font-size: var(--renera-fs-eyebrow);
  letter-spacing: var(--renera-track-eyebrow);
  text-transform: uppercase;
  color: var(--renera-success);
}
.rn-consent__live:empty { display: none; }

/* Focus — visible ring, keyboard only (AC6) */
.rn-consent__btn:focus-visible,
.rn-consent__link:focus-visible {
  outline: 2px solid var(--renera-accent-2);
  outline-offset: 2px;
}

/* Coexistence: keep toasts and the scroll-top pill clear of the banner (AC6).
   --rn-consent-h is measured by cookie-consent.js while the banner is open. */
body.rn-consent-open .rn-toast,
body.rn-consent-open .rnm-toast,
body.rn-consent-open #wpfront-scroll-top-container,
body.rn-consent-open .rn-popup__pill {
  bottom: calc(var(--rn-consent-h, 0px) + 12px);
}

/* Reserve the banner's height at the page end so every control (checkout
   Place order, the register form) can always scroll clear of it.
   `html body` outranks the templates' inline `body.rn-*-page { padding: 0 }`.
   Applies at EVERY width since the card is centred: it now sits over the middle
   column, where the centred register/checkout controls live, so a viewport
   already scrolled to the page end has nowhere left to move them (AC6). While
   the card was bottom-left this was only needed once the sheet went full-width. */
html body.rn-consent-open { padding-bottom: calc(var(--rn-consent-h, 0px) + var(--renera-sp-5)); }

/* ≤ 640px — full-width bottom sheet */
@media (max-width: 640px) {
  .rn-consent {
    left: 0;
    right: 0;
    bottom: var(--rn-consent-lift, 0px);
    width: 100%;
    max-width: none;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--renera-sp-4) var(--renera-sp-4) calc(var(--renera-sp-3) + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: var(--renera-r-lg) var(--renera-r-lg) 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rn-consent, .rn-consent__btn, .rn-consent__link { transition: none; }
  .rn-consent.is-entering { transform: none; }
}
