/* B2.3 Commit 2 — first-layer consent banner.
 *
 * Preference-centre styles arrive with Commit 3; this file covers the banner
 * only.
 *
 * COMPLIANCE GATE (String 4): .consent-banner__btn--primary is shared by BOTH
 * Accept and Reject. They must stay geometrically and visually identical —
 * same padding, radius, font-size, font-weight, min-width and contrast tier.
 * Only --link (Manage preferences) may be de-emphasised. Do not add a
 * "--accept" modifier that changes size or weight.
 */

.consent-banner {
    position: fixed;          /* out of document flow => no CLS when revealed */
    inset-inline: 0;
    bottom: 0;
    z-index: 9990;            /* above sticky chrome, below any future modal */
    background: #ffffff;
    border-top: 2px solid #815ef5;
    box-shadow: 0 -4px 24px rgba(39, 41, 94, .14);
    font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
    direction: rtl;
    text-align: right;
}

.consent-banner__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.consent-banner__heading {
    margin: 0 0 4px;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.4;
    color: #27295e;
}

.consent-banner__description {
    margin: 0;
    font-size: .9375rem;
    line-height: 1.7;
    color: #4a4d70;
}

.consent-banner__pp-link {
    color: #815ef5;
    text-decoration: underline;
    white-space: nowrap;
}

.consent-banner__pp-link:hover,
.consent-banner__pp-link:focus-visible {
    color: #6a45e0;
}

.consent-banner__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.consent-banner__btn {
    font-family: inherit;
    font-size: .9375rem;
    line-height: 1.4;
    cursor: pointer;
    border-radius: 10px;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

/* Accept AND Reject — identical by construction. */
.consent-banner__btn--primary {
    min-height: 48px;                 /* >= 44px tap target */
    padding: 12px 20px;
    font-weight: 700;
    color: #ffffff;
    background: #815ef5;
    border: 2px solid #815ef5;
}

.consent-banner__btn--primary:hover {
    background: #6a45e0;
    border-color: #6a45e0;
}

/* Manage preferences — the only button that may carry less emphasis. */
.consent-banner__btn--link {
    min-height: 44px;
    padding: 10px 16px;
    font-weight: 500;
    color: #815ef5;
    background: transparent;
    border: 1px solid transparent;
    text-decoration: underline;
}

.consent-banner__btn--link:hover {
    color: #6a45e0;
    background: rgba(129, 94, 245, .06);
}

.consent-banner__btn:focus-visible,
.consent-banner__pp-link:focus-visible {
    outline: 3px solid #27295e;
    outline-offset: 2px;
}

@media (min-width: 768px) {
    .consent-banner__inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
        padding: 18px 24px;
    }

    .consent-banner__text  { flex: 1 1 auto; }

    .consent-banner__actions {
        flex-direction: row;
        align-items: center;
        flex: 0 0 auto;
    }

    .consent-banner__btn--primary { min-width: 168px; }
}

@media (prefers-reduced-motion: reduce) {
    .consent-banner__btn,
    .consent-banner__pp-link { transition: none; }
}

/* ---------------------------------------------------------------------------
 * B2.3 Commit 3 — preference centre.
 * --------------------------------------------------------------------------- */

.consent-preferences {
    position: fixed;
    inset: 0;
    z-index: 10000;            /* above the banner's 9990 */
    display: block;
    font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
    direction: rtl;
    text-align: right;
}

.consent-preferences__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 21, 46, .55);
}

.consent-preferences__modal {
    position: relative;
    max-width: 560px;
    margin: 5vh auto;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 24px 60px rgba(20, 21, 46, .3);
}

.consent-preferences__title {
    margin: 0 0 8px;
    font-size: 1.1875rem;
    font-weight: 700;
    color: #27295e;
}

.consent-preferences__intro {
    margin: 0 0 16px;
    font-size: .9375rem;
    line-height: 1.7;
    color: #4a4d70;
}

.consent-preferences__warning {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: #fff8e6;
    border: 1px solid #f0d9a0;
    border-radius: 10px;
}

.consent-preferences__warning p { margin: 0; font-size: .875rem; line-height: 1.7; color: #6b5420; }
.consent-preferences__warning p + p { margin-top: 6px; }

.consent-category {
    padding: 16px 0;
    border-top: 1px solid #ece9f8;
}

.consent-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.consent-category__name {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #27295e;
}

/* String 11 — a static badge, deliberately NOT a disabled control. */
.consent-category__status {
    flex: 0 0 auto;
    padding: 4px 12px;
    border-radius: 999px;
    background: #e9f7ee;
    color: #1f7a45;
    font-size: .8125rem;
    font-weight: 500;
}

.consent-category__desc {
    margin: 0;
    font-size: .875rem;
    line-height: 1.75;
    color: #4a4d70;
}

/* Toggle ------------------------------------------------------------------ */

.consent-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    cursor: pointer;
    min-height: 44px;                /* tap target */
}

.consent-toggle__input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;                      /* hidden but focusable + keyboard-operable */
    margin: 0;
}

.consent-toggle__track {
    position: relative;
    display: inline-block;
    width: 46px; height: 26px;
    border-radius: 999px;
    background: #c9c7d6;
    transition: background-color .18s ease;
}

.consent-toggle__track::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;                      /* RTL: knob rests on the right when off */
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .18s ease;
}

.consent-toggle__input:checked ~ .consent-toggle__track { background: #815ef5; }
.consent-toggle__input:checked ~ .consent-toggle__track::after { transform: translateX(-20px); }

.consent-toggle__input:focus-visible ~ .consent-toggle__track {
    outline: 3px solid #27295e;
    outline-offset: 2px;
}

.consent-toggle__label {
    font-size: .8125rem;
    font-weight: 500;
    color: #4a4d70;
}

/* Exactly one state word is visible at a time. */
.consent-toggle__label--on { display: none; }
.consent-toggle__input:checked ~ .consent-toggle__label--on  { display: inline; }
.consent-toggle__input:checked ~ .consent-toggle__label--off { display: none; }

/* Actions ----------------------------------------------------------------- */

.consent-preferences__actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #ece9f8;
}

.consent-preferences__btn {
    font-family: inherit;
    font-size: .9375rem;
    min-height: 48px;
    padding: 12px 22px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.consent-preferences__btn--save {
    font-weight: 700;
    color: #ffffff;
    background: #815ef5;
    border: 2px solid #815ef5;
}

.consent-preferences__btn--save:hover { background: #6a45e0; border-color: #6a45e0; }

/* Cancel may be de-emphasised: it is not the counterpart of Accept — Reject is,
 * and that parity is enforced on the banner. Cancel simply abandons an edit. */
.consent-preferences__btn--cancel {
    font-weight: 500;
    color: #4a4d70;
    background: transparent;
    border: 2px solid #d9d6e8;
}

.consent-preferences__btn--cancel:hover { background: #f5f3fd; border-color: #c4bee3; }

.consent-preferences__btn:focus-visible {
    outline: 3px solid #27295e;
    outline-offset: 2px;
}

.consent-preferences__announcement {
    margin: 12px 0 0;
    min-height: 1.4em;
    font-size: .875rem;
    font-weight: 500;
    color: #1f7a45;
}

@media (max-width: 767px) {
    .consent-preferences__modal {
        margin: 0;
        max-height: 100vh;
        min-height: 100vh;
        border-radius: 0;
        padding: 20px 16px;
    }
    .consent-preferences__actions { flex-direction: column; }
    .consent-preferences__btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .consent-toggle__track,
    .consent-toggle__track::after,
    .consent-preferences__btn { transition: none; }
}
