/* Cookie banner and settings dialog (public/assets/site/analytics.js). Self-contained, so it looks the same on
   the playground's light/dark pages and on the always-dark coming-soon and legal pages. */

.cc, .cc-dialog {
    --cc-bg: #ffffff;
    --cc-ink: #0d1b2a;
    --cc-muted: #5b6878;
    --cc-line: #e3e9ef;
    --cc-soft: #f3f8f4;
    --cc-accent: #16a34a;
    --cc-accent-ink: #ffffff;
    --cc-accent-hover: #12893e;
    --cc-ring: rgba(22, 163, 74, 0.35);
    --cc-shadow: 0 24px 60px rgba(13, 27, 42, 0.18), 0 2px 8px rgba(13, 27, 42, 0.08);
    font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--cc-ink);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .cc, :root:not([data-theme="light"]) .cc-dialog {
        --cc-bg: #121f36;
        --cc-ink: #edf2f9;
        --cc-muted: #9fb0cc;
        --cc-line: #22314f;
        --cc-soft: #0e1a2f;
        --cc-accent: #22c55e;
        --cc-accent-ink: #052012;
        --cc-accent-hover: #4ade80;
        --cc-ring: rgba(34, 197, 94, 0.4);
        --cc-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Dark when the site is dark, and always on the pages that are only dark (no .site on body) */
:root[data-theme="dark"] .cc, :root[data-theme="dark"] .cc-dialog,
body:not(.site) .cc, body:not(.site) .cc-dialog {
    --cc-bg: #121f36;
    --cc-ink: #edf2f9;
    --cc-muted: #9fb0cc;
    --cc-line: #22314f;
    --cc-soft: #0e1a2f;
    --cc-accent: #22c55e;
    --cc-accent-ink: #052012;
    --cc-accent-hover: #4ade80;
    --cc-ring: rgba(34, 197, 94, 0.4);
    --cc-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------------------------------ banner */

.cc {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 2147483000;
    width: min(400px, calc(100vw - 40px));
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transition: opacity 0.26s ease, transform 0.26s cubic-bezier(.2, .8, .2, 1);
}
.cc.is-in { opacity: 1; transform: none; }
.cc.is-leaving { opacity: 0; transform: translateY(16px) scale(0.98); }

.cc-card {
    background: var(--cc-bg);
    border: 1px solid var(--cc-line);
    border-radius: 20px;
    box-shadow: var(--cc-shadow);
    padding: 20px 20px 16px;
}

.cc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.cc-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: var(--cc-accent);
    background: var(--cc-soft);
    border: 1px solid var(--cc-line);
}
.cc-icon svg { width: 22px; height: 22px; }
.cc-title { margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; color: var(--cc-ink); }

.cc-text { margin: 0 0 16px; font-size: 0.9rem; line-height: 1.55; color: var(--cc-muted); }
.cc-text a { color: var(--cc-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.cc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cc-actions-3 { grid-template-columns: repeat(3, 1fr); margin-top: 18px; }

/* Equal-weight buttons: saying no is as easy as saying yes */
.cc-btn {
    appearance: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--cc-line);
    background: var(--cc-soft);
    color: var(--cc-ink);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.cc-btn:hover { border-color: var(--cc-accent); }
.cc-btn:active { transform: translateY(1px); }
.cc-btn-primary { background: var(--cc-accent); border-color: var(--cc-accent); color: var(--cc-accent-ink); }
.cc-btn-primary:hover { background: var(--cc-accent-hover); border-color: var(--cc-accent-hover); }
.cc-btn:focus-visible, .cc-link:focus-visible, .cc-close:focus-visible, .cc-switch:focus-visible, .cc-text a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--cc-ring);
}

.cc-link {
    appearance: none;
    display: block;
    margin: 12px auto 0;
    padding: 4px 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--cc-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.cc-link:hover { color: var(--cc-ink); }

/* ------------------------------------------------------------------ settings dialog */

.cc-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    border: 1px solid var(--cc-line);
    border-radius: 22px;
    background: var(--cc-bg);
    box-shadow: var(--cc-shadow);
    overflow: auto;
}
.cc-dialog::backdrop { background: rgba(8, 14, 26, 0.55); backdrop-filter: blur(3px); }
.cc-dialog[open] { animation: cc-pop 0.22s cubic-bezier(.2, .8, .2, 1); }
@keyframes cc-pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.cc-dialog-body { padding: 24px; }
.cc-dialog .cc-head { margin-bottom: 12px; }
.cc-dialog .cc-title { font-size: 1.25rem; flex: 1; }
.cc-close {
    appearance: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    background: transparent;
    color: var(--cc-muted);
    cursor: pointer;
}
.cc-close:hover { color: var(--cc-ink); }

.cc-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 0;
    border-top: 1px solid var(--cc-line);
}
.cc-row-title { display: block; font-weight: 800; font-size: 0.98rem; color: var(--cc-ink); cursor: pointer; }
span.cc-row-title { cursor: default; }
.cc-row p { margin: 4px 0 0; font-size: 0.86rem; line-height: 1.5; color: var(--cc-muted); }

.cc-always {
    flex: none;
    margin-top: 2px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--cc-accent);
    background: var(--cc-soft);
    border: 1px solid var(--cc-line);
    white-space: nowrap;
}

/* A checkbox drawn as a switch */
.cc-switch {
    appearance: none;
    flex: none;
    position: relative;
    width: 48px;
    height: 28px;
    margin: 0;
    border-radius: 999px;
    background: var(--cc-line);
    border: 1px solid var(--cc-line);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.cc-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s cubic-bezier(.2, .8, .2, 1);
}
.cc-switch:checked { background: var(--cc-accent); border-color: var(--cc-accent); }
.cc-switch:checked::after { transform: translateX(20px); }
.cc-switch:disabled { opacity: 0.5; cursor: not-allowed; }

html.cc-open { overflow: hidden; }

/* ------------------------------------------------------------------ phones */

@media (max-width: 560px) {
    .cc { left: 12px; right: 12px; bottom: 12px; width: auto; }
    .cc-actions-3 { grid-template-columns: 1fr; }
    .cc-actions-3 .cc-btn-primary { order: -1; }
    .cc-dialog-body { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .cc, .cc.is-leaving { transition: none; transform: none; }
    .cc-dialog[open] { animation: none; }
    .cc-switch, .cc-switch::after { transition: none; }
}

@media print { .cc { display: none; } }
