/*
 * The owned consent banner and preferences panel for the WordPress surface.
 *
 * Self-contained on purpose: this must render identically whatever theme is
 * active, and it must not depend on a stylesheet an editor can dequeue.
 *
 * Accessibility rules the PRD makes explicit (section 10.3): rejecting is the
 * same size, weight, and click count as accepting. There is no colour
 * asymmetry and no primary/secondary styling on the first layer — the only
 * `--primary` button is Save inside the preferences panel, where it competes
 * with nothing.
 */

/* The preferences panel replaces the banner via innerHTML, so it is a fresh
   element each time it opens: an entry animation on its modifier plays on
   every open with no JavaScript involvement. */
@keyframes printeez-consent-panel-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.printeez-consent {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 100000;
  display: flex;
  justify-content: center;
  padding:0;
  padding-bottom: calc(env(safe-area-inset-bottom));
  pointer-events: none;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

.printeez-consent__panel {
  pointer-events: auto;
  width: 100%;
  max-width: 61rem;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #fff;
  color: #141414;
  /* Pinned so the theme's body font size cannot scale the panel: every size
     below is in rem and the app renders at this base. */
  font-size: 1rem;
  line-height: 1.5;
  border: 1px solid #d8d8d8;
  border-radius: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

/* First layer only: a single compact row on desktop, copy left and the
   actions right. The preferences panel keeps the column layout above. */
@media (min-width: 820px) {
  .printeez-consent__panel--banner {
    flex-direction: row;
    align-items: end;
    gap: 2rem;
    padding: 0.875rem 1.5rem;
  }

  .printeez-consent__panel--banner .printeez-consent__actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
}

.printeez-consent__panel--preferences {
  animation: printeez-consent-panel-in 0.2s ease-out;
}

.printeez-consent__copy {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

.printeez-consent__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: inherit;
}

/* Preferences header: title left, the X close control right. */
.printeez-consent__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.printeez-consent__close {
  display: inline-flex;
  flex-shrink: 0;
  padding: 0.25rem;
  margin: -0.25rem -0.25rem 0 0;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: #6b6b6b;
  cursor: pointer;
}

.printeez-consent__close:hover {
  color: #141414;
}

.printeez-consent__close:focus-visible {
  outline: 2px solid #141414;
  outline-offset: 2px;
}

.printeez-consent__close svg {
  width: 1.25rem;
  height: 1.25rem;
}

.printeez-consent__body,
.printeez-consent__purpose-description,
.printeez-consent__footnote {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #4a4a4a;
}

.printeez-consent__purpose-basis {
  display: block;
  font-size: 0.8rem;
  color: #6b6b6b;
}

.printeez-consent__error {
  margin: 0;
  font-size: 0.875rem;
  color: #b42318;
}

.printeez-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Identical geometry and colour for every action: all filled, none
   privileged. Mirrors `.privacy-consent-shell__button` in app.scss — keep in
   sync. */
.printeez-consent__button {
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: #141414;
  border: 1px solid #141414;
  border-radius: 0.375rem;
  cursor: pointer;
}

.printeez-consent__button:focus-visible {
  outline: 2px solid #141414;
  outline-offset: 2px;
}

.printeez-consent__purpose {
  border: 1px solid #e6e6e6;
  border-radius: 0;
  padding: 0.75rem;
  transition: border-color 0.15s, background-color 0.15s;
}

/* The row follows its switch: emerald border and a pale fill while the
   purpose is on. The "Always on" row has no switch and is permanently on, so
   it always wears the same state. Mirrors `.privacy-consent-shell__purpose`
   in app.scss — keep in sync. */
.printeez-consent__purpose:has(.printeez-consent__switch-input:checked),
.printeez-consent__purpose--necessary {
  border-color: #10b981;
  background: rgba(236, 253, 245, 0.5);
}

/* Text on the left, the switch on the right. */
.printeez-consent__purpose-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

/* The app's switch_checkbox look (helpers/checkbox_helper.ex): a visually
   hidden input, a `line` track, and a `dot` knob that slides when checked.
   Plain-CSS duplicate of the `.switch-input` rules in app.scss — keep in
   sync: 40×24 track, 16px knob, green when on. */
.printeez-consent__switch {
  position: relative;
  display: block;
  flex-shrink: 0;
}

.printeez-consent__switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.printeez-consent__switch-line {
  display: block;
  width: 2.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #b9b9b9;
  transition: background-color 0.15s;
}

.printeez-consent__switch-dot {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: #fff;
  transition: transform 0.15s;
}

.printeez-consent__switch-input:checked ~ .printeez-consent__switch-line {
  background: #22c55e;
}

.printeez-consent__switch-input:checked ~ .printeez-consent__switch-dot {
  transform: translateX(100%);
}

.printeez-consent__switch-input:focus-visible ~ .printeez-consent__switch-line {
  outline: 2px solid #141414;
  outline-offset: 2px;
}

.printeez-consent__switch-input:disabled ~ .printeez-consent__switch-line,
.printeez-consent__switch-input:disabled ~ .printeez-consent__switch-dot {
  opacity: 0.5;
}

.printeez-consent__purpose-name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
}

/* Inline in the body paragraph, so it inherits the body's size. */
.printeez-consent__link {
  color: #333;
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  .printeez-consent__panel {
    background: #1b1b1b;
    color: #f2f2f2;
    border-color: #3a3a3a;
  }

  .printeez-consent__body,
  .printeez-consent__purpose-description,
  .printeez-consent__footnote {
    color: #c9c9c9;
  }

  .printeez-consent__button {
    color: #141414 !important;
    background: #f2f2f2 !important;
    border-color: #f2f2f2 !important;
  }

  .printeez-consent__button:hover {
    background: #e5e5e5 !important;
  }

  .printeez-consent__button:focus-visible {
    outline-color: #f2f2f2;
  }

  .printeez-consent__link {
    color: #d8d8d8;
  }

  .printeez-consent__close {
    color: #c9c9c9;
  }

  .printeez-consent__close:hover {
    color: #f2f2f2;
  }

  .printeez-consent__close:focus-visible {
    outline-color: #f2f2f2;
  }

  .printeez-consent__purpose:has(.printeez-consent__switch-input:checked),
  .printeez-consent__purpose--necessary {
    border-color: #047857;
    background: rgba(6, 78, 59, 0.3);
  }

  .printeez-consent__switch-line {
    background: #4a4a4a;
  }

  .printeez-consent__switch-input:checked ~ .printeez-consent__switch-line {
    background: #22c55e;
  }

  .printeez-consent__switch-input:focus-visible ~ .printeez-consent__switch-line {
    outline-color: #f2f2f2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .printeez-consent__panel {
    animation: none;
  }

  .printeez-consent__switch-line,
  .printeez-consent__switch-dot {
    transition: none;
  }

  .printeez-consent__panel {
    transition: none;
  }
}
