/*
 * Zonkey cookie consent (base theme, Zonkey\CookieConsent).
 * Colours come from the site's palette through --zkc-* on :root (Frontend::colourCss), with
 * GOV.UK-style fallbacks. Buttons use the theme's own .z-btn classes.
 */

:root {
    --zkc-banner-bg: #f3f2f1;
    --zkc-text: #0b0c0c;
    --zkc-link: #1a4f8b;
    --zkc-fab-bg: #0b0c0c;
    --zkc-fab-text: #ffffff;
    --zkc-border: #6f777b;
    --zkc-success: #00703c;
}

/* Programmatic focus targets (confirmation messages, dialog title) need no ring; controls get a strong one. */
.zk-cookie-banner [tabindex="-1"]:focus,
.zk-cookie-dialog [tabindex="-1"]:focus,
.zk-cookie-form__status:focus {
    outline: none;
    box-shadow: none; /* the theme draws its focus ring as a box-shadow on every :focus */
}

.zk-cookie-banner :focus-visible,
.zk-cookie-dialog :focus-visible,
.zk-cookie-settings :focus-visible,
.zk-embed :focus-visible,
.zk-map-notice :focus-visible,
.zk-cookie-footer :focus-visible,
.zk-cookie-fab:focus-visible {
    outline: 3px solid var(--zkc-text);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px #ffdd00;
}

.zk-link-button {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--zkc-link);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    cursor: pointer;
}

.zk-link-button:hover {
    text-decoration-thickness: 2px;
}

/* ---- Banner: first in the page, in the normal flow ------------------------ */

.zk-cookie-banner {
    background: var(--zkc-banner-bg);
    color: var(--zkc-text);
    border-bottom: 1px solid var(--zkc-border);
}

/* Two classes, because the theme's .z-layout__outer { padding: 0 15px } loads later and would zero
   these; its side gutters are kept. */
.zk-cookie-banner.z-layout__outer {
    padding-top: 24px;
    padding-bottom: 28px;
}

@media (max-width: 640px) {
    .zk-cookie-banner.z-layout__outer {
        padding-top: 20px;
        padding-bottom: 24px;
    }
}

html.zk-consent-pending #zk-cookie-banner[hidden] {
    display: block; /* decided before first paint by the head script; no flash for returning visitors */
}

.zk-cookie-banner__heading {
    margin: 0 0 0.5em;
    font-size: 1.5rem;
    line-height: 1.25;
    color: inherit;
}

.zk-cookie-banner__content p {
    margin: 0 0 1em;
    max-width: 48em;
}

.zk-cookie-banner__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.zk-cookie-banner__actions .z-btn {
    margin: 0;
}

.zk-cookie-banner a,
.zk-cookie-banner__link {
    color: var(--zkc-link);
}

/* ---- Settings form (dialog and Cookies page) ------------------------------- */

.zk-cookie-form__group {
    border: 0;
    border-top: 1px solid #b1b4b6;
    margin: 0;
    padding: 16px 0;
    min-width: 0;
}

.zk-cookie-form__heading {
    display: block;
    float: none;
    margin: 0 0 0.4em;
    padding: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
}

.zk-cookie-form__group p {
    margin: 0 0 0.75em;
}

.zk-cookie-form__options {
    display: grid;
    gap: 8px;
}

.zk-cookie-form__option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.zk-cookie-form__option input[type="radio"] {
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    margin: 0;
    accent-color: var(--zkc-text);
    cursor: pointer;
}

.zk-cookie-form__option label {
    padding-top: 0.15rem;
    cursor: pointer;
}

.zk-cookie-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #b1b4b6;
}

.zk-cookie-form__actions .z-btn {
    margin: 0;
}

.zk-cookie-form__status {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-left: 6px solid var(--zkc-success);
    background: #e6f2ec;
    color: var(--zkc-text);
    font-weight: 700;
}

/* Under the dialog title, so it is in view without scrolling. */
.zk-cookie-dialog__more {
    margin: -8px 0 16px;
}

.zk-cookie-dialog__more a {
    color: var(--zkc-link);
}

/* ---- Dialog -------------------------------------------------------------- */

/* margin: auto centres a modal <dialog>; the theme's reset (* { margin: 0 }) would pin it top-left. */
.zk-cookie-dialog {
    width: calc(100% - 32px);
    max-width: 40rem;
    max-height: calc(100% - 32px);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #ffffff;
    color: var(--zkc-text);
    overflow: auto;
}

