/*
 * Accessibility menu, integrated from the existing implementation (button, panel, reading guide, light contrast,
 * grayscale, highlighted links, stop motion, text size / letter spacing / line height), restyled with CashBot's
 * tokens. The class names and behaviour are the original ones; only colors, position and sizing are CashBot's.
 */
:root { --font-scale: 100%; --letter-space: 0px; --line-height: 1.35; }

/* text settings - CashBot uses pixel sizes, so the text size is applied as zoom on the content areas */
.main, .legal-page, .auth, .modal, .top, .side { zoom: var(--font-scale); }
body { letter-spacing: var(--letter-space); }
.main, .legal-page, .auth, .modal, .side { line-height: var(--line-height); }

#a11y-button {
  position: fixed;
  inset-inline-start: 16px;
  bottom: 16px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface-2);
  color: var(--accent);
  z-index: 9999;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: a11yBounce 3.5s infinite;
}
body:has(.layout) #a11y-button, body:has(.layout) #a11y-panel { inset-inline-start: calc(var(--side, 264px) + 16px); }
#a11y-button:hover { background: var(--accent); color: var(--accent-ink); }
#a11y-button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
#a11y-button svg { width: 24px; height: 24px; }

@keyframes a11yBounce {
  0%, 72%, 100% { transform: translateY(0); }
  78% { transform: translateY(-7px); }
  88% { transform: translateY(-4px); }
}

#a11y-panel {
  position: fixed;
  inset-inline-start: 16px;
  bottom: 74px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  display: none;
  z-index: 9998;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
  padding: 16px;
}
#a11y-panel.open { display: block; animation: a11yIn .18s ease both; }
@keyframes a11yIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.a11y-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-weight: 700;
  margin-bottom: 12px;
}
.a11y-title > span { font-size: 18px !important; }
.a11y-statement { color: var(--accent); font-size: 13px !important; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.a11y-btn, .a11y-big {
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 5px;
  padding: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.a11y-big { width: 100%; margin-bottom: 4px; }
.a11y-btn:hover, .a11y-big:hover { border-color: var(--accent); }
.a11y-active { background: var(--accent) !important; color: var(--accent-ink) !important; border-color: var(--accent) !important; }
.a11y-btn:focus-visible, .a11y-big:focus-visible, .a11y-range:focus-visible, .a11y-statement:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.a11y-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.a11y-label { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.a11y-range { width: 100%; accent-color: var(--accent); }

/* the panel keeps a fixed, readable size whatever the page settings are */
#a11y-panel, #a11y-panel * { font-size: 15px; line-height: 1.35 !important; letter-spacing: 0 !important; }
#a11y-panel, #a11y-button { zoom: 1; }

#reading-guide {
  position: fixed;
  left: 0;
  width: 100%;
  height: 4px;
  top: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  z-index: 9997;
  display: none;
  pointer-events: none;
}
body.reading-guide-on #reading-guide { display: block; }

/* light contrast: CashBot's colors swapped for a light, high-contrast set */
body.contrast-light {
  --bg: #ffffff; --bg-2: #f4f5f2; --surface: #ffffff; --surface-2: #eef0eb; --row-hover: #e6e9e2;
  --border: #6b7065; --border-2: #3d4138;
  --text: #000000; --muted: #1f221c; --faint: #3a3e35;
  --accent: #1d6b00; --accent-ink: #ffffff; --accent-soft: rgba(29, 107, 0, .12);
  --warn: #7a4a00; --bad: #a3001b; --info: #1f3fb0; --violet: #4b33b8; --live: #a3001b;
  background: #fff !important;
  color: #000 !important;
}
body.contrast-light .side, body.contrast-light .top { background: #f4f5f2 !important; border-color: #3d4138 !important; }
body.contrast-light .platform-indicator { background: #fff; color: #000; border-color: #3d4138; }
body.contrast-light .notice.info { background: #f4f5f2; color: #000; border-color: #3d4138; }
body.contrast-light .tr:hover:not(.th) { background: #e6e9e2; }
body.contrast-light .hint, body.contrast-light .muted, body.contrast-light .policy-box p, body.contrast-light .policy-box li { color: #111 !important; }
body.contrast-light .preview-frame, body.contrast-light .canvas-wrap { background-color: #d9dcd5; }

/* grayscale on <html> so fixed elements (the menu, dialogs) keep their position */
html:has(body.grayscale) { filter: grayscale(1); }
body.underline-links a { text-decoration: underline !important; text-underline-offset: 5px; }
body.underline-links a:not(.btn) { outline: 1px dashed currentColor; outline-offset: 2px; }

body.pause-motion *,
body.pause-motion *::before,
body.pause-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
body.pause-motion #a11y-button { transform: none !important; }

@media (prefers-reduced-motion: reduce) { #a11y-button, #a11y-panel.open { animation: none; } }

@media (max-width: 820px) {
  body:has(.layout) #a11y-button, #a11y-button {
    inset-inline-start: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
  }
  body:has(.layout) #a11y-panel, #a11y-panel {
    inset-inline-start: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    width: min(360px, calc(100vw - 24px));
  }
}
@media print { #a11y-button, #a11y-panel, #reading-guide { display: none !important; } }
