﻿/* ==========================================================================
   Accessibility Features CSS
   Loaded only by _LayoutPSAccessible.cshtml and Views/Account/Login.cshtml.
   Does not affect any page still using _LayoutPS.cshtml.
   ========================================================================== */

/* ---------- Skip link ---------- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #1E74FD;
    color: #fff;
    padding: 8px 14px;
    z-index: 100000;
    border-radius: 0 0 6px 6px;
    text-decoration: none;
    font-weight: 600;
}
.skip-link:focus {
    top: 0;
    color: #fff;
}

/* ---------- Appearance control cluster (header) ---------- */
.a11y-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.a11y-controls .headerButton {
    position: relative;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.a11y-controls .headerButton.a11y-aa-btn {
    width: auto;
    padding: 0 8px;
    min-width: 34px;
}

/* ---------- Appearance popover ---------- */
.appearance-popover {
    display: none;
    position: absolute;
    top: 54px;
    right: 8px;
    left: auto;
    width: 280px;
    max-width: calc(100vw - 16px);
    background: #fff;
    color: #141515;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    padding: 18px;
    z-index: 10001;
}
html[dir="rtl"] .appearance-popover {
    right: auto;
    left: 8px;
}
.appearance-popover.open {
    display: block;
}
.appearance-popover h4 {
    margin: 0 0 12px 0;
    font-size: 1.05rem;
    font-weight: 800;
}
.appearance-popover .a11y-section {
    margin-bottom: 16px;
}
.appearance-popover .a11y-section:last-child {
    margin-bottom: 0;
}
.appearance-popover label.a11y-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6C7C94;
    margin-bottom: 8px;
}
.a11y-textsize-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.a11y-textsize-row .a11y-a-small {
    font-size: 0.8rem;
    font-weight: 700;
}
.a11y-textsize-row .a11y-a-large {
    font-size: 1.25rem;
    font-weight: 700;
}
.a11y-textsize-row input[type="range"] {
    flex: 1;
    accent-color: #1E74FD;
}
.a11y-contrast-toggle,
.a11y-darkmode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ---------- Font-size scaling ----------
   Applied by scaling the primary content wrapper. Uses `zoom` (supported by
   Chromium/WebKit-based browsers, which this portal is primarily used with)
   with a `transform: scale()` fallback for browsers without zoom support. */
body.font-scale-sm #appCapsule { zoom: 0.9; }
body.font-scale-lg #appCapsule { zoom: 1.15; }
body.font-scale-xl #appCapsule { zoom: 1.3; }

@supports not (zoom: 1) {
    body.font-scale-sm #appCapsule { transform: scale(0.9); transform-origin: top left; width: 111.11%; }
    body.font-scale-lg #appCapsule { transform: scale(1.15); transform-origin: top left; width: 86.96%; }
    body.font-scale-xl #appCapsule { transform: scale(1.3); transform-origin: top left; width: 76.92%; }
}

/* ---------- High contrast mode ---------- */
/* WCAG 2.1 AA verified: white (#FFFFFF) on black (#000000) = 21:1 (normal text, needs 4.5:1).
   Yellow (#FFEB3B) on black (#000000) = ~17.5:1 (links/accents, needs 4.5:1/3:1). */
body.high-contrast-active {
    background: #000 !important;
    color: #fff !important;
}
body.high-contrast-active #appCapsule,
body.high-contrast-active .appHeader,
body.high-contrast-active .appBottomMenu,
body.high-contrast-active .card,
body.high-contrast-active .section,
body.high-contrast-active .modal-content,
body.high-contrast-active .appearance-popover,
body.high-contrast-active .form-control {
    background: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}
body.high-contrast-active a,
body.high-contrast-active .a11y-a-small,
body.high-contrast-active .a11y-a-large {
    color: #FFEB3B !important;
}
body.high-contrast-active .btn-primary,
body.high-contrast-active .bg-primary {
    background: #000 !important;
    color: #FFEB3B !important;
    border: 2px solid #FFEB3B !important;
}
body.high-contrast-active ion-icon {
    color: inherit !important;
}
body.high-contrast-active :focus {
    outline: 3px solid #FFEB3B !important;
    outline-offset: 2px !important;
}

/* ---------- Required-field convention (Phase 3) ---------- */
.form-group.required > label.a11y-req-label::after,
.form-group.required > .a11y-req-label::after {
    content: " *";
    color: #EC4433;
    font-weight: 700;
}

/* ==========================================================================
   Enhanced Accessibility widget (floating button + panel) — additive,
   kept alongside the header "AA" cluster, not a replacement for it.
   ========================================================================== */
