/* Built-in accessibility — focus, contrast, motion, visitor panel (BCBCS pattern) */

/* Screen-reader-only text */
.gl-a11y-sr-only,
.gl-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Visible keyboard focus (WCAG 2.4.7) */
:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}
.gl-console-sidebar :focus-visible {
  outline-color: #fbbf24;
}
html[data-a11y-contrast="high"] :focus-visible {
  outline-width: 4px;
  outline-color: #ffff00;
}

/* Flash messages — not color-only */
.gl-flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  max-width: 52rem;
}
.gl-flash-ok,
p.gl-flash-ok {
  color: #0a6629;
  background: #e6f4ea;
  border: 1px solid #86c99a;
}
.gl-flash-err,
p.gl-flash-err {
  color: #8b0000;
  background: #ffebee;
  border: 1px solid #e57373;
}
html[data-a11y-contrast="high"] .gl-flash-ok,
html[data-a11y-contrast="high"] p.gl-flash-ok {
  color: #000;
  background: #fff;
  border: 3px solid #000;
}
html[data-a11y-contrast="high"] .gl-flash-err,
html[data-a11y-contrast="high"] p.gl-flash-err {
  color: #fff;
  background: #000;
  border: 3px solid #fff;
}

/* ─── Visitor panel UI (GenerateLetters navy / gold) ─── */
.gl-a11y-trigger {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10050;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--gl-navy, #0f2444);
  background: linear-gradient(145deg, #f4f6f9 0%, #ffffff 45%, #e8eef5 100%);
  border: 2px solid var(--gl-navy, #0f2444);
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(15, 36, 68, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: pointer;
  line-height: 0;
}

.gl-a11y-trigger-icon {
  width: 1.65rem;
  height: 1.65rem;
  flex-shrink: 0;
}

.gl-a11y-trigger:hover {
  border-color: var(--gl-navy-light, #1a365d);
  box-shadow: 0 6px 20px rgba(15, 36, 68, 0.22);
}

.gl-a11y-trigger:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.85), 0 4px 16px rgba(15, 36, 68, 0.18);
}

.gl-a11y-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.85), 0 4px 16px rgba(15, 36, 68, 0.18);
}

.gl-a11y-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10051;
  background: rgba(15, 36, 68, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.gl-a11y-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.gl-a11y-dialog {
  position: fixed;
  right: 1rem;
  bottom: 4.25rem;
  z-index: 10052;
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(85vh, 28rem);
  overflow: auto;
  padding: 1.15rem 1.25rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--gl-text, #1c2b42);
  background: #f4f6f9;
  border: 2px solid var(--gl-navy-light, #1a365d);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 36, 68, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
}

.gl-a11y-dialog.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.gl-a11y-dialog h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gl-navy, #0f2444);
}

.gl-a11y-dialog .gl-a11y-lede {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--gl-muted, #5a6a80);
}

.gl-a11y-lede-note {
  margin-top: 0.5rem !important;
  margin-bottom: 0 !important;
}

.gl-a11y-field {
  margin-bottom: 1rem;
  border: none;
  padding: 0;
}

.gl-a11y-field legend {
  font-weight: 600;
  font-size: 0.8125rem;
  color: #334155;
  margin-bottom: 0.35rem;
}

.gl-a11y-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.gl-a11y-seg label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: #ffffff;
  border: 1px solid var(--gl-border, #d8dee8);
  border-radius: 8px;
  cursor: pointer;
}

.gl-a11y-seg label:has(input:checked) {
  border-color: var(--gl-navy, #0f2444);
  background: #e8eef5;
  color: var(--gl-navy, #0f2444);
}

.gl-a11y-seg input {
  accent-color: var(--gl-navy, #0f2444);
}

.gl-a11y-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--gl-border, #d8dee8);
}

.gl-a11y-toggle-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.gl-a11y-toggle-row span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gl-text, #1c2b42);
}

.gl-a11y-toggle-row small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gl-muted, #5a6a80);
  margin-top: 0.15rem;
}

.gl-a11y-switch {
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 999px;
  border: 2px solid var(--gl-navy, #0f2444);
  background: #ffffff;
  position: relative;
  cursor: pointer;
  padding: 0;
}

.gl-a11y-switch[aria-checked="true"] {
  background: var(--gl-navy, #0f2444);
}

.gl-a11y-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--gl-gold, #c9a84c);
  transition: transform 0.15s ease;
}

.gl-a11y-switch[aria-checked="true"]::after {
  transform: translateX(1.2rem);
  background: #f5e6b8;
}

.gl-a11y-switch:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.65);
}

.gl-a11y-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.gl-a11y-actions button {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
}

