/* ============================================================
   USMLE Wise: cookie consent banner (markup is built by js/consent.js)
   and the footer "Cookie settings" control.
   Everything is namespaced uw-consent so it cannot collide with page CSS,
   and it uses the design-system tokens so dark mode follows automatically.
   ============================================================ */

.uw-consent {
  position: fixed;
  left: 24px;
  bottom: 24px;
  left: calc(24px + env(safe-area-inset-left, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 400; /* above the WhatsApp button (90) and nav layers, below modals */
  width: min(440px, calc(100vw - 32px));
  font-family: var(--font-sans);
}
.uw-consent[hidden] { display: none !important; }

.uw-consent__card {
  box-sizing: border-box;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 20px;
  background: var(--uw-surface);
  color: var(--uw-ink-800);
  border: 1px solid var(--uw-border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: uw-consent-in var(--dur-med) var(--ease-out) both;
  overscroll-behavior: contain;
}
.uw-consent__card:focus { outline: none; }
.uw-consent__card:focus-visible { outline: 2px solid var(--uw-blue-300); outline-offset: 2px; }

@keyframes uw-consent-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.uw-consent__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.uw-consent__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--uw-ink-900);
}
.uw-consent__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: -6px -8px 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--uw-ink-500);
  cursor: pointer;
}
.uw-consent__close[hidden] { display: none; }
.uw-consent__close:hover { color: var(--uw-ink-900); background: var(--uw-ink-75); }

.uw-consent__text {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--uw-ink-600);
}
.uw-consent__text a { color: var(--uw-blue-600); text-decoration: underline; text-underline-offset: 3px; }

/* Settings panel: one row per category with a switch. */
.uw-consent__panel { margin: 0 0 16px; border-top: 1px solid var(--uw-border); }
.uw-consent__panel[hidden] { display: none; }
.uw-consent__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--uw-border);
  cursor: pointer;
}
.uw-consent__rowtext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.uw-consent__rowtext strong { font-size: 14px; font-weight: 600; color: var(--uw-ink-900); }
.uw-consent__rowtext span { font-size: 13px; line-height: 1.45; color: var(--uw-ink-500); }

.uw-consent__switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--uw-border-strong);
  cursor: pointer;
  transition: background 0.15s ease;
}
.uw-consent__switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.uw-consent__switch:checked { background: var(--uw-blue-500); }
.uw-consent__switch:checked::after { transform: translateX(18px); }
.uw-consent__switch:disabled { opacity: 0.55; cursor: not-allowed; }
.uw-consent__switch:focus-visible { outline: 2px solid var(--uw-blue-300); outline-offset: 2px; }

/* Reject and Accept are deliberately the same size, weight and position. */
.uw-consent__actions { display: flex; gap: 10px; }
.uw-consent__btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--r-md);
  border: 1.5px solid var(--uw-blue-500);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.uw-consent__btn--solid { background: var(--uw-blue-500); color: #fff; }
.uw-consent__btn--solid:hover { background: var(--uw-blue-600); border-color: var(--uw-blue-600); }
.uw-consent__btn--outline { background: transparent; color: var(--uw-blue-500); }
.uw-consent__btn--outline:hover { background: var(--uw-ink-75); }
.uw-consent__btn:focus-visible,
.uw-consent__link:focus-visible { outline: 2px solid var(--uw-blue-300); outline-offset: 2px; }

.uw-consent__save { display: block; width: 100%; margin-top: 10px; }
.uw-consent__save[hidden] { display: none; }

.uw-consent__link {
  display: block;
  margin: 12px auto 0;
  padding: 4px 8px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--uw-ink-600);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.uw-consent__link[hidden] { display: none; }
.uw-consent__link:hover { color: var(--uw-ink-900); }

/* Phones: a sheet across the bottom (above the full-width WhatsApp bar). */
@media (max-width: 640px) {
  .uw-consent {
    left: 12px;
    right: 12px;
    bottom: 12px;
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }
  .uw-consent__card { padding: 16px; max-height: calc(100dvh - 24px); }
  .uw-consent__title { font-size: 17px; }
  .uw-consent__text { margin-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .uw-consent__card { animation: none; }
  .uw-consent__switch,
  .uw-consent__switch::after,
  .uw-consent__btn { transition: none; }
}

@media print { .uw-consent { display: none !important; } }

/* ---------- Footer "Cookie settings" control ----------
   Styled like the neighbouring footer links (those are defined per page, so
   the values are repeated here). Hidden until consent.js is running, so a
   page without the script never shows a button that does nothing. */
.msp-foot__consent {
  align-self: flex-start;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-14);
  color: rgba(255, 255, 255, 0.55);
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease;
}
.msp-foot__consent[hidden] { display: none; }
.msp-foot__consent:hover { color: #fff; }
.msp-foot__consent:focus-visible { outline: 2px solid var(--uw-blue-300); outline-offset: 3px; border-radius: 2px; }
