/*
 * Cookie consent popup (eu_cookie_compliance, categories mode).
 *
 * Restyles the contrib popup in the flat site style: one typeface, one fluid
 * text size and one line-height throughout, square white buttons with red
 * labels and no text shadow, and Utopia fluid spacing between the 360px and
 * 1280px viewport anchors (values from fluid_clamp, 14px => 16px base).
 *
 * Loaded standalone after css/styles.css: the theme's main stylesheet is built
 * with Compass/Ruby SASS, which cannot be compiled locally. Every rule is
 * scoped under #sliding-popup so it outranks both the module stylesheet and
 * the legacy flatcookies mixin output without !important.
 */

#sliding-popup {
  /* Utopia type step 0 and space scale (360px => 1280px). */
  --koba-cookie-step-0: clamp(0.875rem, 0.8261rem + 0.2174vw, 1rem);
  --koba-cookie-space-3xs: clamp(0.2188rem, 0.2065rem + 0.0543vw, 0.25rem);
  --koba-cookie-space-2xs: clamp(0.4375rem, 0.413rem + 0.1087vw, 0.5rem);
  --koba-cookie-space-xs: clamp(0.6562rem, 0.6196rem + 0.163vw, 0.75rem);
  --koba-cookie-space-s: clamp(0.875rem, 0.8261rem + 0.2174vw, 1rem);
  --koba-cookie-space-m: clamp(1.3125rem, 1.2391rem + 0.3261vw, 1.5rem);
  /* One-up pair l => xl: the popup edge padding grows faster than the text. */
  --koba-cookie-space-l-xl: clamp(1.75rem, 1.2609rem + 2.1739vw, 3rem);
  --koba-cookie-line-height: 1.5;
  --koba-cookie-border: max(1px, 0.0625rem);
  /* Brand red ($red in sass/_init.scss), same value as popup_bg_hex. */
  --koba-cookie-red: #ff7159;
  --koba-cookie-white: #fff;
  --koba-cookie-black: #000;

  /* The module writes popup_width (50%) as an inline width. min-width beats
     width, so narrow viewports get a usable full-width popup, and max-width
     caps the line length on wide screens, both without !important. */
  min-width: min(100%, 34rem);
  max-width: 44rem;
  /* Long category lists must stay reachable on short screens: the popup is
     fixed to the bottom, so overflow would otherwise end up off-screen. */
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  /* The module injects a visually-hidden withdraw button that sits outside
     the popup box; without this it adds a horizontal scrollbar. */
  overflow-x: hidden;
  overscroll-behavior: contain;
  container: koba-cookie / inline-size;
  font-family: 'Poppins', sans-serif;
  font-size: var(--koba-cookie-step-0);
  line-height: var(--koba-cookie-line-height);
  text-align: left;
}

/* One size, one line-height, one typeface for every text element. */
#sliding-popup :is(h1, h2, h3, p, label, button, .eu-cookie-compliance-category-description) {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
  color: var(--koba-cookie-white);
}

#sliding-popup .eu-cookie-compliance-banner {
  padding: var(--koba-cookie-space-l-xl);
}

/* Grid replaces the module floats: message and categories on full rows, the
   two buttons side by side on the last row. The flexible second track keeps
   the full-row items out of the first column's sizing, so that column is
   exactly as wide as the save button. */
#sliding-popup .eu-cookie-compliance-content {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--koba-cookie-space-s);
  width: auto;
  max-width: none;
  margin: 0;
}

/* The categories wrapper only groups markup; its children join the grid so
   the save button can share a row with the accept button. */
#sliding-popup .eu-cookie-compliance-categories {
  display: contents;
}

#sliding-popup .eu-cookie-compliance-message,
#sliding-popup .eu-cookie-compliance-category {
  grid-column: 1 / -1;
  width: auto;
  max-width: none;
  margin: 0;
}

#sliding-popup .eu-cookie-compliance-message {
  margin-bottom: var(--koba-cookie-space-2xs);
}

#sliding-popup .eu-cookie-compliance-message :is(h1, h2, h3, p) {
  display: block;
  margin: 0;
  padding: 0;
  font-weight: 600;
}

#sliding-popup .eu-cookie-compliance-more-button {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

#sliding-popup .eu-cookie-compliance-more-button:hover {
  background: none;
  text-decoration-thickness: 2px;
}

#sliding-popup .eu-cookie-compliance-category > div:first-child {
  display: flex;
  align-items: center;
  gap: var(--koba-cookie-space-2xs);
}

#sliding-popup .eu-cookie-compliance-category-checkbox {
  flex: none;
  width: 1em;
  height: 1em;
  margin: 0;
  accent-color: var(--koba-cookie-black);
}

#sliding-popup .eu-cookie-compliance-category label {
  display: inline;
  font-weight: 600;
  cursor: pointer;
}

#sliding-popup .eu-cookie-compliance-category-description {
  margin-top: var(--koba-cookie-space-3xs);
}

#sliding-popup .eu-cookie-compliance-categories-buttons,
#sliding-popup .eu-cookie-compliance-buttons {
  float: none;
  width: auto;
  max-width: none;
  margin: var(--koba-cookie-space-xs) 0 0;
}

#sliding-popup .eu-cookie-compliance-categories-buttons {
  grid-column: 1;
}

#sliding-popup .eu-cookie-compliance-buttons {
  grid-column: 2;
  justify-self: start;
}

/* Buttons: white, red label, square corners, no shadows or gradients. The
   transparent border keeps the button outline visible in forced-colors mode. */
#sliding-popup .eu-cookie-compliance-buttons button,
#sliding-popup .eu-cookie-compliance-save-preferences-button {
  display: inline-block;
  position: static;
  width: auto;
  margin: 0;
  padding: var(--koba-cookie-space-2xs) var(--koba-cookie-space-m);
  border: var(--koba-cookie-border) solid transparent;
  border-radius: 0;
  background: var(--koba-cookie-white);
  box-shadow: none;
  color: var(--koba-cookie-red);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

#sliding-popup .eu-cookie-compliance-buttons button:hover,
#sliding-popup .eu-cookie-compliance-save-preferences-button:hover,
#sliding-popup .eu-cookie-compliance-buttons button:focus-visible,
#sliding-popup .eu-cookie-compliance-save-preferences-button:focus-visible {
  background: var(--koba-cookie-black);
  color: var(--koba-cookie-white);
}

#sliding-popup button:focus-visible,
#sliding-popup .eu-cookie-compliance-category-checkbox:focus-visible {
  outline: max(2px, 0.125rem) solid var(--koba-cookie-black);
  outline-offset: 2px;
}

#sliding-popup .eu-cookie-compliance-buttons button:active,
#sliding-popup .eu-cookie-compliance-save-preferences-button:active {
  top: auto;
}

/* Narrow popup: stack the buttons on full-width rows. */
@container koba-cookie (width < 30rem) {
  #sliding-popup .eu-cookie-compliance-content {
    grid-template-columns: 1fr;
  }

  #sliding-popup .eu-cookie-compliance-categories-buttons,
  #sliding-popup .eu-cookie-compliance-buttons {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  /* Stacked, the row gap alone separates the two buttons. */
  #sliding-popup .eu-cookie-compliance-buttons {
    margin-top: 0;
  }

  #sliding-popup .eu-cookie-compliance-buttons button,
  #sliding-popup .eu-cookie-compliance-save-preferences-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #sliding-popup .eu-cookie-compliance-buttons button,
  #sliding-popup .eu-cookie-compliance-save-preferences-button {
    transition: none;
  }
}