.gl-a11y-btn-close {
  background: #ffffff;
  border-color: var(--gl-border, #d8dee8);
  color: #334155;
}

.gl-a11y-btn-close:hover {
  border-color: var(--gl-navy, #0f2444);
  color: var(--gl-navy, #0f2444);
}

.gl-a11y-btn-reset {
  background: linear-gradient(90deg, var(--gl-gold, #c9a84c), #e8c96a);
  color: var(--gl-navy, #0f2444);
  border-color: #a88a3a;
}

.gl-a11y-btn-reset:hover {
  filter: brightness(1.03);
}

/* ─── Page effects (html data-a11y-* attributes) ─── */
html[data-a11y-text="1"] {
  font-size: 110%;
}

html[data-a11y-text="2"] {
  font-size: 125%;
}

html[data-a11y-contrast="high"] {
  --gl-a11y-body: #0a0a0a;
  --gl-a11y-link: #0f2444;
  --gl-a11y-muted: #3f3f46;
}

html[data-a11y-contrast="high"] body {
  color: var(--gl-a11y-body, #0a0a0a);
}

html[data-a11y-contrast="high"] a:not(.gl-a11y-trigger):not(.gl-a11y-switch):not(.gl-a11y-actions button):not(.gl-btn) {
  color: var(--gl-a11y-link, #0f2444);
  text-decoration-thickness: 2px;
}

html[data-a11y-contrast="high"] body.gl-console-body {
  --gl-bg: #fff;
  --gl-text: #000;
  --gl-muted: #222;
  --gl-border: #000;
  background: #fff;
  color: #000;
}

html[data-a11y-contrast="high"] .gl-console-sidebar {
  background: #000;
  color: #fff;
  border-right: 4px solid #fff;
}

html[data-a11y-contrast="high"] .gl-console-nav a,
html[data-a11y-contrast="high"] .gl-console-nav-summary {
  color: #fff;
}

html[data-a11y-contrast="high"] .gl-console-nav a.is-active,
html[data-a11y-contrast="high"] .gl-console-nav-summary.is-active {
  background: #fff;
  color: #000;
  font-weight: 700;
}

html[data-a11y-contrast="high"] .gl-console-kpi,
html[data-a11y-contrast="high"] .gl-console-panel,
html[data-a11y-contrast="high"] table.gl-table,
html[data-a11y-contrast="high"] .gl-form-card,
html[data-a11y-contrast="high"] .gl-help-box {
  border: 2px solid #000 !important;
  background: #fff !important;
  color: #000 !important;
}

html[data-a11y-contrast="high"] .gl-btn-primary {
  background: #000 !important;
  color: #fff !important;
  border: 2px solid #000 !important;
}

html[data-a11y-contrast="high"] .gl-a11y-trigger {
  background: #fff !important;
  color: #000 !important;
  border: 3px solid #000;
}

html[data-a11y-contrast="high"] .gl-a11y-dialog {
  border: 3px solid #000;
  background: #fff;
  color: #000;
}

html[data-a11y-motion="reduced"] {
  scroll-behavior: auto !important;
}

html[data-a11y-motion="reduced"] *,
html[data-a11y-motion="reduced"] *::before,
html[data-a11y-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

html[data-a11y-motion="reduced"] .gl-a11y-backdrop,
html[data-a11y-motion="reduced"] .gl-a11y-dialog,
html[data-a11y-motion="reduced"] .gl-a11y-switch::after {
  transition: none !important;
}

html[data-a11y-links="underline"] a:not(.gl-btn):not(.gl-a11y-trigger):not(.gl-a11y-switch) {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

html[data-a11y-spacing="readable"] body {
  line-height: 1.75 !important;
}

html[data-a11y-spacing="readable"] p,
html[data-a11y-spacing="readable"] li {
  margin-bottom: 0.85em;
}

@media (prefers-reduced-motion: reduce) {
  .gl-a11y-backdrop,
  .gl-a11y-dialog,
  .gl-a11y-switch::after {
    transition: none;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Minimum touch / click target (~44px) for controls */
.gl-btn,
.gl-console-nav a,
button:not(.gl-a11y-trigger):not(.gl-a11y-switch),
input[type="submit"],
input[type="button"] {
  min-height: 2.75rem;
}
table.gl-table a.gl-btn-sm,
.gl-btn-sm {
  min-height: 2.25rem;
}

@media (max-width: 480px) {
  .gl-a11y-trigger {
    right: 0.75rem;
    bottom: 0.75rem;
    width: 3rem;
    height: 3rem;
  }
  .gl-a11y-dialog {
    right: 0.75rem;
    bottom: 3.85rem;
    width: calc(100vw - 1.5rem);
  }
}

/* Main landmark */
main.gl-console-main-inner:focus {
  outline: none;
}
main.gl-console-main-inner {
  display: block;
  min-width: 0;
}

.gl-help-box,
.gl-zone-help {
  line-height: 1.55;
}

table.gl-table th {
  font-weight: 700;
}

.gl-req {
  font-weight: 700;
}

iframe.gl-parse-verify-frame {
  border: 2px solid var(--gl-border);
}

/* Client portal */
html[data-a11y-contrast="high"] .gl-portal-header {
  border-bottom: 3px solid #000;
}
html[data-a11y-contrast="high"] .gl-portal-main {
  color: #000;
}
