/* =====================================================
   RB Accessibility Toolbar — WCAG 2.1 helper modes
   ===================================================== */

/* ---------- Skip to content link ---------- */
.rb-a11y-skip-link {
    position: absolute !important;
    top: -100px;
    left: 16px;
    z-index: 999999;
    padding: 12px 24px;
    background: var(--rb-dark, #1F1B16);
    color: var(--rb-accent, #F2B137) !important;
    font-family: var(--rb-font-heading, sans-serif);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    border-radius: 0 0 8px 8px;
    transition: top 0.2s ease-out;
    outline: none;
    border: 2px solid var(--rb-accent, #F2B137);
}

.rb-a11y-skip-link:focus,
.rb-a11y-skip-link:focus-visible {
    top: 0;
    outline: 2px solid var(--rb-accent, #F2B137);
    outline-offset: 2px;
}

/* ---------- Toolbar wrapper ---------- */
.rb-a11y {
    position: fixed;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --rb-a11y-primary: #A47B52;
    --rb-a11y-accent:  #F2B137;
    --rb-a11y-dark:    #1F1B16;
    --rb-a11y-light:   #FFFFFF;
}

.rb-a11y--bottom-right { bottom: 24px; right: 24px; }
.rb-a11y--bottom-left  { bottom: 24px; left:  24px; }
.rb-a11y--top-right    { top: 24px;    right: 24px; }
.rb-a11y--top-left     { top: 24px;    left:  24px; }

/* ---------- Trigger button ---------- */
.rb-a11y__trigger {
    width: 56px !important;
    height: 56px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: var(--rb-a11y-primary) !important;
    color: var(--rb-a11y-light) !important;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(31, 27, 22, 0.25) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: none !important;
}

.rb-a11y__trigger:hover,
.rb-a11y__trigger:focus,
.rb-a11y__trigger:focus-visible {
    background: var(--rb-a11y-accent) !important;
    color: var(--rb-a11y-dark) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 12px 28px rgba(242, 177, 55, 0.4) !important;
    outline: 3px solid rgba(255, 255, 255, 0.4) !important;
    outline-offset: 2px !important;
}

.rb-a11y__trigger svg {
    width: 26px !important;
    height: 26px !important;
    fill: currentColor !important;
}

/* ---------- Panel ---------- */
.rb-a11y__panel {
    position: absolute;
    width: 320px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    background: var(--rb-a11y-light);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(31, 27, 22, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    color: var(--rb-a11y-dark);
}

.rb-a11y--bottom-right .rb-a11y__panel { bottom: 72px; right: 0; transform-origin: bottom right; }
.rb-a11y--bottom-left  .rb-a11y__panel { bottom: 72px; left: 0;  transform-origin: bottom left; }
.rb-a11y--top-right    .rb-a11y__panel { top: 72px;    right: 0; transform-origin: top right; }
.rb-a11y--top-left     .rb-a11y__panel { top: 72px;    left: 0;  transform-origin: top left; }

.rb-a11y.is-open .rb-a11y__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.rb-a11y__panel[hidden] { display: flex !important; }

/* ---------- Header ---------- */
.rb-a11y__header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--rb-a11y-primary), var(--rb-a11y-dark));
    color: var(--rb-a11y-light);
}

.rb-a11y__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--rb-a11y-light);
}

.rb-a11y__close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
    border-radius: 50% !important;
    color: var(--rb-a11y-light) !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    transition: background 0.2s ease;
    outline: none !important;
}

.rb-a11y__close:hover,
.rb-a11y__close:focus {
    background: rgba(255, 255, 255, 0.3) !important;
    outline: none !important;
}

.rb-a11y__close svg {
    width: 16px;
    height: 16px;
}

/* ---------- Body ---------- */
.rb-a11y__body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.rb-a11y__group {
    margin-bottom: 20px;
}

.rb-a11y__group-title {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #6B6155;
}

.rb-a11y__row {
    display: flex;
    gap: 8px;
}

.rb-a11y__row .rb-a11y__btn {
    flex: 1;
}