.a11y-widget-fab {
    position: fixed;
    left: 16px;
    /* Sits above the fixed bottom nav bar (.appBottomMenu, ~56px tall)
       instead of overlapping it. */
    bottom: calc(56px + env(safe-area-inset-bottom) + 16px);
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 50%;
    background: #3f9ac9;
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    cursor: pointer;
    padding: 0;
}
.a11y-widget-fab:hover,
.a11y-widget-fab:focus {
    background: #135ecf;
}
.a11y-widget-fab-glyph {
    font-size: 1.6rem;
    line-height: 1;
    color: #fff;
    display: inline-block;
}
/* Pages without the bottom nav (e.g. Login) don't need the extra offset. */
body:not(:has(.appBottomMenu)) .a11y-widget-fab {
    bottom: calc(env(safe-area-inset-bottom) + 16px);
}
html[dir="rtl"] .a11y-widget-fab {
    left: auto;
    right: 16px;
}

.a11y-widget-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 10003;
}
.a11y-widget-overlay.open {
    display: block;
}

.a11y-widget-panel {
    display: none;
    position: fixed;
    left: 16px;
    bottom: 80px;
    width: 320px;
    max-width: calc(100vw - 32px);
    max-height: 75vh;
    overflow-y: auto;
    background: #fff;
    color: #141515;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
    z-index: 10004;
    padding: 16px;
}
.a11y-widget-panel.open {
    display: block;
}
html[dir="rtl"] .a11y-widget-panel {
    left: auto;
    right: 16px;
}
.a11y-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.a11y-widget-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}
.a11y-widget-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #6C7C94;
    cursor: pointer;
}
.a11y-widget-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.a11y-widget-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: #F9F9F9;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4F5050;
    cursor: pointer;
    text-align: center;
}
.a11y-widget-tile ion-icon {
    font-size: 1.6rem;
}
.a11y-widget-tile .a11y-tile-glyph {
    font-size: 1.4rem;
    font-weight: 800;
}
.a11y-widget-tile.active {
    border-color: #1E74FD;
    background: #eaf1ff;
    color: #1E74FD;
}
.a11y-widget-reset {
    width: 100%;
    margin-top: 14px;
    padding: 10px;
    background: #F9F9F9;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    color: #4F5050;
    cursor: pointer;
}

/* ---------- Enhanced-widget feature effects ---------- */
body.a11y-highlight-links a {
    outline: 2px solid #1E74FD !important;
    text-decoration: underline !important;
    background: rgba(30,116,253,.08) !important;
}
body.a11y-text-spacing {
    letter-spacing: 0.05em !important;
    word-spacing: 0.12em !important;
}
body.a11y-pause-animations *,
body.a11y-pause-animations *::before,
body.a11y-pause-animations *::after {
    animation-play-state: paused !important;
    transition: none !important;
}
body.a11y-hide-images img {
    visibility: hidden !important;
}
body.a11y-dyslexia-friendly,
body.a11y-dyslexia-friendly * {
    font-family: "Comic Sans MS", "Comic Sans", Verdana, sans-serif !important;
    letter-spacing: 0.02em !important;
}
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24"><path d="M3 2l14 8-6 2-2 6z" fill="black" stroke="white" stroke-width="1"/></svg>') 4 4, auto !important;
}
body.a11y-tooltips [title] {
    position: relative;
}
body.a11y-tooltips [title]:hover::after,
body.a11y-tooltips [title]:focus::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #141515;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10005;
}
body.a11y-line-height,
body.a11y-line-height p,
body.a11y-line-height li,
body.a11y-line-height div {
    line-height: 1.9 !important;
}
body.a11y-text-align-left,
body.a11y-text-align-left * {
    text-align: left !important;
}

/* ---------- Menu search ---------- */
.menu-search-wrap {
    position: relative;
}
.menu-search-results {
    display: none;
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    max-height: 340px;
    overflow-y: auto;
    background: #fff;
    color: #141515;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    z-index: 10001;
}
.menu-search-results.open {
    display: block;
}
.menu-search-results .menu-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: #141515;
    border-bottom: 1px solid #f0f0f0;
}
.menu-search-results .menu-search-item:last-child {
    border-bottom: none;
}
.menu-search-results .menu-search-item:hover,
.menu-search-results .menu-search-item:focus {
    background: #F9F9F9;
}
.menu-search-empty {
    padding: 14px;
    color: #A1A1A2;
    font-size: 0.85rem;
}
.menu-search-mode-row {
    display: flex;
    gap: 8px;
    padding: 8px 10px 0 10px;
}
.menu-search-mode-row button {
    flex: 1;
    font-size: 0.78rem;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #E1E1E1;
    background: #fff;
    color: #4F5050;
    font-weight: 600;
}
.menu-search-mode-row button.active {
    background: #1E74FD;
    color: #fff;
    border-color: #1E74FD;
}
