/**
 * Floating site preferences — FAB + left off-canvas.
 * v1.0.0
 */

.ae-prefs {
  --ae-p-red: #cc2229;
  --ae-p-black: #161616;
  --ae-p-grey: #f0f0f0;
  --ae-p-border: #e0e0e0;
  --ae-p-text: #222;
  --ae-p-muted: #666;
  --ae-p-width: min(22rem, calc(100vw - 1rem));
  --ae-p-fab: 3.25rem;
  z-index: 100050;
}

.ae-prefs__fab {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 100052;
  width: var(--ae-p-fab);
  height: var(--ae-p-fab);
  border: 0;
  border-radius: 12px;
  background: var(--ae-p-black);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.ae-prefs__fab:hover,
.ae-prefs__fab:focus-visible {
  background: var(--ae-p-red);
  outline: none;
  transform: translateY(-1px);
}

.ae-prefs__fab[aria-expanded="true"] {
  background: var(--ae-p-red);
}

.ae-prefs__fab-icon {
  display: flex;
  line-height: 0;
}

.ae-prefs__backdrop {
  position: fixed;
  inset: 0;
  z-index: 100051;
  background: rgba(22, 22, 22, 0.45);
  border: 0;
  padding: 0;
  cursor: pointer;
}

.ae-prefs__panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100053;
  width: var(--ae-p-width);
  height: 100%;
  max-height: 100dvh;
  background: #fff;
  color: var(--ae-p-text);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.28s ease;
  overflow: hidden;
}

.ae-prefs.is-open .ae-prefs__panel {
  transform: translateX(0);
}

.ae-prefs__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--ae-p-border);
  flex: 0 0 auto;
}

.ae-prefs__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ae-p-black);
}

.ae-prefs__close {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--ae-p-border);
  border-radius: 8px;
  background: var(--ae-p-grey);
  color: var(--ae-p-black);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.ae-prefs__close:hover,
.ae-prefs__close:focus-visible {
  border-color: var(--ae-p-red);
  color: var(--ae-p-red);
  outline: none;
}

.ae-prefs__tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.75rem 1rem 0;
  flex: 0 0 auto;
}

.ae-prefs__tab {
  min-height: 2.5rem;
  border: 1px solid var(--ae-p-border);
  border-radius: 8px;
  background: #fff;
  color: var(--ae-p-muted);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.45rem 0.5rem;
}

.ae-prefs__tab.is-active,
.ae-prefs__tab[aria-selected="true"] {
  background: var(--ae-p-black);
  border-color: var(--ae-p-black);
  color: #fff;
}

.ae-prefs__panels {
  flex: 1 1 auto;
  overflow: auto;
  padding: 1rem;
}

.ae-prefs__pane[hidden] {
  display: none !important;
}

.ae-prefs__lede {
  margin: 0 0 1rem;
  color: var(--ae-p-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.ae-prefs__lede a {
  color: var(--ae-p-red);
  font-weight: 700;
}

.ae-prefs__switch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  margin: 0 0 0.75rem;
  padding: 0.85rem 0.9rem;
  background: var(--ae-p-grey);
  border-radius: 12px;
  border: 1px solid #e6e6e6;
  cursor: pointer;
}

.ae-prefs__switch-copy {
  display: grid;
  gap: 0.2rem;
}

.ae-prefs__switch-copy strong {
  font-size: 0.95rem;
  color: var(--ae-p-black);
}

.ae-prefs__switch-copy span {
  font-size: 0.82rem;
  color: var(--ae-p-muted);
  line-height: 1.4;
}

.ae-prefs__switch input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--ae-p-red);
}

.ae-prefs__fieldset {
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.ae-prefs__fieldset legend {
  margin: 0 0 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ae-p-muted);
}

.ae-prefs__segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.ae-prefs__seg {
  min-height: 2.4rem;
  border: 1px solid var(--ae-p-border);
  border-radius: 8px;
  background: #fff;
  color: var(--ae-p-text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.ae-prefs__seg.is-active {
  background: var(--ae-p-black);
  border-color: var(--ae-p-black);
  color: #fff;
}

.ae-prefs__actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.15rem;
}

.ae-prefs__btn {
  min-height: 2.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  padding: 0.65rem 0.9rem;
}

.ae-prefs__btn--primary {
  background: var(--ae-p-red);
  color: #fff;
}

.ae-prefs__btn--primary:hover,
.ae-prefs__btn--primary:focus-visible {
  background: #b01c22;
  outline: none;
}

.ae-prefs__btn--ghost {
  background: #fff;
  border-color: var(--ae-p-border);
  color: var(--ae-p-black);
}

.ae-prefs__btn--ghost:hover,
.ae-prefs__btn--ghost:focus-visible {
  border-color: var(--ae-p-black);
  outline: none;
}

/* Applied accessibility modes on <html> */
html.ae-a11y-text-large {
  font-size: 112.5% !important;
}

html.ae-a11y-text-xlarge {
  font-size: 125% !important;
}

html.ae-a11y-contrast {
  filter: contrast(1.12);
}

html.ae-a11y-contrast body {
  background: #fff !important;
  color: #000 !important;
}

html.ae-a11y-underline a {
  text-decoration: underline !important;
  text-underline-offset: 0.15em;
}

html.ae-a11y-motion *,
html.ae-a11y-motion *::before,
html.ae-a11y-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

html.ae-a11y-readable,
html.ae-a11y-readable body {
  font-family: Verdana, "Segoe UI", Tahoma, sans-serif !important;
  letter-spacing: 0.02em;
  word-spacing: 0.04em;
  line-height: 1.65;
}

@media (max-width: 480px) {
  .ae-prefs__fab {
    left: 0.75rem;
    bottom: 0.75rem;
  }
}
