/*
 * bNagish - Modern Accessibility Framework (Ultimate Pro Version + Text-to-Speech)
 */

:root {
    --bn-primary: #0056b3;
    --bn-bg-dark: rgba(25, 25, 25, 0.95);
    --bn-text-light: #ffffff;
    --bn-hover-yellow: #ffeb3b;
    --bn-border-radius: 12px;
    --bn-transition: all 0.3s ease-in-out;
}

.bNagish * {
    box-sizing: border-box;
    font-family: inherit;
}
.bNagish .offset {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- Accessibility Modes --- */
.bNagish-mark-links a {
    text-decoration: underline !important;
    font-weight: bold;
    color: var(--bn-primary) !important;
}
.invert-contrast {
    filter: invert(1) hue-rotate(180deg);
    background: #000;
}
.gray-contrast {
    filter: grayscale(100%);
}
.high-dark-contrast * {
    background-color: #000 !important;
    color: #ffeb3b !important;
    border-color: #ffeb3b !important;
}

.bNagish-readable-font * {
    font-family: Arial, Helvetica, sans-serif !important;
}
.bNagish-text-spacing * {
    letter-spacing: 0.1em !important;
    word-spacing: 0.2em !important;
    line-height: 1.8 !important;
}
.bNagish-align-center * {
    text-align: center !important;
}
.bNagish-stop-animations * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
}
.bNagish-hide-images img,
.bNagish-hide-images svg,
.bNagish-hide-images [style*="background-image"] {
    visibility: hidden !important;
}
.bNagish-large-cursor * {
    cursor:
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24"><path d="M7 2l12 11.2-5.8.5 3.3 7.3-2.25.9-3.2-7.4-4.4 4.7z" fill="black" stroke="white" stroke-width="1.5"/></svg>'),
        auto !important;
}

/* Highlight Features */
.bNagish-highlight-headings h1,
.bNagish-highlight-headings h2,
.bNagish-highlight-headings h3,
.bNagish-highlight-headings h4,
.bNagish-highlight-headings h5,
.bNagish-highlight-headings h6 {
    border: 2px dashed var(--bn-primary) !important;
    padding: 2px !important;
}
.bNagish-hover-highlight *:hover {
    outline: 3px solid var(--bn-hover-yellow) !important;
    outline-offset: 2px !important;
}

/* Reading Guide Mask */
.bn-reading-guide-line {
    position: fixed;
    left: 0;
    width: 100vw;
    height: 15vh;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 4px solid var(--bn-hover-yellow);
    pointer-events: none;
    z-index: 99998;
    display: none;
    transform: translateY(-50%);
}
.bNagish-reading-guide-active .bn-reading-guide-line {
    display: block;
}

/* --- UI Elements --- */
.bNagish-toggle {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 60px;
    height: 60px;
    background: var(--bn-primary);
    color: var(--bn-text-light);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: var(--bn-transition);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bNagish[dir="rtl"] .bNagish-toggle {
    left: auto;
    right: 25px;
}
.bNagish[dir="ltr"] .bNagish-toggle {
    left: 25px;
    right: auto;
}
.bNagish-toggle:hover,
.bNagish-toggle:focus {
    transform: scale(1.1);
    background: var(--bn-hover-yellow);
    color: #000;
}
.bNagish.open .bNagish-toggle {
    display: none;
}
.bNagish-toggle em {
    font-size: 28px;
}
.bNagish-toggle .text {
    display: none;
}

.bNagish-bar {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 340px;
    max-height: 85vh;
    background: var(--bn-bg-dark);
    color: var(--bn-text-light);
    border-radius: var(--bn-border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 99999;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: var(--bn-transition);
    backdrop-filter: blur(10px);
}
.bNagish[dir="rtl"] .bNagish-bar {
    left: auto;
    right: 25px;
}
.bNagish[dir="ltr"] .bNagish-bar {
    left: 25px;
    right: auto;
}
.bNagish.open .bNagish-bar {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.bNagish-bar h2 {
    margin: 0 0 20px 0;
    font-size: 1.5em;
    text-align: center;
    border-bottom: 2px solid #444;
    padding-bottom: 10px;
}

.bNagish-settings {
    flex-grow: 1;
    overflow-y: auto;
    padding-left: 5px;
}
.bNagish[dir="rtl"] .bNagish-settings {
    padding-left: 0;
    padding-right: 5px;
}
.bNagish-settings::-webkit-scrollbar {
    width: 6px;
}
.bNagish-settings::-webkit-scrollbar-track {
    background: transparent;
}
.bNagish-settings::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 10px;
}

.bNagish-links-group {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}
.bNagish-links-group {
    flex-wrap: wrap;
}
.bNagish-links-group button,
.bNagish-links-group a {
    flex: 1;
    padding: 12px;
    background: #fff;
    color: #333;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: var(--bn-transition);
    font-size: 0.9em;
}
.bNagish-links-group a:hover,
.bNagish-links-group button:hover {
    background: var(--bn-hover-yellow);
    color: #000;
}
.bNagish .bn-reset-btn {
    background: #ffecb3 !important;
    color: #d35400 !important;
}
.bNagish .bn-reset-btn:hover {
    background: #e67e22 !important;
    color: #fff !important;
}

.bNagish-bar fieldset {
    border: none;
    padding: 0;
    margin: 0 0 20px 0;
}
.bNagish-bar legend {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #ddd;
}
.bNagish .options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    background: #333;
    padding: 5px;
    border-radius: 8px;
}
.bNagish .options > span {
    flex: 1 1 calc(33% - 5px);
}
.bNagish .options input[type="radio"],
.bNagish .options input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}
.bNagish .options label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 5px;
    background: #fff;
    color: #333;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85em;
    text-align: center;
    transition: var(--bn-transition);
    height: 100%;
}
.bNagish .options input:checked + label {
    background: var(--bn-primary);
    color: #fff;
    font-weight: bold;
}