.rb-a11y__btn {
    padding: 14px 12px !important;
    background: #F5EFE6 !important;
    border: 2px solid transparent !important;
    border-radius: 10px !important;
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--rb-a11y-dark) !important;
    cursor: pointer;
    transition: all 0.15s ease !important;
    outline: none !important;
}

.rb-a11y__btn:hover,
.rb-a11y__btn:focus {
    background: var(--rb-a11y-accent) !important;
    color: var(--rb-a11y-dark) !important;
    transform: translateY(-1px);
    outline: none !important;
}

.rb-a11y__btn--reset {
    background: var(--rb-a11y-dark) !important;
    color: var(--rb-a11y-light) !important;
}

.rb-a11y__btn--reset:hover,
.rb-a11y__btn--reset:focus {
    background: var(--rb-a11y-primary) !important;
    color: var(--rb-a11y-light) !important;
}

/* ---------- Mode grid ---------- */
.rb-a11y__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rb-a11y__mode {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px !important;
    background: #F5EFE6 !important;
    border: 2px solid transparent !important;
    border-radius: 10px !important;
    color: var(--rb-a11y-dark) !important;
    cursor: pointer;
    transition: all 0.15s ease !important;
    outline: none !important;
    font-family: inherit !important;
}

.rb-a11y__mode:hover,
.rb-a11y__mode:focus {
    background: #ECE0D0 !important;
    border-color: var(--rb-a11y-primary) !important;
    outline: none !important;
}

.rb-a11y__mode[aria-pressed="true"] {
    background: var(--rb-a11y-accent) !important;
    border-color: var(--rb-a11y-primary) !important;
}

.rb-a11y__mode-icon {
    width: 22px;
    height: 22px;
    color: var(--rb-a11y-primary);
}

.rb-a11y__mode[aria-pressed="true"] .rb-a11y__mode-icon {
    color: var(--rb-a11y-dark);
}

.rb-a11y__mode-label {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

/* ---------- Reset all ---------- */
.rb-a11y__reset {
    width: 100%;
    margin-top: 12px;
    padding: 12px 16px !important;
    background: transparent !important;
    border: 2px solid var(--rb-a11y-primary) !important;
    border-radius: 10px !important;
    color: var(--rb-a11y-primary) !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease !important;
    outline: none !important;
}

.rb-a11y__reset:hover,
.rb-a11y__reset:focus {
    background: var(--rb-a11y-primary) !important;
    color: var(--rb-a11y-light) !important;
    outline: none !important;
}

.rb-a11y__reset svg {
    width: 16px;
    height: 16px;
}

.rb-a11y__footer {
    margin: 16px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #6B6155;
    text-align: center;
}

/* ===========================================================
   ACCESSIBILITY MODES — applied to <html> via class
   =========================================================== */

/* Text size scaling */
html.rb-a11y-text-1 { font-size: 18px; }   /* +12.5% */
html.rb-a11y-text-2 { font-size: 20px; }   /* +25% */
html.rb-a11y-text-3 { font-size: 22px; }   /* +37.5% */
html.rb-a11y-text-4 { font-size: 24px; }   /* +50% */
html.rb-a11y-text-m1 { font-size: 14px; }  /* −12.5% */
html.rb-a11y-text-m2 { font-size: 12px; }  /* −25% */

/* High contrast — black background, yellow text, white links */
html.rb-a11y-contrast,
html.rb-a11y-contrast body {
    background: #000 !important;
    color: #FFFF00 !important;
}

html.rb-a11y-contrast * {
    background-color: #000 !important;
    color: #FFFF00 !important;
    border-color: #FFFF00 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

html.rb-a11y-contrast a,
html.rb-a11y-contrast a * {
    color: #00FFFF !important;
    text-decoration: underline !important;
}

html.rb-a11y-contrast button,
html.rb-a11y-contrast input,
html.rb-a11y-contrast textarea,
html.rb-a11y-contrast select {
    background: #000 !important;
    color: #FFFF00 !important;
    border: 2px solid #FFFF00 !important;
}

html.rb-a11y-contrast img,
html.rb-a11y-contrast video {
    filter: grayscale(0) contrast(1) !important;
}

/* Grayscale */
html.rb-a11y-grayscale,
html.rb-a11y-grayscale body {
    filter: grayscale(100%) !important;
}

/* Highlight links — force underlines + bold on every link */
html.rb-a11y-links a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
    font-weight: 600 !important;
}

/* Big cursor */
html.rb-a11y-big-cursor,
html.rb-a11y-big-cursor * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><polygon points='4,4 4,40 14,30 22,46 28,42 20,28 36,28' fill='%23F2B137' stroke='%231F1B16' stroke-width='2' stroke-linejoin='round'/></svg>") 4 4, auto !important;
}

