/*
 * Reading and accessibility (Plugmind Calm), for the support portal and the operator panel: the same choices as the
 * Operator and Help Desk apps (Settings > Reading and accessibility). Each is a class on <html>, set from this
 * browser's saved choices before the page is drawn (Support/Reading.php), so nothing flashes; reading.js has the panel.
 *
 *   ndc-r-scaled + --ndc-r-scale   text size, on top of the browser's own
 *   ndc-r-font-atkinson / -opendyslexic
 *   ndc-r-spacing                  more space between lines
 *   ndc-r-contrast                 darker text and borders (lighter in dark mode)
 *   ndc-r-motion                   no animations or transitions
 *   ndc-r-calm                     calmer ticket view (reading.js)
 *
 * SupportPal's CSS is in cascade layers, so these plain rules win over it without !important, except where it uses
 * !important itself.
 */

@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("../fonts/AtkinsonHyperlegible-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("../fonts/AtkinsonHyperlegible-Bold.ttf") format("truetype");
    font-weight: 600 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic-Regular.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic-Bold.otf") format("opentype");
    font-weight: 600 800;
    font-style: normal;
    font-display: swap;
}

/* Text size: everything in SupportPal and the theme is sized in rem, so the root size scales the page. */
html.ndc-r-scaled {
    font-size: calc(100% * var(--ndc-r-scale, 1));
}

/* Font: everything except icons and code. */
html.ndc-r-font-atkinson {
    --ndc-r-font: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
}
html.ndc-r-font-opendyslexic {
    --ndc-r-font: "OpenDyslexic", ui-sans-serif, system-ui, sans-serif;
}
html[class*="ndc-r-font-"] body,
html[class*="ndc-r-font-"] body :where(*):not(i, svg, svg *, code, pre, kbd, samp, .fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands, [class^="fa-"], [class*=" fa-"], [class^="fiv-"], [class*=" fiv-"]) {
    font-family: var(--ndc-r-font) !important;
}
html.ndc-r-font-opendyslexic body {
    letter-spacing: .01em;
}

/* More space between lines (and a little between letters and words), in running text. */
html.ndc-r-spacing body :is(p, li, dd, dt, td, th, blockquote, figcaption, label, .sp-description, .sp-message-text, .sp-message-text *, .ndc-prose, .ndc-prose *, .sp-article *) {
    line-height: 1.7 !important;
    letter-spacing: .02em;
    word-spacing: .06em;
}
html.ndc-r-spacing body :is(h1, h2, h3, h4) {
    line-height: 1.4 !important;
}

/* High contrast: SupportPal's, the theme's and Plugmind UI's colours, darker on light and lighter on dark. */
html.ndc-r-contrast {
    --color-text-primary: #000;
    --color-text-secondary: #1f2328;
    --color-background-tertiary: #6b7280;
    --sp-text-color-secondary: #1f2328;
    --ndc-op-text: #000;
    --ndc-op-muted: #1f2328;
    --ndc-op-line: #6b7280;
    --ndc-text: #000;
    --ndc-text-strong: #000;
    --ndc-body: #111827;
    --ndc-muted: #1f2328;
    --ndc-subtle: #374151;
    --ndc-border: #6b7280;
    --ndc-border-soft: #9ca3af;
    --ndc-input-border: #4b5563;
}
html.ndc-r-contrast.sp-theme-dark {
    --color-text-primary: #fff;
    --color-text-secondary: #e5e7eb;
    --color-background-tertiary: #9ca3af;
    --sp-text-color-secondary: #e5e7eb;
    --ndc-op-text: #fff;
    --ndc-op-muted: #e5e7eb;
    --ndc-op-line: #9ca3af;
    --ndc-text: #fff;
    --ndc-text-strong: #fff;
    --ndc-body: #f3f4f6;
    --ndc-muted: #e5e7eb;
    --ndc-subtle: #d1d5db;
    --ndc-border: #9ca3af;
    --ndc-border-soft: #6b7280;
    --ndc-input-border: #9ca3af;
}
html.ndc-r-contrast .pm, html.ndc-r-contrast .pm-tokens {
    --pm-muted: var(--color-text-secondary);
    --pm-border: var(--color-background-tertiary);
}
html.ndc-r-contrast body :is(p, li, td, .sp-description, .sp-message-text) a {
    text-decoration: underline;
}
html.ndc-r-contrast body :focus-visible {
    outline: 3px solid currentColor !important;
    outline-offset: 2px;
}

