/*
 * Cookie banner.
 *
 * Colours come from the theme when it provides SepoDesk tokens (--sd-*), and
 * from the plugin's own palette otherwise. .is-dark is set by the banner
 * script when the page is in dark mode, whatever theme draws it.
 */

.sepo-cc-scope {
  --cc-accent: var(--sepo-cc-accent-custom, var(--sd-btn-bg, #0b3d33));
  --cc-accent-hover: var(--sepo-cc-accent-custom, var(--sd-btn-bg-h, #123f35));
  --cc-on-accent: var(--sepo-cc-on-accent-custom, var(--sd-btn-fg, #ffffff));
  --cc-surface: var(--sd-surface, #ffffff);
  --cc-soft: var(--sd-surface-2, #f7faf8);
  --cc-tint: var(--sd-mint, #eaf6f0);
  --cc-heading: var(--sd-heading, #0b3d33);
  --cc-text: var(--sd-text, #4b5b56);
  --cc-muted: var(--sd-muted, #6d7e78);
  --cc-line: var(--sd-border, #e4ebe8);
  --cc-veil: rgba(6, 24, 20, 0.42);
  --cc-radius: var(--sd-radius, 18px);
  --cc-radius-sm: var(--sd-radius-sm, 12px);
  --cc-font: var(--sd-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  --cc-mono: var(--sd-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  --cc-ease: var(--sd-ease, cubic-bezier(0.2, 0.7, 0.3, 1));
}

.sepo-cc-scope.is-dark {
  --cc-accent: var(--sepo-cc-accent-dark, var(--sd-btn-bg, #3ed598));
  --cc-accent-hover: var(--sepo-cc-accent-dark, var(--sd-btn-bg-h, #63e0ae));
  --cc-on-accent: var(--sepo-cc-on-accent-dark, var(--sd-btn-fg, #06231c));
  --cc-surface: var(--sd-surface, #111a18);
  --cc-soft: var(--sd-surface-2, #0c1513);
  --cc-tint: var(--sd-mint, rgba(62, 213, 152, 0.12));
  --cc-heading: var(--sd-heading, #eef6f2);
  --cc-text: var(--sd-text, #b5c7c1);
  --cc-muted: var(--sd-muted, #8ea39c);
  --cc-line: var(--sd-border, rgba(255, 255, 255, 0.12));
  --cc-veil: rgba(0, 0, 0, 0.6);
}

/* Theme rules for headings, paragraphs and buttons stop at the banner. */
.sepo-cc-scope,
.sepo-cc-scope * {
  box-sizing: border-box;
}
.sepo-cc-scope :is(h2, h3, p) {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--cc-font);
}
.sepo-cc-scope :is(button, .sepo-cc-btn) {
  margin: 0;
  font-family: var(--cc-font);
  text-transform: none;
  letter-spacing: -0.01em;
  box-shadow: none;
  text-shadow: none;
  min-height: 0;
  width: auto;
}
.sepo-cc-scope[hidden],
.sepo-cc-scope [hidden] {
  display: none !important;
}
.sepo-cc-scope svg {
  display: block;
  flex: none;
}

/* ------------------------------------------------------------ buttons */

.sepo-cc-scope .sepo-cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.sepo-cc-scope .sepo-cc-btn--primary {
  background: var(--cc-accent);
  color: var(--cc-on-accent);
}
.sepo-cc-scope .sepo-cc-btn--primary:hover {
  background: var(--cc-accent-hover);
  color: var(--cc-on-accent);
}
.sepo-cc-scope .sepo-cc-btn--soft {
  background: var(--cc-tint);
  color: var(--cc-heading);
  border-color: transparent;
}
.sepo-cc-scope .sepo-cc-btn--soft:hover {
  background: color-mix(in srgb, var(--cc-accent) 18%, var(--cc-surface));
  color: var(--cc-heading);
}
.sepo-cc-scope .sepo-cc-btn--ghost {
  background: transparent;
  color: var(--cc-heading);
  border-color: var(--cc-line);
}
.sepo-cc-scope .sepo-cc-btn--ghost:hover {
  background: var(--cc-tint);
  color: var(--cc-heading);
}
.sepo-cc-scope .sepo-cc-btn--link {
  height: auto;
  padding: 4px 2px;
  background: none;
  color: var(--cc-heading);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
.sepo-cc-scope :is(.sepo-cc-btn, button, a, input):focus-visible {
  outline: 2px solid var(--cc-accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ banner */

.sepo-cc {
  position: fixed;
  z-index: 2147482000;
  font-family: var(--cc-font);
  color: var(--cc-text);
}

.sepo-cc__banner {
  position: relative;
  z-index: 1;
  background: var(--cc-surface);
  border: 1px solid var(--cc-line);
  border-radius: var(--cc-radius);
  padding: 22px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.32s var(--cc-ease), transform 0.32s var(--cc-ease);
}
.sepo-cc__banner:focus,
.sepo-cc-prefs__box:focus {
  outline: none;
}
.sepo-cc__banner.is-in {
  opacity: 1;
  transform: none;
}

.sepo-cc__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.sepo-cc-scope .sepo-cc__icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--cc-tint);
  color: var(--cc-heading);
}
.sepo-cc-scope .sepo-cc__title {
  color: var(--cc-heading);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.sepo-cc-scope .sepo-cc__msg {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--cc-text);
}
.sepo-cc-scope .sepo-cc__msg a,
.sepo-cc-scope .sepo-cc-prefs__intro a {
  color: var(--cc-heading);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.sepo-cc-scope .sepo-cc__preview {
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: var(--cc-radius-sm);
  background: color-mix(in srgb, #f2b33d 18%, var(--cc-surface));
  color: var(--cc-heading);
  font-size: 13px;
  font-weight: 600;
}

.sepo-cc__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}
.sepo-cc__actions [data-act="manage"] {
  grid-column: 1 / -1;
  order: 3;
}
.sepo-cc__actions [data-act="reject"] { order: 1; }
.sepo-cc__actions [data-act="accept"] { order: 2; }

/* Card: a corner of the screen. */
.sepo-cc[data-layout="card"] {
  bottom: 20px;
  left: 20px;
  width: min(420px, calc(100vw - 32px));
}
.sepo-cc[data-layout="card"][data-position="right"] {
  left: auto;
  right: 20px;
}

/* Bar: full width along the bottom. */
.sepo-cc[data-layout="bar"] {
  left: 0;
  right: 0;
  bottom: 0;
}
.sepo-cc[data-layout="bar"] .sepo-cc__banner {
  border-width: 1px 0 0;
  border-radius: 0;
  padding: 20px max(20px, calc((100vw - 1180px) / 2));
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "head actions" "msg actions";
  column-gap: 32px;
  align-items: center;
}
.sepo-cc[data-layout="bar"] .sepo-cc__head { grid-area: head; margin-bottom: 6px; }
.sepo-cc[data-layout="bar"] .sepo-cc__msg { grid-area: msg; max-width: 760px; }
.sepo-cc[data-layout="bar"] .sepo-cc__preview { grid-column: 1 / -1; }
.sepo-cc[data-layout="bar"] .sepo-cc__actions {
  grid-area: actions;
  display: flex;
  margin-top: 0;
}
.sepo-cc[data-layout="bar"] .sepo-cc__actions [data-act="manage"] { order: 0; }

/* Modal: centred, the page waits behind a veil. */
.sepo-cc[data-layout="modal"] {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
}
.sepo-cc[data-layout="modal"] .sepo-cc__banner {
  width: min(520px, 100%);
  padding: 28px;
  pointer-events: auto;
}
.sepo-cc[data-layout="modal"] .sepo-cc__banner[hidden] ~ .sepo-cc__veil { display: none; }
.sepo-cc__veil {
  position: fixed;
  inset: 0;
  background: var(--cc-veil);
  pointer-events: auto;
}

html.sepo-cc-locked {
  overflow: hidden;
}

/* ------------------------------------------------------------ revisit button */

.sepo-cc-scope.sepo-cc-fab {
  position: fixed;
  z-index: 2147481000;
  bottom: 20px;
  left: 20px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--cc-line);
  border-radius: 50%;
  background: var(--cc-surface);
  color: var(--cc-heading);
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s var(--cc-ease);
}
.sepo-cc-scope.sepo-cc-fab[data-position="right"] {
  left: auto;
  right: 20px;
}
.sepo-cc-scope.sepo-cc-fab:hover {
  background: var(--cc-tint);
  transform: translateY(-2px);
}

/* ------------------------------------------------------------ preferences */

.sepo-cc-prefs {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 16px;
  font-family: var(--cc-font);
  color: var(--cc-text);
}
.sepo-cc-prefs__veil {
  position: absolute;
  inset: 0;
  background: var(--cc-veil);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sepo-cc-prefs__box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  background: var(--cc-surface);
  border: 1px solid var(--cc-line);
  border-radius: var(--cc-radius);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 0.28s var(--cc-ease), transform 0.28s var(--cc-ease);
}
.sepo-cc-prefs.is-in .sepo-cc-prefs__veil { opacity: 1; }
.sepo-cc-prefs.is-in .sepo-cc-prefs__box { opacity: 1; transform: none; }

.sepo-cc-prefs__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--cc-line);
}
.sepo-cc-scope .sepo-cc-prefs__title {
  flex: 1;
  color: var(--cc-heading);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.sepo-cc-scope .sepo-cc-prefs__close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--cc-line);
  border-radius: 50%;
  background: transparent;
  color: var(--cc-heading);
  cursor: pointer;
}
.sepo-cc-scope .sepo-cc-prefs__close:hover { background: var(--cc-tint); }

.sepo-cc-prefs__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px 22px;
}
.sepo-cc-scope .sepo-cc-prefs__intro {
  font-size: 14.5px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.sepo-cc-cat {
  padding: 16px 18px;
  border: 1px solid var(--cc-line);
  border-radius: var(--cc-radius-sm);
  background: var(--cc-surface);
}
.sepo-cc-cat + .sepo-cc-cat { margin-top: 10px; }
.sepo-cc-cat.is-locked { background: var(--cc-soft); }
.sepo-cc-cat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.sepo-cc-scope .sepo-cc-cat__title {
  color: var(--cc-heading);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
}
.sepo-cc-scope .sepo-cc-cat__desc {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.55;
}
.sepo-cc-scope .sepo-cc-badge {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--cc-tint);
  color: var(--cc-heading);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
}

.sepo-cc-scope .sepo-cc-cat__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--cc-heading);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}
.sepo-cc-cat__chev {
  display: inline-grid;
  transition: transform 0.2s var(--cc-ease);
}
.sepo-cc-cat__more[aria-expanded="true"] .sepo-cc-cat__chev { transform: rotate(90deg); }
.sepo-cc-scope .sepo-cc-cat__count {
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--cc-soft);
  color: var(--cc-muted);
  font-size: 12px;
  font-weight: 600;
}
.sepo-cc-cat.is-locked .sepo-cc-cat__count { background: var(--cc-surface); }

.sepo-cc-cookies {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.sepo-cc-cookie {
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--cc-soft);
}
.sepo-cc-cat.is-locked .sepo-cc-cookie { background: var(--cc-surface); }
.sepo-cc-cookie__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.sepo-cc-scope .sepo-cc-cookie__name {
  padding: 0;
  background: none;
  color: var(--cc-heading);
  font-family: var(--cc-mono);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.sepo-cc-cookie__dur {
  flex: none;
  color: var(--cc-muted);
  font-size: 12.5px;
}
.sepo-cc-scope .sepo-cc-cookie__purpose {
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.5;
}
.sepo-cc-scope .sepo-cc-cookie__meta {
  margin-top: 3px;
  color: var(--cc-muted);
  font-size: 12.5px;
}
.sepo-cc-scope .sepo-cc-cookies__none {
  color: var(--cc-muted);
  font-size: 13.5px;
}

/* Switch */
.sepo-cc-switch {
  position: relative;
  flex: none;
  display: inline-block;
  width: 46px;
  height: 26px;
  margin: 0;
  cursor: pointer;
}
.sepo-cc-scope .sepo-cc-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.sepo-cc-switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cc-muted) 38%, var(--cc-surface));
  transition: background-color 0.2s ease;
}
.sepo-cc-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.22s var(--cc-ease), background-color 0.2s ease;
}
.sepo-cc-switch input:checked + .sepo-cc-switch__track { background: var(--cc-accent); }
.sepo-cc-switch input:checked + .sepo-cc-switch__track::after {
  transform: translateX(20px);
  background: var(--cc-on-accent);
}
.sepo-cc-switch input:focus-visible + .sepo-cc-switch__track {
  outline: 2px solid var(--cc-accent);
  outline-offset: 2px;
}

.sepo-cc-prefs__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--cc-line);
  background: var(--cc-surface);
}
.sepo-cc-prefs__gap { flex: 1; }

/* ------------------------------------------------------------ blocked embeds */

.sepo-cc-embed {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 220px;
  margin: 0 0 1em;
  padding: 28px 22px;
  border: 1px dashed var(--cc-line);
  border-radius: var(--cc-radius-sm);
  background: var(--cc-soft);
  color: var(--cc-text);
  font-family: var(--cc-font);
  text-align: center;
}
.sepo-cc-embed.is-fill {
  aspect-ratio: 16 / 9;
  min-height: 0;
}
.sepo-cc-scope .sepo-cc-embed__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cc-tint);
  color: var(--cc-heading);
}
.sepo-cc-scope .sepo-cc-embed__text {
  max-width: 420px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--cc-text);
}
.sepo-cc-embed__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
}

/* ------------------------------------------------------------ shortcodes */

.sepo-cc-trigger {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  box-shadow: none;
}
.sepo-cc-trigger.sepo-cc-trigger--button {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--sepo-cc-accent-custom, var(--sd-btn-bg, #0b3d33));
  color: var(--sepo-cc-on-accent-custom, var(--sd-btn-fg, #ffffff));
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
}

.sepo-cc-list section + section { margin-top: 1.6em; }
.sepo-cc-list h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sepo-cc-list__state {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sd-surface-2, rgba(127, 127, 127, 0.14));
  color: var(--sd-text, inherit);
  font-family: var(--sd-font, inherit);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}
.sepo-cc-list__state:empty { display: none; }
.sepo-cc-list__state.is-on {
  background: var(--sd-mint, #eaf6f0);
  color: var(--sd-heading, #0b3d33);
}
.sepo-cc-list__status {
  padding: 12px 16px;
  border-radius: var(--sd-radius-sm, 12px);
  background: var(--sd-mint, rgba(18, 133, 95, 0.1));
}
.sepo-cc-list__scroll { overflow-x: auto; }
.sepo-cc-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
.sepo-cc-list :is(th, td) {
  padding: 10px 12px;
  border-bottom: 1px solid var(--sd-border, rgba(127, 127, 127, 0.25));
  text-align: left;
  vertical-align: top;
}
.sepo-cc-list :is(th, td):first-child {
  width: 28%;
}
.sepo-cc-list code {
  word-break: normal;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 640px) {
  .sepo-cc[data-layout="card"],
  .sepo-cc[data-layout="card"][data-position="right"] {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
  .sepo-cc[data-layout="bar"] .sepo-cc__banner {
    display: block;
    padding: 18px 16px;
  }
  .sepo-cc[data-layout="bar"] .sepo-cc__actions {
    display: grid;
    margin-top: 16px;
  }
  .sepo-cc[data-layout="bar"] .sepo-cc__actions [data-act="manage"] { order: 3; }
  .sepo-cc-prefs { padding: 0; place-items: end stretch; }
  .sepo-cc-prefs__box {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--cc-radius) var(--cc-radius) 0 0;
    border-width: 1px 0 0;
  }
  .sepo-cc-prefs__foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .sepo-cc-prefs__gap { display: none; }
  .sepo-cc-prefs__foot [data-act="accept"] { grid-column: 1 / -1; order: -1; }
  .sepo-cc-scope.sepo-cc-fab { bottom: 12px; left: 12px; }
  .sepo-cc-scope.sepo-cc-fab[data-position="right"] { right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sepo-cc__banner,
  .sepo-cc-prefs__box,
  .sepo-cc-prefs__veil,
  .sepo-cc-switch__track,
  .sepo-cc-switch__track::after {
    transition: none;
  }
}