html.rb-a11y-big-cursor a,
html.rb-a11y-big-cursor button,
html.rb-a11y-big-cursor [role="button"],
html.rb-a11y-big-cursor input[type="submit"],
html.rb-a11y-big-cursor input[type="button"] {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><path d='M16 4 C 16 2 18 2 18 4 V 22 H 22 V 6 C 22 4 24 4 24 6 V 22 H 28 V 8 C 28 6 30 6 30 8 V 22 H 34 V 12 C 34 10 36 10 36 12 V 30 C 36 38 30 44 24 44 H 22 C 16 44 12 40 8 32 L 6 28 C 5 26 7 24 9 25 L 14 28 V 12 C 14 10 16 10 16 12 V 4 Z' fill='%23F2B137' stroke='%231F1B16' stroke-width='2' stroke-linejoin='round'/></svg>") 16 4, pointer !important;
}

/* Pause animations */
html.rb-a11y-reduce-motion *,
html.rb-a11y-reduce-motion *::before,
html.rb-a11y-reduce-motion *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* Dyslexia-friendly font (uses widely-installed Atkinson Hyperlegible / Comic Sans fallback) */
html.rb-a11y-dyslexia,
html.rb-a11y-dyslexia body,
html.rb-a11y-dyslexia *:not([class*="rb-a11y"]):not([class*="rb-a11y"] *) {
    font-family: "Atkinson Hyperlegible", "OpenDyslexic", "Comic Sans MS", Verdana, Tahoma, sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.7 !important;
}

/* Reading guide — horizontal bar follows cursor (handled by JS) */
.rb-a11y-reading-guide-bar {
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(31, 27, 22, 0.85);
    pointer-events: none;
    z-index: 99997;
    display: none;
    box-shadow: 0 0 0 2000px rgba(31, 27, 22, 0.0);
}

html.rb-a11y-reading-guide .rb-a11y-reading-guide-bar {
    display: block;
}

/* Wider spacing — increase line-height + letter spacing for readability */
html.rb-a11y-spacing,
html.rb-a11y-spacing body,
html.rb-a11y-spacing p,
html.rb-a11y-spacing h1, html.rb-a11y-spacing h2, html.rb-a11y-spacing h3,
html.rb-a11y-spacing h4, html.rb-a11y-spacing h5, html.rb-a11y-spacing h6,
html.rb-a11y-spacing li, html.rb-a11y-spacing span, html.rb-a11y-spacing div {
    line-height: 1.8 !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 480px) {
    .rb-a11y--bottom-right,
    .rb-a11y--top-right { right: 16px; }
    .rb-a11y--bottom-left,
    .rb-a11y--top-left  { left:  16px; }
    .rb-a11y--bottom-right,
    .rb-a11y--bottom-left { bottom: 16px; }

    .rb-a11y__panel {
        width: calc(100vw - 32px);
    }

    .rb-a11y__trigger {
        width: 48px !important;
        height: 48px !important;
    }
    .rb-a11y__trigger svg { width: 22px !important; height: 22px !important; }
}

/* ---------- Focus visibility (site-wide upgrade) ---------- */
*:focus-visible {
    outline: 3px solid var(--rb-a11y-accent, #F2B137) !important;
    outline-offset: 2px !important;
}