/* Reduce motion. */
html.ndc-r-motion,
html.ndc-r-motion *,
html.ndc-r-motion *::before,
html.ndc-r-motion *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* The button that opens the panel, in the top bar. */
.ndc-reading-button {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
}
.ndc-reading-glyph {
    white-space: nowrap;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1;
}
.ndc-reading-button:hover {
    background: rgb(255 255 255 / .1);
}
.ndc-reading-button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* The panel. */
.ndc-reading {
    --r-bg: var(--ndc-surface, var(--ndc-op-surface, #fff));
    --r-text: var(--ndc-text, var(--ndc-op-text, #1d2533));
    --r-muted: var(--ndc-muted, var(--ndc-op-muted, #657083));
    --r-line: var(--ndc-border, var(--ndc-op-line, #e5e8ee));
    --r-accent: var(--ndc-accent, var(--ndc-op-accent, #f40867));
    position: fixed;
    inset: 0;
    width: min(26rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    margin: auto;
    padding: 0;
    overflow: auto;
    border: 1px solid var(--r-line);
    border-radius: 16px;
    background: var(--r-bg);
    color: var(--r-text);
    box-shadow: 0 20px 50px rgb(16 24 40 / .25);
}
.ndc-reading::backdrop {
    background: rgb(10 14 20 / .4);
}
.ndc-reading-inner {
    display: grid;
    gap: 1.1rem;
    padding: 1.25rem 1.35rem 1.35rem;
}
.ndc-reading-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.ndc-reading h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}
.ndc-reading-note {
    margin: .2rem 0 0;
    color: var(--r-muted);
    font-size: .8125rem;
}
.ndc-reading-close {
    flex: none;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--r-muted);
    font-size: 1.1rem;
    cursor: pointer;
}
.ndc-reading-row {
    display: grid;
    gap: .35rem;
}
.ndc-reading-row > label, .ndc-reading-label {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-weight: 600;
    font-size: .9rem;
}
.ndc-reading-row output {
    color: var(--r-muted);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}
.ndc-reading input[type=range] {
    width: 100%;
    height: auto;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    appearance: auto;
    accent-color: var(--r-accent);
}
.ndc-reading select {
    width: 100%;
}
.ndc-reading-hint {
    margin: 0;
    color: var(--r-muted);
    font-size: .8rem;
    line-height: 1.45;
}
.ndc-reading-switch {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .65rem 0;
    border-top: 1px solid var(--r-line);
    font-weight: normal;
    cursor: pointer;
}
.ndc-reading-switch input {
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    margin-top: .15rem;
    accent-color: var(--r-accent);
}
.ndc-reading-switch strong {
    display: block;
    font-size: .9rem;
}
.ndc-reading-switch small {
    display: block;
    margin-top: .1rem;
    color: var(--r-muted);
    font-size: .8rem;
    line-height: 1.45;
}
.ndc-reading-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: .75rem;
    border-top: 1px solid var(--r-line);
}
.ndc-reading-reset {
    padding: .45rem .8rem;
    border: 1px solid var(--r-line);
    border-radius: 8px;
    background: transparent;
    color: var(--r-text);
    cursor: pointer;
}
.ndc-reading-done {
    padding: .5rem 1rem;
    border: 0;
    border-radius: 8px;
    background: var(--r-accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.ndc-reading button:focus-visible, .ndc-reading select:focus-visible, .ndc-reading input:focus-visible {
    outline: 2px solid var(--r-accent);
    outline-offset: 2px;
}

/* Calmer ticket view: an earlier message closed by reading.js says it can be opened. */
html.ndc-r-calm .sp-message.ndc-r-closed .sp-message-text-trimmed {
    opacity: .85;
}
