/* Tokens come from style.css (:root), mapped to the Ninthroot palette. */
/* It also uses the site's .btn, .btn--primary, .btn--outline and .btn--block buttons. */

/* ==========================================================================
   COOKIE CONSENT
   Asks once, after the loader lifts. Reject sits beside Accept with the same weight;
   Cookie settings in the footer reopens it with the choices already open.
   ========================================================================== */
.consent {
  position: fixed;
  /* bottom right: over the hero photo rather than the quick form (was left: clamp(16px, 2.5vw, 32px)) */
  right: clamp(16px, 2.5vw, 32px);
  bottom: clamp(16px, 2.5vw, 32px);
  z-index: 90; /* under the header (100), so the full-screen menu covers it */
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 22px;
  border-radius: var(--radius-l);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(20, 40, 90, .08), 0 28px 56px -24px rgba(14, 29, 68, .5);
  /* resting state; leaving returns here, so it exits the way it came in */
  opacity: 0;
  transform: translateY(16px) scale(.97);
  transform-origin: 100% 100%; /* rises out of its corner */
  transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-out);
}
.consent[hidden] { display: none; }
.consent.is-open {
  opacity: 1;
  transform: none;
  transition: opacity 320ms var(--ease-out), transform 560ms var(--ease-drawer);
}
/* after a choice it fades out while sinking, unhurried, so it never feels snapped shut
   (it used to fall back to the resting state's 220/260ms and a 16px drop) */
.consent.is-leaving {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 440ms cubic-bezier(0.4, 0, 0.2, 1), transform 560ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* the content settles in just behind the card, a beat apart */
.consent__head,
.consent__text,
.consent__manage,
.consent__actions {
  opacity: 0;
  transform: translateY(8px);
}
.consent.is-open :is(.consent__head, .consent__text, .consent__manage, .consent__actions),
.consent.is-leaving :is(.consent__head, .consent__text, .consent__manage, .consent__actions) {
  opacity: 1;
  transform: none;
}
.consent.is-open :is(.consent__head, .consent__text, .consent__manage, .consent__actions) {
  transition:
    opacity 360ms var(--ease-out) calc(90ms + var(--i, 0) * 50ms),
    transform 480ms var(--ease-out) calc(90ms + var(--i, 0) * 50ms);
}

.consent__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
/* the khatam star turns an eighth into place: it lands looking exactly as it started */
.consent__star {
  flex: none;
  width: 18px;
  height: 18px;
  fill: var(--gold);
  opacity: 0;
  transform: rotate(-45deg) scale(.5);
}
.consent.is-open .consent__star,
.consent.is-leaving .consent__star { opacity: 1; transform: none; }
.consent.is-open .consent__star { transition: transform 720ms var(--ease-out) 150ms, opacity 280ms var(--ease-out) 150ms; }
.consent__title { font-family: var(--serif); font-size: 1.375rem; line-height: 1.2; color: var(--lapis); }
.consent__title:focus { outline: none; } /* only ever focused by script, on reopen */
.consent__close {
  display: none;
  position: relative;
  flex: none;
  width: 36px;
  height: 36px;
  margin: -6px -10px -6px auto;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color .2s, color .2s, transform 160ms var(--ease-out);
}
.consent.can-dismiss .consent__close { display: block; }
.consent__close:active { transform: scale(.92); }
.consent__close span,
.consent__close span::before {
  position: absolute;
  left: 11px;
  top: 17px;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  transform: rotate(45deg);
}
.consent__close span::before { content: ""; left: 0; top: 0; transform: rotate(90deg); }

.consent__text { margin: 0; font-size: .9375rem; line-height: 1.55; color: var(--ink-soft); }

.consent__manage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 0;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--blue);
  transition: color .2s;
}
.consent__manage svg { width: 12px; height: 12px; transition: transform 260ms var(--ease-in-out); }
.consent.is-expanded .consent__manage svg { transform: rotate(180deg); }

/* choices: the panel opens to its natural height, rows arrive one after another;
   closing is quicker and all together */
.consent__prefs { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 240ms var(--ease-in-out); }
.consent.is-expanded .consent__prefs { grid-template-rows: 1fr; transition-duration: 380ms; }
.consent__prefs-inner { min-height: 0; overflow: hidden; margin: 0 -4px; padding: 0 4px; }
.consent__row,
.consent__save {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out);
}
.consent.is-expanded :is(.consent__row, .consent__save) {
  opacity: 1;
  transform: none;
  transition:
    opacity 300ms var(--ease-out) calc(70ms + var(--i, 0) * 40ms),
    transform 420ms var(--ease-out) calc(70ms + var(--i, 0) * 40ms);
}
.consent__row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.consent__label { font-size: 1rem; font-weight: 500; color: var(--ink); }
label.consent__label { cursor: pointer; }
.consent__row p { grid-column: 1 / -1; margin: 0; font-size: .875rem; line-height: 1.5; color: var(--muted); }
.consent__always { font-size: .875rem; font-weight: 500; color: var(--teal); }
.consent__save { padding: 6px 0 4px; }

/* switch: the thumb slides across and stretches a little while pressed */
.consent__switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: #C3CAD6;
  cursor: pointer;
  transition: background-color 200ms var(--ease-out);
}
.consent__switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(14, 29, 68, .3);
  transition: transform 220ms var(--ease-out), width 160ms var(--ease-out);
}
.consent__switch:checked { background: var(--lapis); }
.consent__switch:checked::before { transform: translateX(18px); }
.consent__switch:active::before { width: 24px; }
.consent__switch:checked:active::before { transform: translateX(14px); }
.consent__switch:focus-visible { outline-offset: 2px; border-radius: 13px; }

.consent__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.consent__actions .btn { min-height: 46px; padding: 10px 14px; }

@media (hover: hover) and (pointer: fine) {
  .consent__manage:hover { color: var(--lapis); }
  .consent__close:hover { background: var(--mist); color: var(--lapis); }
}

/* phones: a sheet that comes up from the bottom edge and goes back down there */
@media (max-width: 600px) {
  .consent {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 18px 20px 20px;
    transform: translateY(calc(100% + 24px));
    transform-origin: 50% 100%;
    transition: opacity 260ms var(--ease-out), transform 300ms var(--ease-out);
  }
  /* the sheet sinks back below the edge it came from, fading as it goes */
  .consent.is-leaving { transform: translateY(calc(100% + 24px)); }
  .consent__title { font-size: 1.25rem; }
}

/* reduced motion: gentler, not zero. Everything still fades; nothing travels */
@media (prefers-reduced-motion: reduce) {
  .consent,
  .consent :is(.consent__head, .consent__text, .consent__manage, .consent__actions, .consent__star, .consent__row, .consent__save) { transform: none !important; }
  .consent__prefs,
  .consent.is-expanded .consent__prefs { transition: none; }
}
