/* Cookie / legal modals — Figma 0060, 0070, 0080
   Frames: 4109:8804, 4109:8765, 4109:8717
*/

.ww-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: #1f2933;
}

.ww-modal[hidden] {
  display: none !important;
}

.ww-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.ww-modal__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 1115px;
  max-width: calc(100vw - 48px);
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
}

.ww-modal__panel:focus {
  outline: none;
}

.ww-modal__panel:focus-visible {
  outline: none;
}

/* ---------- Shared close ----------
   default: rgba(31,41,51,0.40)
   hover:   rgba(31,41,51,0.70)
   active:  #1F2933
   focus:   #1F2933 + 1px solid border
   disabled: rgba(31,41,51,0.40)
*/
.ww-modal__close {
  position: absolute;
  z-index: 3;
  top: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  /* 20px icon + 3px gap each side + 1px border each side */
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: rgba(31, 41, 51, 0.4);
  cursor: pointer;
  line-height: 0;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.ww-modal__close:hover {
  color: rgba(31, 41, 51, 0.7);
}

.ww-modal__close:active {
  color: #1f2933;
}

.ww-modal__close:focus {
  outline: none;
  color: #1f2933;
  border-color: #1f2933;
}

.ww-modal__close:focus-visible {
  outline: none;
  color: #1f2933;
  border-color: #1f2933;
}

.ww-modal__close:disabled,
.ww-modal__close.is-disabled,
.ww-modal__close[aria-disabled="true"] {
  color: rgba(31, 41, 51, 0.4);
  border-color: transparent;
  cursor: not-allowed;
  pointer-events: none;
}

.ww-modal__close svg {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  pointer-events: none;
}

.ww-modal__close svg path {
  fill: currentColor;
}

/* ---------- Shared primary CTA ---------- */
.ww-modal__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: #1f2933;
  color: #ffffff;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
}

/* Figma 4109:8769 — arrow 20px from right; label centered in remaining width */
.ww-modal__cta:has(> .ww-modal__cta-icon) {
  position: relative;
  gap: 0;
  padding-left: 0;
  padding-right: 41px; /* 20px + 21px arrow */
}

.ww-modal__cta:focus {
  outline: none;
}

.ww-modal__cta:hover {
  background: rgba(31, 41, 51, 0.7);
}

.ww-modal__cta:active {
  background: rgba(31, 41, 51, 0.9);
}

.ww-modal__cta:focus-visible {
  outline: none;
  background: #1f2933;
  border-color: #8f9499;
}

.ww-modal__cta:disabled,
.ww-modal__cta.is-disabled {
  background: #1f2933;
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.ww-modal__cta-icon {
  display: block;
  width: 21px;
  height: 14px;
  flex-shrink: 0;
}

.ww-modal__cta:has(> .ww-modal__cta-icon) > .ww-modal__cta-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

/* ============================================================
   0060 — Customise cookies
   Panel 1115×864 @ (403,108); title fixed; content scrolls
   ============================================================ */
.ww-modal--customise .ww-modal__panel {
  width: 1115px;
  height: 864px;
  max-height: calc(100vh - 48px);
}

/* Fixed title only — intro + prefs scroll below */
.ww-modal--customise .ww-modal__header {
  flex: 0 0 auto;
  box-sizing: border-box;
  padding: 48px 179px 16px; /* title at y:48; intro follows at y:94 */
}

.ww-modal--customise .ww-modal__title {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 30px;
  text-align: center;
  color: #1f2933;
}

.ww-modal--customise .ww-modal__scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  /* 864 − header 94 − footer 136 = 634 */
  height: 634px;
  max-height: calc(100% - 94px - 136px);
  overflow: hidden;
}

