/* ============================================================
   Cookie consent — banner + preferences dialog.
   First-party, design-token driven (no Bootstrap components).
   Loaded only when a consent-gated tool is configured (Head.ss).
   ============================================================ */

/* ---------- First-visit banner ---------- */
.cookie-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--surface);
    border-top: 1px solid var(--hairline-strong);
    box-shadow: var(--shadow-4);
    padding: var(--s-5) 0;
    /* viewport-fit=cover: extend the white ground under the iOS home indicator
       and keep the buttons above it. */
    padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
}
.cookie-banner[hidden] { display: none; }
.cookie-banner:focus { outline: none; }

.cookie-banner__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-5) var(--s-6);
    flex-wrap: wrap;
}
.cookie-banner__copy { flex: 1 1 380px; min-width: 0; }
.cookie-banner__title {
    font-size: var(--t-h3);
    font-weight: 700;
    margin: 0 0 var(--s-2);
    color: var(--ink);
}
.cookie-banner__text {
    font-size: var(--t-small);
    line-height: 1.55;
    color: var(--ink-soft);
    margin: 0;
    max-width: 70ch;
}
.cookie-banner__policy {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}
.cookie-banner__policy:hover { color: var(--accent); }

.cookie-banner__actions {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
    flex: 0 0 auto;
}

/* ---------- Buttons ----------
   Accept and Reject use the SAME solid style — equal prominence, one click
   each (TTDDG / DSK: reject must be as easy as accept). "Settings"/"Save"
   are the quieter text variant — secondary, but not a consent decision. */
.cookie-consent__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    color: var(--bg);
    background: var(--ink);
    border: 1px solid var(--ink);
    border-radius: var(--r-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background 160ms var(--ease), color 160ms var(--ease),
                border-color 160ms var(--ease), opacity 160ms var(--ease);
}
.cookie-consent__btn:hover { opacity: 0.86; }
.cookie-consent__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cookie-consent__btn--text {
    background: transparent;
    color: var(--ink);
    border-color: transparent;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding-left: var(--s-3);
    padding-right: var(--s-3);
}
.cookie-consent__btn--text:hover { color: var(--accent); opacity: 1; }

/* ---------- Preferences dialog ---------- */
.cookie-settings {
    width: min(560px, calc(100vw - 2 * var(--gutter)));
    max-width: 560px;
    padding: 0;
    border: 0;
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-4);
}
.cookie-settings::backdrop {
    background: rgba(15, 14, 10, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.cookie-settings__panel { position: relative; padding: var(--s-6); }

.cookie-settings__close {
    position: absolute;
    top: var(--s-3);
    right: var(--s-3);
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-pill);
    color: var(--ink-soft);
    background: transparent;
    transition: background 140ms var(--ease), color 140ms var(--ease);
}
.cookie-settings__close:hover { background: var(--stone-100); color: var(--ink); }
.cookie-settings__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cookie-settings__title {
    font-size: var(--t-h2);
    font-weight: 700;
    margin: 0 var(--s-7) var(--s-2) 0;
    color: var(--ink);
}
/* Programmatic focus target on open (for screen-reader orientation) — no
   visible focus ring, it's not a keyboard-navigable control. */
.cookie-settings__title:focus { outline: none; }
.cookie-settings__intro {
    font-size: var(--t-small);
    line-height: 1.55;
    color: var(--ink-soft);
    margin: 0 0 var(--s-4);
    max-width: 52ch;
}

.cookie-settings__list { list-style: none; margin: 0; padding: 0; }

.cc-cat {
    padding: var(--s-4) 0;
    border-top: 1px solid var(--hairline);
}
.cc-cat:first-child { border-top: 0; }
.cc-cat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
}
.cc-cat__name { font-weight: 600; font-size: 15px; color: var(--ink); }
.cc-cat__desc {
    font-size: var(--t-small);
    line-height: 1.5;
    color: var(--ink-soft);
    margin: var(--s-1) 0 0;
    max-width: 60ch;
}

/* ---------- Toggle switch ---------- */
.cc-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    flex: 0 0 auto;
    cursor: pointer;
}
.cc-switch input {
    position: absolute;
    top: 0;
    left: 0;
    width: 44px;
    height: 24px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.cc-switch input:disabled { cursor: not-allowed; }
.cc-switch__track {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    border-radius: var(--r-pill);
    background: var(--stone-300);
    transition: background 160ms var(--ease);
}
.cc-switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-1);
    transition: transform 160ms var(--ease);
}
.cc-switch input:checked + .cc-switch__track { background: var(--accent); }
.cc-switch input:checked + .cc-switch__track::after { transform: translateX(20px); }
.cc-switch input:focus-visible + .cc-switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-switch--locked .cc-switch__track { opacity: 0.55; }
.cc-switch__state {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
    white-space: nowrap;
}

.cookie-settings__policy { font-size: var(--t-small); margin: var(--s-4) 0 0; }
.cookie-settings__policy a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.cookie-settings__policy a:hover { color: var(--accent); }

.cookie-settings__actions {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-top: var(--s-5);
}

/* ---------- Footer "Cookie settings" button ----------
   Matches the sibling legal links (.site-footer__legal a). */
.site-footer__legal-btn {
    font: inherit;
    font-size: inherit;
    color: var(--ink-soft);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}
.site-footer__legal-btn:hover { color: var(--accent); }
.site-footer__legal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .cookie-banner__actions { width: 100%; }
    .cookie-banner__actions .cookie-consent__btn { flex: 1 1 auto; }
    .cookie-banner__actions .cookie-consent__btn--text {
        order: 3;
        flex-basis: 100%;
    }
    .cookie-settings__actions { flex-direction: column-reverse; align-items: stretch; }
    .cookie-settings__actions .cookie-consent__btn { width: 100%; }
}
