/* Display settings: the header button, the panel, and the five page-wide
   adjustments it turns on. Token names come from the V6 weave tokens
   (--ink, --slate, --muted, --line, --violet, --lavender-2 ...); every one
   has a fallback so the file also works on a page that lacks them.

   The adjustments are attribute selectors on <html> set by
   display-settings-boot.js before first paint:
     data-ds-size      text size (CSS zoom on body; value in --ds-zoom)
     data-ds-spacing   WCAG 1.4.12 text spacing
     data-ds-contrast  darker text and borders
     data-ds-motion    no animation or transition
     data-ds-links     underlined links in running text */

/* ---------- header button ---------- */
.ds-open {
  min-width: 44px;
  min-height: 44px;
  padding: 0 .75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid var(--line, #dedee8);
  border-radius: var(--radius-md, 16px);
  color: var(--purple-900, #2b235e);
  background: var(--surface, #fff);
  font-family: var(--font-display, "Montserrat", Arial, sans-serif);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}
.ds-open:hover { border-color: var(--violet, #6f5bd3); background: var(--lavender-2, #f3f1fc); }
.ds-open:focus-visible { outline: 0; box-shadow: var(--alex-focus-ring, 0 0 0 4px rgba(111, 91, 211, .25)); }
.ds-sr, .ds-open .ds-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
@media (max-width: 480px) {
  .ds-open { padding: 0; width: 44px; }
  .ds-open__label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- panel ---------- */
.ds-panel {
  position: fixed;
  z-index: 250;
  inset: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) auto auto;
  width: min(380px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  margin: 0;
  padding: 0;
  border: 1px solid var(--line, #dedee8);
  border-radius: var(--radius-lg, 22px);
  color: var(--ink, #202034);
  background: var(--paper, #fffdf9);
  box-shadow: var(--alex-shadow-raised, 0 18px 50px rgba(32, 32, 52, .18));
  overflow: hidden auto;
}
.ds-panel::backdrop { background: rgba(32, 32, 52, .28); }
.ds-panel__inner { padding: 1.15rem 1.2rem 1.3rem; }
.ds-panel__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: .7rem; }
.ds-panel__mark { width: 34px; height: 34px; display: grid; place-items: center; color: var(--alex-purple, #413494); }
.ds-panel__head h2 { margin: 0; font-family: var(--font-display, Arial, sans-serif); font-size: 1.12rem; font-weight: 800; }
.ds-panel__head p { margin: .15rem 0 0; color: var(--slate, #495965); font-size: .85rem; }
.ds-panel__close {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--line, #dedee8); border-radius: var(--radius-sm, 12px);
  color: var(--slate, #495965); background: var(--surface, #fff); cursor: pointer;
}
.ds-panel__close:hover { border-color: var(--violet, #6f5bd3); }
.ds-panel__close:focus-visible, .ds-reset:focus-visible { outline: 0; box-shadow: var(--alex-focus-ring, 0 0 0 4px rgba(111, 91, 211, .25)); }

.ds-form { margin-top: 1rem; }
.ds-size { margin: 0; padding: 0; border: 0; }
.ds-size legend, .ds-toggle b {
  font-family: var(--font-display, Arial, sans-serif); font-weight: 800; font-size: .9rem; color: var(--ink, #202034);
}
.ds-size legend { margin-bottom: .45rem; padding: 0; }
.ds-size__options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.ds-size__options label {
  min-height: 48px; display: flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .35rem .4rem; border: 1px solid var(--line-strong, #c9c8d5); border-radius: var(--radius-sm, 12px);
  background: var(--surface, #fff); cursor: pointer; text-align: center;
  font-family: var(--font-display, Arial, sans-serif); font-weight: 700; font-size: .85rem;
}
.ds-size__options label:has(input:checked) { border-color: var(--alex-purple, #413494); background: var(--lavender-2, #f3f1fc); box-shadow: inset 0 0 0 1px var(--alex-purple, #413494); }
.ds-size__options label:has(input:focus-visible) { box-shadow: var(--alex-focus-ring, 0 0 0 4px rgba(111, 91, 211, .25)); }
.ds-size__options input { margin: 0; accent-color: var(--alex-purple, #413494); }
.ds-size__a1 { font-size: 1.06rem; }
.ds-size__a2 { font-size: 1.16rem; }
.ds-status { margin: .5rem 0 0; min-height: 1.3em; color: var(--slate, #495965); font-size: .82rem; }

.ds-toggles { margin-top: 1rem; display: grid; gap: .4rem; }
.ds-toggle {
  min-height: 48px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .65rem;
  padding: .55rem .7rem; border: 1px solid var(--line, #dedee8); border-radius: var(--radius-sm, 12px);
  background: var(--surface, #fff); cursor: pointer;
}
.ds-toggle:has(input:checked) { border-color: var(--alex-purple, #413494); background: var(--lavender-2, #f3f1fc); }
.ds-toggle:has(input:focus-visible) { box-shadow: var(--alex-focus-ring, 0 0 0 4px rgba(111, 91, 211, .25)); }
.ds-toggle input { width: 20px; height: 20px; margin: 0; accent-color: var(--alex-purple, #413494); }
.ds-toggle span { display: grid; gap: .1rem; }
.ds-toggle small { color: var(--slate, #495965); font-size: .8rem; line-height: 1.35; }

.ds-panel__foot { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line, #dedee8); }
.ds-reset {
  min-height: 44px; padding: 0 1rem; border: 1px solid var(--line-strong, #c9c8d5); border-radius: var(--radius-pill, 999px);
  color: var(--purple-900, #2b235e); background: var(--surface, #fff); cursor: pointer;
  font-family: var(--font-display, Arial, sans-serif); font-weight: 700; font-size: .85rem;
}
.ds-reset:hover { border-color: var(--violet, #6f5bd3); }
.ds-panel__foot p { margin: .6rem 0 0; color: var(--slate, #495965); font-size: .8rem; line-height: 1.45; }

@media (max-width: 560px) {
  .ds-panel {
    inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: 88vh;
    border-radius: var(--radius-lg, 22px) var(--radius-lg, 22px) 0 0;
  }
}
@media print { .ds-open, .ds-panel { display: none !important; } }

/* ---------- 1. text size ---------- */
html[data-ds-size] body { zoom: var(--ds-zoom, 1); }
/* Maps measure the pointer against unzoomed coordinates; keep them at 1:1 so
   a click lands where it looks like it lands. */
html[data-ds-size] .leaflet-container { zoom: calc(1 / var(--ds-zoom, 1)); }
@media print { html[data-ds-size] body { zoom: 1; } }

/* ---------- 2. text spacing (WCAG 1.4.12 values) ---------- */
html[data-ds-spacing] body :is(p, li, dt, dd, td, th, label, legend, summary, blockquote, figcaption,
  h1, h2, h3, h4, h5, h6, a, span, small, b, strong, em, button, input, textarea, select) {
  line-height: 1.5 !important;
  letter-spacing: .12em !important;
  word-spacing: .16em !important;
}
html[data-ds-spacing] body p { margin-bottom: 2em !important; }

/* ---------- 3. higher contrast ---------- */
html[data-ds-contrast] {
  --ink: #0f0f1a;
  --charcoal: #1d252b;
  --slate: #2b353d;
  --muted: #333c44;
  --subtle: #3e4750;
  --line: #85849a;
  --line-strong: #5f5e74;
  --alex-border-subtle: rgba(32, 32, 52, .5);
}
html[data-ds-contrast] body { color: var(--ink); }
/* Faded labels set with an inline opacity are dimmed text; show them in full. */
html[data-ds-contrast] body [style*="opacity:."],
html[data-ds-contrast] body [style*="opacity: ."] { opacity: 1 !important; }
html[data-ds-contrast] body :is(p, li, td, dd, small, .fine, .hint) { text-shadow: none !important; }

/* ---------- 4. pause motion ---------- */
html[data-ds-motion] *, html[data-ds-motion] *::before, html[data-ds-motion] *::after {
  animation-duration: 0s !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}
html[data-ds-motion] { scroll-behavior: auto !important; }
html[data-ds-motion] .alex-hero__copy > * { opacity: 1 !important; transform: none !important; }

/* ---------- 5. underline links ---------- */
/* Links styled as buttons already read as controls; leave them alone. */
html[data-ds-links] body :is(p, li, td, dd, dt, small, figcaption, blockquote, .fine, label)
  a:not([class*="btn"]):not([class*="button"]):not([role="button"]),
html[data-ds-links] .site-footer a {
  text-decoration: underline !important;
  text-decoration-thickness: max(1px, .08em);
  text-underline-offset: .18em;
}