.ww-modal--customise .ww-modal__scroll-inner {
  box-sizing: border-box;
  height: 100%;
  padding: 0 179px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ww-modal--customise .ww-modal__scroll-inner::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Same Figma scrollbar treatment as legal modals — rail width from main.css */
.ww-modal--customise .ww-modal__scrollbar {
  position: absolute;
  top: 16px;
  right: 32px;
  z-index: 2;
  height: calc(100% - 40px);
  max-height: 594px;
  pointer-events: none;
}

.ww-modal--customise .ww-modal__intro {
  margin: 0;
  max-width: 755px;
  font-family: "General Sans", Inter, "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 25px;
  color: #6b7280;
}

.ww-modal--customise .ww-modal__intro a {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-weight: 600;
  color: #1f2933;
  text-decoration: none;
}

.ww-modal--customise .ww-modal__intro a:hover {
  text-decoration: underline;
}

.ww-modal--customise .ww-modal__allow {
  margin: 48px 0 0; /* 168 − 70 − 50 */
  font-family: "General Sans", Inter, "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 27px;
  color: #1f2933;
}

.ww-modal--customise .cookie-pref-list {
  display: flex;
  flex-direction: column;
  gap: 38px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  max-width: 755px;
}

.cookie-pref {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  column-gap: 24px; /* 69 − 45 */
  row-gap: 10px;
  align-items: start;
}

.cookie-pref__toggle {
  grid-column: 1;
  grid-row: 1;
  margin-top: 0;
}

.cookie-pref__name {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 25px;
  color: #1f2933;
}

.cookie-pref__desc {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 25px;
  color: #6b7280;
}

/* ============================================================
   Switch — Figma 4109:47250 / Switch (45×27)
   On:  Default #1F2933 · Hover #8F9499 · On Click #6B7280
   Off: Default rgba(31,41,51,0.16) · Hover 0.32 · On Click 0.4
   Focus: 55×33 ring, 0.5px #1F2933, radius 2px
   Disabled: same glyph at 50% opacity
   ============================================================ */
.cookie-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 45px;
  height: 27px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1f2933;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s ease;
}

.cookie-toggle__icon {
  display: none;
  width: 45px;
  height: 27px;
  flex-shrink: 0;
  pointer-events: none;
}

.cookie-toggle[aria-checked="true"] .cookie-toggle__icon--on {
  display: block;
}

.cookie-toggle[aria-checked="false"] .cookie-toggle__icon--off {
  display: block;
}

/* Off */
.cookie-toggle[aria-checked="false"] {
  color: rgba(31, 41, 51, 0.16);
}

/* Hover */
@media (hover: hover) {
  .cookie-toggle:hover:not(:disabled):not(.is-locked)[aria-checked="true"] {
    color: #8f9499;
  }

  .cookie-toggle:hover:not(:disabled):not(.is-locked)[aria-checked="false"] {
    color: rgba(31, 41, 51, 0.32);
  }
}

/* On Click / pressed */
.cookie-toggle:active:not(:disabled):not(.is-locked)[aria-checked="true"] {
  color: #6b7280;
}

.cookie-toggle:active:not(:disabled):not(.is-locked)[aria-checked="false"] {
  color: rgba(31, 41, 51, 0.4);
}

/* Focus — Figma 55×33 frame, 0.5px stroke, radius 2px */
.cookie-toggle:focus {
  outline: none;
}

.cookie-toggle:focus::after,
.cookie-toggle:focus-visible::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 55px;
  height: 33px;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  border: 0.5px solid #1f2933;
  border-radius: 2px;
  pointer-events: none;
}

.cookie-toggle:disabled:focus::after,
.cookie-toggle.is-locked:focus::after {
  content: none;
}

/* Disabled / locked — Figma opacity 0.5 */
.cookie-toggle:disabled,
.cookie-toggle.is-locked {
  cursor: default;
  opacity: 0.5;
  color: #1f2933;
}

.cookie-toggle:disabled[aria-checked="false"],
.cookie-toggle.is-locked[aria-checked="false"] {
  color: rgba(31, 41, 51, 0.16);
}

