/* ==========================================================================
   L.B. English Co. — cookie consent banner + preferences dialog
   Loaded on every public page. Uses the design tokens from main.css, so the
   banner follows all four palettes and both light/dark schemes.

   Nothing here is display:none'd by default: the markup is built by
   assets/js/consent.js, so a visitor without JavaScript never sees a banner
   they cannot use.
   ========================================================================== */

.lb-consent {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 420;
  display: flex;
  justify-content: center;
  padding: clamp(0.75rem, 1.6vw, 1.25rem);
  padding-bottom: max(clamp(0.75rem, 1.6vw, 1.25rem), env(safe-area-inset-bottom));
  pointer-events: none;
}

.lb-consent[hidden] {
  display: none;
}

.lb-consent__card {
  width: min(100%, 1080px);
  padding: clamp(1.1rem, 1.4vw + 0.8rem, 1.75rem);
  color: var(--text-soft);
  background-image: linear-gradient(120deg, var(--accent-glow), transparent 55%), var(--grad-surface);
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  pointer-events: auto;
  animation: lb-consent-rise var(--t-slow) var(--ease-out) both;
}

@keyframes lb-consent-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lb-consent__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-5);
  align-items: center;
}

.lb-consent__title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
  align-items: center;
  margin: 0 0 0.4rem;
  color: var(--text);
  font-size: var(--step-1);
  font-weight: 680;
  letter-spacing: -0.015em;
}

.lb-consent__eyebrow {
  display: inline-flex;
  gap: 0.4em;
  align-items: center;
  padding: 0.18em 0.6em;
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
}

.lb-consent__text {
  max-width: 68ch;
  margin: 0;
  font-size: var(--step--1);
  line-height: 1.6;
  color: var(--text-muted);
}

.lb-consent__text a {
  color: var(--text);
}

.lb-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  justify-content: flex-end;
}

.lb-consent__actions .btn {
  white-space: nowrap;
}

/* Reject must be as easy to reach as accept; it gets a real button, not a
   link hidden in small print. */
.lb-consent__link {
  padding: 0.55em 0.2em;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 640;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
  background: none;
  border: 0;
  cursor: pointer;
}

.lb-consent__link:hover {
  color: var(--text);
}

@media (max-width: 860px) {
  .lb-consent__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-4);
  }

  .lb-consent__actions {
    justify-content: flex-start;
  }

  .lb-consent__actions .btn {
    flex: 1 1 12rem;
  }
}

/* Two choices side by side, the manage link beneath: the banner was taking
   40% of a phone screen when all three stacked. */
@media (max-width: 620px) {
  .lb-consent {
    padding-inline: 0.6rem;
  }

  .lb-consent__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }

  .lb-consent__actions .btn {
    flex: none;
    padding-inline: 0.5rem;
    white-space: normal;
  }

  .lb-consent__link {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .lb-consent__card {
    padding: 1rem;
    border-radius: var(--r-md);
  }

  .lb-consent__grid {
    gap: 0.65rem;
  }

  /* The category chip is decoration; every pixel here costs reading space. */
  .lb-consent__eyebrow {
    display: none;
  }

  .lb-consent__title {
    margin-bottom: 0.25rem;
    font-size: 1rem;
  }

  .lb-consent__text {
    font-size: 0.78rem;
    line-height: 1.5;
  }
}

/* --------------------------------------------------------------------------
   Preferences dialog
   -------------------------------------------------------------------------- */

.lb-consent-modal {
  position: fixed;
  inset: 0;
  z-index: 430;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgba(2, 7, 16, 0.68);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
}

.lb-consent-modal[hidden] {
  display: none;
}

.lb-consent-modal__panel {
  display: flex;
  flex-direction: column;
  width: min(100%, 640px);
  max-height: min(88vh, 780px);
  padding: clamp(1.1rem, 2vw, 1.75rem);
  overflow: hidden;
  color: var(--text-soft);
  background-image: var(--grad-surface);
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}

.lb-consent-modal__head {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  justify-content: space-between;
}

.lb-consent-modal__title {
  margin: 0;
  color: var(--text);
  font-size: var(--step-2);
  font-weight: 680;
  letter-spacing: -0.02em;
}

.lb-consent-modal__intro {
  margin: var(--sp-3) 0 0;
  font-size: var(--step--1);
  line-height: 1.6;
  color: var(--text-muted);
}