.zk-cookie-dialog::backdrop {
    background: rgba(11, 12, 12, 0.6);
}

.zk-cookie-dialog__inner {
    padding: 24px;
}

/*
 * On short screens the dialog scrolls; keep Save and Close in view at its foot. scroll-padding
 * stops the browser scrolling a focused radio button underneath them (WCAG 2.4.11).
 */
.zk-cookie-dialog {
    scroll-padding-bottom: 160px; /* the bar is taller on phones, where the buttons stack */
}

.zk-cookie-dialog .zk-cookie-form__actions {
    position: sticky;
    bottom: 0;
    margin-bottom: -24px;
    padding-bottom: 24px;
    background: #ffffff;
}

.zk-cookie-dialog__title {
    margin: 0 0 16px;
    font-size: 1.6rem;
    line-height: 1.25;
}

/* ---- Embedded content and maps waiting for consent ------------------------ */

.zk-embed {
    background: var(--zkc-banner-bg);
    color: var(--zkc-text);
    border: 1px solid var(--zkc-border);
    padding: 20px;
    margin: 0 0 1.5em;
}

.zk-embed__notice p {
    margin: 0 0 0.75em;
}

.zk-embed__notice p:last-child {
    margin-bottom: 0;
}

.zk-embed__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.zk-embed__actions .z-btn {
    margin: 0;
}

.zk-embed a {
    color: var(--zkc-link);
}

[data-map] {
    position: relative;
}

.zk-map-notice {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: var(--zkc-banner-bg);
    color: var(--zkc-text);
    text-align: center;
    overflow: auto;
}

.zk-map-notice p {
    margin: 0;
    max-width: 32em;
}

.zk-map-notice__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px 16px;
}

.zk-map-notice .z-btn {
    margin: 0;
}

/* ---- Cookies page ------------------------------------------------------------- */

.zk-cookie-settings {
    margin: 0 0 2.5rem;
}

/* A "Manage cookie preferences" button saved in content by the old plugin's block: it still opens
   Cookie settings, and now looks like the module's other settings links. */
button[data-ccc-action="open-preferences"] {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--zkc-link);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    cursor: pointer;
}

button[data-ccc-action="open-preferences"]:focus-visible {
    outline: 3px solid var(--zkc-text);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px #ffdd00;
}

.zk-cookie-table-wrap {
    overflow-x: auto;
    margin: 0 0 1.5em;
}

.zk-cookie-table {
    width: 100%;
    border-collapse: collapse;
}

.zk-cookie-table th,
.zk-cookie-table td {
    padding: 10px 12px 10px 0;
    border-bottom: 1px solid #b1b4b6;
    text-align: left;
    vertical-align: top;
}

.zk-cookie-table code {
    white-space: nowrap;
}

/* ---- Footer link ----------------------------------------------------------- */

/* Two classes: the theme's .z-layout__outer { padding: 0 15px } gives the side gutter, these the rest. */
.zk-cookie-footer.z-layout__outer {
    padding-top: 12px;
    padding-bottom: 16px;
    font-size: 0.95rem;
}

.zk-cookie-footer .zk-link-button,
.zk-cookie-footer a {
    color: inherit;
}

/* ---- Floating button: bottom right (back-to-top is bottom left) ----------------- */

.zk-cookie-fab {
    position: fixed;
    right: max(20px, env(safe-area-inset-right, 0px));
    bottom: max(30px, env(safe-area-inset-bottom, 0px));
    z-index: 900;
    display: inline-flex;
    align-items: center;
    gap: 0;
    height: 48px;
    min-width: 48px;
    padding: 0 12px;
    border: 2px solid #ffffff;
    border-radius: 24px;
    background: var(--zkc-fab-bg);
    color: var(--zkc-fab-text);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.zk-cookie-fab[hidden] {
    display: none;
}

.zk-cookie-fab__icon {
    flex: none;
}

/* The label is always the button's name; it slides into view on hover and keyboard focus. */
.zk-cookie-fab__label {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.2s ease, margin 0.2s ease;
}

.zk-cookie-fab:hover .zk-cookie-fab__label,
.zk-cookie-fab:focus-visible .zk-cookie-fab__label {
    max-width: 12em;
    margin-left: 8px;
}

@media (prefers-reduced-motion: reduce) {
    .zk-cookie-fab__label {
        transition: none;
    }
}

@media print {
    .zk-cookie-banner,
    .zk-cookie-fab,
    .zk-cookie-dialog,
    .zk-cookie-footer {
        display: none !important;
    }
}