.ww-modal--customise .ww-modal__footer {
  flex: 0 0 136px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
  padding: 40px 0 0;
}

.ww-modal--customise .ww-modal__cta {
  width: 320px;
  height: 56px;
  border-radius: 3px;
}

/* ============================================================
   0070 Terms / 0080 Privacy — shared scrollable legal modal
   Panel 1115×922; mask 1115×786; title fixed; content scrolls
   Figma scrollbar: 4×594 @ content (999,105) → panel (1079,129)
   ============================================================ */
.ww-modal--legal .ww-modal__panel {
  width: 1115px;
  height: 922px;
  max-height: calc(100vh - 48px);
}

/* Fixed title — outside scroll (Figma content y:24 + title y:24) */
.ww-modal--legal .ww-modal__header {
  flex: 0 0 auto;
  box-sizing: border-box;
  padding: 48px 80px 24px; /* 48 title top + 32 title + 24 gap → sections at y:104 */
}

.ww-modal--legal .ww-modal__title {
  margin: 0 auto;
  max-width: 955px;
  font-family: "General Sans", Inter, "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: 0.02em;
  text-align: center;
  color: #1f2933;
}

/* Content-only scroll region (mask 786 − header 104 = 682) */
.ww-modal--legal .ww-modal__scroll {
  position: relative;
  flex: 1 1 auto;
  height: 682px;
  max-height: calc(100% - 104px - 136px);
  min-height: 0;
  overflow: hidden;
}

.ww-modal--legal .ww-modal__scroll-inner {
  box-sizing: border-box;
  height: 100%;
  padding: 0 80px 40px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  /* Hide native scrollbar; custom Figma bar is used instead */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ww-modal--legal .ww-modal__scroll-inner::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Figma Scroll #4109:8801 / #4109:8762 — rail width from main.css */
.ww-modal--legal .ww-modal__scrollbar {
  position: absolute;
  top: 25px;
  right: 32px;
  z-index: 2;
  height: 594px;
  pointer-events: none;
}

.ww-modal--legal .ww-modal__scrollbar[hidden],
.ww-modal--customise .ww-modal__scrollbar[hidden] {
  display: none !important;
}

.ww-modal--legal .legal-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto;
  max-width: 955px;
  padding: 0;
}

.legal-section {
  margin: 0;
}

.legal-section__title {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 25px;
  color: #1f2933;
}

.legal-section__body {
  margin: 16px 0 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  color: #6b7280;
}

.legal-section__body + .legal-section__body {
  margin-top: 8px;
}

.legal-section__body--light {
  font-family: "General Sans", Inter, "Plus Jakarta Sans", system-ui, sans-serif;
  font-weight: 300;
}

.legal-section__body a,
.legal-section__em {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-weight: 600;
  color: #1f2933;
  text-decoration: none;
}

.legal-section__body a:hover {
  text-decoration: underline;
}

.legal-section__list {
  margin: 16px 0 0;
  padding: 0 0 0 1.15em;
  list-style: disc;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  color: #6b7280;
}

.legal-section__list li + li {
  margin-top: 0;
}

.ww-modal--legal .ww-modal__footer {
  flex: 0 0 136px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
  padding: 40px 0 0;
}

.ww-modal--legal .ww-modal__cta {
  width: 320px;
  height: 56px;
}

/* ---------- Tablet / mobile ----------
   Cap panel to viewport; keep title+footer fixed; content scrolls.
   Fixed desktop heights (864/922/609/682) must be overridden. */