.lb-consent-modal__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  background: var(--glass-1);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.lb-consent-modal__close:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.lb-consent-modal__close svg {
  width: 18px;
  height: 18px;
}

/* Only the category list scrolls, so the title and the save buttons stay
   reachable on a short phone screen. */
.lb-consent-list {
  display: grid;
  flex: 1 1 auto;
  gap: var(--sp-3);
  min-height: 0;
  padding: 0 4px 0 0;
  margin: var(--sp-5) 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.lb-consent-cat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-3) var(--sp-4);
  align-items: start;
  padding: var(--sp-4);
  background: var(--glass-1);
  border: 1px solid var(--line-hair);
  border-radius: var(--r-md);
}

.lb-consent-cat__name {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
  color: var(--text);
  font-size: var(--step-0);
  font-weight: 660;
}

.lb-consent-cat__tag {
  padding: 0.14em 0.55em;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}

.lb-consent-cat__desc {
  margin: 0.35rem 0 0;
  font-size: var(--step--1);
  line-height: 1.55;
  color: var(--text-muted);
}

/* --- Switch ------------------------------------------------------------- */

.lb-switch {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  cursor: pointer;
}

.lb-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  clip-path: inset(50%);
  opacity: 0;
}

.lb-switch__track {
  position: relative;
  display: block;
  width: 46px;
  height: 26px;
  background: var(--glass-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  transition: background-color var(--t-mid) ease, border-color var(--t-mid) ease;
}

.lb-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-mid) var(--ease-spring), background-color var(--t-mid) ease;
}

.lb-switch input:checked + .lb-switch__track {
  background-image: var(--grad-accent);
  border-color: transparent;
}

.lb-switch input:checked + .lb-switch__track .lb-switch__thumb {
  background: #06101f;
  transform: translateX(20px);
}

.lb-switch input:focus-visible + .lb-switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.lb-switch input:disabled + .lb-switch__track {
  opacity: 0.7;
  cursor: not-allowed;
}

.lb-switch--locked {
  cursor: not-allowed;
}

.lb-consent-modal__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  justify-content: flex-end;
  padding-top: var(--sp-5);
  margin-top: var(--sp-5);
  border-top: 1px solid var(--line-hair);
}

.lb-consent-modal__foot .btn {
  flex: 0 1 auto;
}

.lb-consent-modal__note {
  flex: 1 1 14rem;
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.lb-consent-modal__status {
  margin: var(--sp-3) 0 0;
  font-size: var(--step--1);
  color: var(--accent);
}

.lb-consent-modal__status:empty {
  display: none;
}

body.lb-consent-open {
  overflow: hidden;
}

/* --- Confirmation toast ------------------------------------------------- */

.lb-consent-toast {
  position: fixed;
  left: clamp(0.75rem, 2vw, 1.5rem);
  bottom: max(clamp(0.75rem, 2vw, 1.5rem), env(safe-area-inset-bottom));
  z-index: 440;
  max-width: min(92vw, 24rem);
  padding: 0.7rem 1.05rem;
  color: var(--text);
  font-size: var(--step--1);
  font-weight: 600;
  background-color: var(--bg);
  background-image: var(--grad-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md);
  animation: lb-consent-rise var(--t-mid) var(--ease-out) both;
  transition: opacity var(--t-mid) ease, transform var(--t-mid) ease;
}

.lb-consent-toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}

/* --------------------------------------------------------------------------
   Footer trigger + inline preference summary
   -------------------------------------------------------------------------- */

/* Only bare triggers are reset. Buttons carrying .btn already have their
   own padding, colour and background; this rule must not flatten them. */
button[data-consent-open]:not(.btn) {
  padding: 0;
  color: inherit;
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}

button[data-consent-open]:not(.btn):hover {
  color: var(--text);
}

/* Matches the surrounding footer links; the button earns a keyboard focus
   ring that the plain links get from the browser. */
.footer__legal button {
  color: var(--text-muted);
  font: inherit;
  text-decoration: none;
  border-radius: 3px;
}

.footer__legal button:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer__legal button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[data-consent-status] {
  color: var(--text);
  font-weight: 620;
}

@media (prefers-reduced-motion: reduce) {
  .lb-consent__card {
    animation: none;
  }

  .lb-switch__thumb,
  .lb-switch__track {
    transition: none;
  }
}