.bNagish .checkboxes-group .options {
    flex-direction: column;
    background: transparent;
    padding: 0;
}
.bNagish .checkboxes-group .options label {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px;
}
.bNagish[dir="rtl"] .checkboxes-group .options label {
    text-align: right;
}
.bNagish[dir="ltr"] .checkboxes-group .options label {
    text-align: left;
}

.bNagish-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #444;
}
.bNagish-close {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: var(--bn-transition);
}
.bNagish-close:hover {
    background: #c0392b;
}
.bNagish-copyrights {
    font-size: 0.85em;
    color: #aaa;
}
.bNagish-copyrights span {
    color: #fff;
}

@media (max-width: 479.98px) {
    .bNagish-toggle {
        bottom: 10px;
    }
    .bNagish[dir="rtl"] .bNagish-toggle {
        right: 10px;
    }
    .bNagish[dir="ltr"] .bNagish-toggle {
        left: 10px;
    }
    .bNagish-bar {
        bottom: 10px;
        max-height: calc(100vh - 20px);
        width: calc(100vw - 20px);
    }
    .bNagish[dir="rtl"] .bNagish-bar {
        right: 10px;
    }
    .bNagish[dir="ltr"] .bNagish-bar {
        left: 10px;
    }
}

/* A Pharm colours and a consistent left-centre launcher in RTL and LTR. */
:root {
    --bn-primary: #a20d2f;
    --bn-hover-yellow: #f5c7d3;
    --bn-bg-dark: rgba(31, 31, 33, 0.97);
}
#bNagish .bNagish-toggle,
#bNagish .bNagish[dir="rtl"] .bNagish-toggle,
#bNagish .bNagish[dir="ltr"] .bNagish-toggle {
    top: 50%;
    bottom: auto;
    left: -10px;
    right: auto;
    transform: translateY(-50%);
}
#bNagish .bNagish-toggle:hover,
#bNagish .bNagish-toggle:focus-visible {
    transform: translateY(-50%) scale(1.08);
}
#bNagish .bNagish-icon {
    width: 31px;
    height: 31px;
    object-fit: contain;
}
html.bNagish-hide-images #bNagish .bNagish-icon {
    visibility: visible !important;
}
#bNagish .bNagish-bar,
#bNagish .bNagish[dir="rtl"] .bNagish-bar,
#bNagish .bNagish[dir="ltr"] .bNagish-bar {
    top: 50%;
    bottom: auto;
    left: 14px;
    right: auto;
    width: min(340px, calc(100vw - 28px));
    max-height: min(85vh, calc(100dvh - 28px));
    transform: translateY(calc(-50% + 20px));
}
#bNagish .bNagish.open .bNagish-bar {
    transform: translateY(-50%);
}
#bNagish .bNagish {
    font-size: 16px;
    line-height: 1.45;
}
#bNagish .bNagish-bar h2 {
    color: #fff !important;
    font-size: 24px !important;
    font-weight: 700;
    line-height: 1.35;
}
#bNagish .bNagish-bar legend {
    color: #ddd !important;
    font-size: 16px !important;
}
#bNagish .bNagish .options input[type="radio"],
#bNagish .bNagish .options input[type="checkbox"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    opacity: 0 !important;
    clip-path: inset(50%);
    overflow: hidden;
}
#bNagish .bNagish .options label,
#bNagish .bNagish-links-group :is(a, button) {
    font-size: 14px;
    line-height: 1.35;
}
#bNagish .bNagish .options label::before,
#bNagish .bNagish .options label::after {
    content: none !important;
    display: none !important;
}
#bNagish .bNagish-footer .bNagish-close {
    width: auto;
    min-width: 68px;
    flex: none;
    font-size: 14px;
}
#bNagish .bn-reset-btn {
    background: #fbe5eb !important;
    color: #89112c !important;
}
#bNagish .bn-reset-btn:hover,
#bNagish .bn-reset-btn:focus-visible,
#bNagish .bNagish-close,
#bNagish .bNagish-close:hover {
    background: #a20d2f !important;
    color: #fff !important;
}
#bNagish .bNagish :is(button, a, input + label):focus-visible {
    outline: 3px solid #f5c7d3;
    outline-offset: 2px;
}
@media (max-width: 479.98px) {
    #bNagish .bNagish-toggle,
    #bNagish .bNagish-bar {
        left: 10px;
    }
}