@media (max-width: 1279px) {
  .ww-modal {
    padding: 16px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .ww-modal--customise .ww-modal__panel,
  .ww-modal--legal .ww-modal__panel {
    width: 100%;
    max-width: 100%;
    /* Definite height so flex child can scroll */
    height: calc(100vh - 32px);
    height: min(922px, calc(100dvh - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    min-height: 0;
  }

  .ww-modal--customise .ww-modal__panel {
    height: calc(100vh - 32px);
    height: min(864px, calc(100dvh - 32px));
  }

  .ww-modal--customise .ww-modal__header {
    flex: 0 0 auto;
    padding: 40px 32px 12px;
  }

  .ww-modal--legal .ww-modal__header {
    flex: 0 0 auto;
    padding: 40px 32px 16px;
  }

  .ww-modal--customise .ww-modal__scroll,
  .ww-modal--legal .ww-modal__scroll {
    position: relative;
    flex: 1 1 auto;
    height: auto !important;
    max-height: none !important;
    min-height: 0;
    overflow: hidden;
  }

  .ww-modal--customise .ww-modal__scroll-inner,
  .ww-modal--legal .ww-modal__scroll-inner {
    position: absolute;
    inset: 0;
    height: auto;
    max-height: none;
    padding: 0 32px 24px;
    padding-right: 40px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .ww-modal--customise .ww-modal__close,
  .ww-modal--legal .ww-modal__close {
    top: 16px;
    right: 16px;
  }

  .ww-modal--customise .ww-modal__scrollbar,
  .ww-modal--legal .ww-modal__scrollbar {
    /* Close 28px at right 16 → center 30 from edge; 2px rail → right 29 */
    top: 0;
    right: 29px;
    height: calc(100% - 16px);
    max-height: none;
  }

  .ww-modal--legal .ww-modal__footer,
  .ww-modal--customise .ww-modal__footer {
    /* Override desktop 136px fixed footer */
    flex: 0 0 auto;
    flex-basis: auto;
    min-height: 0;
    padding: 20px 16px 28px;
  }
}

@media (max-width: 719px) {
  .ww-modal {
    padding: 12px;
  }

  .ww-modal--customise .ww-modal__panel,
  .ww-modal--legal .ww-modal__panel {
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 8px;
  }

  .ww-modal--customise .ww-modal__header {
    padding: 36px 20px 8px;
  }

  .ww-modal--legal .ww-modal__header {
    padding: 36px 20px 12px;
  }

  .ww-modal--customise .ww-modal__close,
  .ww-modal--legal .ww-modal__close {
    top: 14px;
    right: 14px;
  }

  .ww-modal--customise .ww-modal__scrollbar,
  .ww-modal--legal .ww-modal__scrollbar {
    /* Close 28px at right 14 → center 28 from edge; 2px rail → right 27 */
    top: 0;
    right: 27px;
    height: calc(100% - 12px);
  }

  .ww-modal--customise .ww-modal__scroll-inner,
  .ww-modal--legal .ww-modal__scroll-inner {
    padding: 0 20px 16px;
    padding-right: 36px;
  }

  .ww-modal--customise .ww-modal__title,
  .ww-modal--legal .ww-modal__title {
    font-size: 20px;
    line-height: 28px;
  }

  .ww-modal--customise .ww-modal__intro,
  .ww-modal--customise .ww-modal__allow,
  .ww-modal--customise .cookie-pref__name,
  .ww-modal--customise .cookie-pref__desc {
    font-size: 16px;
    line-height: 22px;
  }

  .ww-modal--customise .ww-modal__allow {
    margin-top: 28px;
  }

  .cookie-pref {
    grid-template-columns: 45px minmax(0, 1fr);
    column-gap: 12px;
  }

  .ww-modal--customise .ww-modal__cta,
  .ww-modal--legal .ww-modal__cta {
    width: 100%;
    max-width: 320px;
    font-size: 16px;
    white-space: normal;
  }

  .ww-modal--legal .ww-modal__footer,
  .ww-modal--customise .ww-modal__footer {
    padding: 16px 16px 24px;
  }
}

/* Body lock while any modal is open */
body.ww-modal-open {
  overflow: hidden;
  touch-action: none;
}
