/* Thiek cookie consent — uses theme tokens with safe fallbacks. */

.thiek-consent {
  position: fixed;
  z-index: 9990;
  right: 16px;
  bottom: 16px;
  left: 16px;
  max-width: 560px;
  margin-left: auto;
  border: 1px solid var(--color-line, rgb(245 243 239 / 16%));
  border-radius: var(--radius-lg, 12px);
  background: var(--color-surface, #1b1a18);
  color: var(--color-text, #f5f3ef);
  box-shadow: 0 12px 40px rgb(0 0 0 / 45%);
}

.thiek-consent[hidden] {
  display: none;
}

.thiek-consent-inner {
  padding: 20px;
}

.thiek-consent-title {
  margin: 0 0 8px;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.thiek-consent-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-muted, #b8b2a8);
  text-wrap: pretty;
}

.thiek-consent-text a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.thiek-consent-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

/* Same weight for every choice: refusing is as easy as accepting. */
.thiek-consent-btn {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--color-text, #f5f3ef);
  border-radius: var(--radius, 8px);
  background: transparent;
  color: var(--color-text, #f5f3ef);
  font: 500 14px/1 var(--font-body, system-ui, sans-serif);
  cursor: pointer;
}

.thiek-consent-btn:hover {
  background: var(--color-text, #f5f3ef);
  color: var(--color-bg, #111);
}

.thiek-consent-btn:focus-visible,
.thiek-consent-close:focus-visible,
.thiek-consent-open:focus-visible,
.thiek-consent-switch input:focus-visible + span {
  outline: 2px solid var(--color-brand-light, #e0705f);
  outline-offset: 2px;
}

/* Preferences panel */
.thiek-consent-panel {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--color-line, rgb(245 243 239 / 16%));
  border-radius: var(--radius-lg, 12px);
  background: var(--color-surface, #1b1a18);
  color: var(--color-text, #f5f3ef);
  overscroll-behavior: contain;
}

.thiek-consent-panel::backdrop {
  background: rgb(0 0 0 / 60%);
}

.thiek-consent-panel-inner {
  padding: 20px;
}

.thiek-consent-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.thiek-consent-panel-head h2 {
  margin: 0;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 18px;
  font-weight: 600;
}

.thiek-consent-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border: 0;
  border-radius: var(--radius, 8px);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.thiek-consent-cat {
  padding: 16px 0;
  border-top: 1px solid var(--color-line, rgb(245 243 239 / 16%));
}

.thiek-consent-cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.thiek-consent-cat h3 {
  margin: 0;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 15px;
  font-weight: 600;
}

.thiek-consent-cat p,
.thiek-consent-note {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-muted, #b8b2a8);
}

.thiek-consent-always {
  font-size: 13px;
  color: var(--color-muted, #b8b2a8);
  white-space: nowrap;
}

.thiek-consent-details {
  margin-top: 8px;
  font-size: 13px;
}

.thiek-consent-details summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.thiek-consent-list {
  display: grid;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.thiek-consent-list li {
  display: grid;
  gap: 2px;
  color: var(--color-muted, #b8b2a8);
}

.thiek-consent-list code {
  font-size: 12px;
  color: var(--color-text, #f5f3ef);
  overflow-wrap: anywhere;
}

.thiek-consent-duration {
  font-size: 12px;
}

/* Switch */
.thiek-consent-switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 44px;
  height: 26px;
}

.thiek-consent-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.thiek-consent-switch span {
  width: 100%;
  height: 100%;
  border: 1px solid var(--color-muted, #b8b2a8);
  border-radius: 999px;
  transition: background 150ms ease;
}

.thiek-consent-switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-muted, #b8b2a8);
  transition: transform 150ms ease;
}

.thiek-consent-switch input:checked + span {
  border-color: var(--color-brand, #b8453a);
  background: var(--color-brand, #b8453a);
}

.thiek-consent-switch input:checked + span::after {
  background: #fff;
  transform: translateX(18px);
}

/* Footer trigger, styled like the legal links. */
.thiek-consent-open {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-size, 44px);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-ivory, #f5f3ef);
  font: inherit;
  font-size: var(--text-small, 14px);
  cursor: pointer;
}

.thiek-consent-open:hover {
  color: var(--color-brand-light, #e0705f);
}

@media (max-width: 599px) {
  .thiek-consent {
    right: 0;
    bottom: 0;
    left: 0;
    max-width: none;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .thiek-consent-inner {
    padding: 16px;
  }

  .thiek-consent-actions {
    grid-template-columns: 1fr 1fr;
  }

  .thiek-consent-actions [data-thiek-consent="customize"],
  .thiek-consent-actions [data-thiek-consent="save"] {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thiek-consent-switch span,
  .thiek-consent-switch span::after {
    transition: none;
  }
}
