:root {
    --tibdas-font-scale-percentage: 100%;
}

/*
 * Agrandissement fiable du contenu.
 * Le widget et son panneau gardent leur propre taille.
 */
html:not(.tibdas-widget-scope) {
    font-size: var(--tibdas-font-scale-percentage) !important;
}

.tibdas-launcher,
.tibdas-panel,
.tibdas-launcher *,
.tibdas-panel * {
    box-sizing: border-box;
}

.tibdas-launcher {
    position: fixed;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    background: var(--tibdas-primary, #1F4B99);
    color: var(--tibdas-launcher-text, #FFFFFF);
    font: 700 14px/1.2 Arial, sans-serif;
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.30);
    cursor: pointer;
}

.tibdas-launcher:focus-visible,
.tibdas-panel button:focus-visible {
    outline: 4px solid #FBBF24 !important;
    outline-offset: 3px !important;
}

.tibdas-shape-round {
    border-radius: 999px;
}

.tibdas-shape-square {
    border-radius: 12px;
}

.tibdas-shape-pill {
    border-radius: 999px;
    padding-inline: 18px !important;
}

.tibdas-size-small {
    min-width: 46px;
    min-height: 46px;
    padding: 10px;
}

.tibdas-size-medium {
    min-width: 58px;
    min-height: 58px;
    padding: 13px;
}

.tibdas-size-large {
    min-width: 72px;
    min-height: 72px;
    padding: 16px;
    font-size: 16px;
}

.tibdas-position-top-left {
    top: var(--tibdas-offset-y, 24px);
    left: var(--tibdas-offset-x, 24px);
}

.tibdas-position-top-right {
    top: var(--tibdas-offset-y, 24px);
    right: var(--tibdas-offset-x, 24px);
}

.tibdas-position-middle-left {
    top: 50%;
    left: var(--tibdas-offset-x, 24px);
    transform: translateY(-50%);
}

.tibdas-position-middle-right {
    top: 50%;
    right: var(--tibdas-offset-x, 24px);
    transform: translateY(-50%);
}

.tibdas-position-bottom-left {
    bottom: var(--tibdas-offset-y, 24px);
    left: var(--tibdas-offset-x, 24px);
}

.tibdas-position-bottom-right {
    right: var(--tibdas-offset-x, 24px);
    bottom: var(--tibdas-offset-y, 24px);
}

.tibdas-launcher-icon {
    font-size: 1.25em;
}

.tibdas-launcher-label[data-desktop="hide"] {
    display: none;
}

.tibdas-panel {
    position: fixed;
    right: 24px;
    bottom: 105px;
    z-index: 2147482999;
    width: min(410px, calc(100vw - 28px));
    max-height: min(760px, calc(100vh - 130px));
    overflow: auto;
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 20px;
    background: #FFFFFF;
    color: #101828;
    font: 400 15px/1.45 Arial, sans-serif;
    box-shadow: 0 18px 60px rgba(16, 24, 40, 0.30);
}

.tibdas-panel[hidden] {
    display: none !important;
}

.tibdas-panel-for-bottom-left,
.tibdas-panel-for-middle-left,
.tibdas-panel-for-top-left {
    right: auto;
    left: 24px;
}

.tibdas-panel-for-top-left,
.tibdas-panel-for-top-right {
    top: 90px;
    bottom: auto;
}

.tibdas-panel-for-middle-left,
.tibdas-panel-for-middle-right {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

.tibdas-theme-dark {
    background: #111827;
    color: #F9FAFB;
}

@media (prefers-color-scheme: dark) {
    .tibdas-theme-auto {
        background: #111827;
        color: #F9FAFB;
    }
}

.tibdas-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.tibdas-header > div {
    display: grid;
}

.tibdas-header strong {
    font-size: 18px;
}

.tibdas-header small {
    margin-top: 3px;
    color: #667085;
}

.tibdas-theme-dark .tibdas-header small {
    color: #CBD5E1;
}

.tibdas-close {
    width: 38px;
    height: 38px;
    border: 1px solid #D0D5DD;
    border-radius: 10px;
    background: #F8FAFC;
    color: #101828;
    font-size: 24px;
    cursor: pointer;
}

.tibdas-section-title {
    margin: 20px 0 10px;
    font-size: 14px;
}

.tibdas-grid,
.tibdas-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tibdas-option {
    min-height: 48px;
    padding: 11px;
    border: 1px solid #D0D5DD;
    border-radius: 11px;
    background: #F8FAFC;
    color: #101828;
    font: 700 13px/1.25 Arial, sans-serif;
    cursor: pointer;
}

.tibdas-option[aria-pressed="true"] {
    border-color: var(--tibdas-primary, #1F4B99);
    background: #EAF1FF;
    box-shadow: inset 0 0 0 2px var(--tibdas-primary, #1F4B99);
}

.tibdas-theme-dark .tibdas-option {
    border-color: #475467;
    background: #1F2937;
    color: #F9FAFB;
}

.tibdas-scale-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 82px 1fr;
    align-items: center;
    gap: 10px;
}

.tibdas-scale-output {
    display: grid;
    min-height: 48px;
    place-items: center;
    border: 1px solid #D0D5DD;
    border-radius: 11px;
    background: #FFFFFF;
    color: #101828;
    font-weight: 800;
}

.tibdas-reset {
    width: 100%;
    margin-top: 16px;
}

.tibdas-powered {
    display: block;
    margin-top: 12px;
    text-align: center;
    color: #667085;
}

/* Effets d’accessibilité */

html.tibdas-high-contrast body {
    filter: contrast(1.35);
}

html.tibdas-grayscale body {
    filter: grayscale(1);
}

html.tibdas-high-contrast.tibdas-grayscale body {
    filter: contrast(1.35) grayscale(1);
}

/* Le widget ne doit pas subir les filtres du site. */
html.tibdas-high-contrast .tibdas-launcher,
html.tibdas-high-contrast .tibdas-panel,
html.tibdas-grayscale .tibdas-launcher,
html.tibdas-grayscale .tibdas-panel {
    filter: none !important;
}

html.tibdas-underline-links body a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
}

html.tibdas-readable-font body,
html.tibdas-readable-font body button,
html.tibdas-readable-font body input,
html.tibdas-readable-font body select,
html.tibdas-readable-font body textarea {
    font-family: Arial, Verdana, sans-serif !important;
}

html.tibdas-text-spacing body :where(
    p, li, a, span, label, button, input, select, textarea,
    h1, h2, h3, h4, h5, h6
) {
    letter-spacing: 0.08em !important;
    word-spacing: 0.12em !important;
    line-height: 1.7 !important;
}

html.tibdas-stop-animations body *,
html.tibdas-stop-animations body *::before,
html.tibdas-stop-animations body *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

html.tibdas-highlight-focus body *:focus {
    outline: 4px solid #FBBF24 !important;
    outline-offset: 3px !important;
}

html.tibdas-hide-images body img,
html.tibdas-hide-images body picture,
html.tibdas-hide-images body video {
    visibility: hidden !important;
}

html.tibdas-large-cursor body,
html.tibdas-large-cursor body * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M3 3l12 32 5-11 11-5z' fill='white' stroke='black' stroke-width='3'/%3E%3C/svg%3E") 3 3, auto !important;
}

html.tibdas-reading-guide-active body::after {
    content: "";
    position: fixed;
    top: 48%;
    right: 0;
    left: 0;
    z-index: 2147482000;
    height: 58px;
    border-top: 3px solid #FBBF24;
    border-bottom: 3px solid #FBBF24;
    background: rgba(251, 191, 36, 0.15);
    pointer-events: none;
}

@media (max-width: 640px) {
    .tibdas-launcher-label[data-mobile="hide"] {
        display: none;
    }

    .tibdas-launcher-label[data-mobile="show"] {
        display: inline;
    }

    .tibdas-panel,
    .tibdas-panel-for-bottom-left,
    .tibdas-panel-for-middle-left,
    .tibdas-panel-for-top-left,
    .tibdas-panel-for-top-right,
    .tibdas-panel-for-middle-right {
        top: auto;
        right: 14px;
        bottom: 92px;
        left: 14px;
        width: auto;
        max-height: calc(100vh - 110px);
        transform: none;
    }

    .tibdas-grid,
    .tibdas-profile-grid {
        grid-template-columns: 1fr 1fr;
    }
}
