/* =====================================================================
   Cookie Consent – IRC4Fun
   Light-first design with html.theme-dark overrides.
   Colors aligned with irc4fun.css (blue #0076f9, dark bg #12151a, etc.)
   ===================================================================== */

/* Banner */
#cookie-banner {
    display: none;
    position: fixed;
    left: max(18px, env(safe-area-inset-left, 0px));
    bottom: max(18px, env(safe-area-inset-bottom, 0px));
    margin: 0;
    width: min(560px, calc(100vw - 36px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    background: #fff;
    color: #1a1a2e;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    text-align: left;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 220ms ease, transform 220ms ease;
    z-index: 1000;
}

#cookie-banner.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

html.theme-dark #cookie-banner {
    background: rgba(18, 21, 26, 0.96);
    color: #e4e7eb;
    border-color: #2a2f38;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
}

/* Header row */
.cookie-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cookie-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cookie-title-site { display: inline; }
.cookie-title-generic { display: none; }

.cookie-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
}

.cookie-header {
    font-size: 16px;
    font-weight: 900;
    margin: 0;
    letter-spacing: 0.2px;
}

.cookie-status {
    font-size: 12px;
    opacity: 0.72;
    white-space: nowrap;
}

html.theme-dark .cookie-status { opacity: 0.92; }

/* Mini actions */
.cookie-mini-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cookie-mini-settings {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a2e;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.cookie-mini-settings:hover { background: rgba(0, 0, 0, 0.08); }
.cookie-mini-settings:focus-visible { outline: 3px solid rgba(0, 118, 249, 0.4); outline-offset: 2px; }

html.theme-dark .cookie-mini-settings {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}
html.theme-dark .cookie-mini-settings:hover { background: rgba(255, 255, 255, 0.12); }
html.theme-dark .cookie-mini-settings:focus-visible { outline-color: rgba(255, 255, 255, 0.35); }

/* Description */
.cookie-description {
    font-size: 13px;
    opacity: 0.78;
    margin: 10px 0 0 0;
    line-height: 1.5;
    color: #4a4a5a;
}

html.theme-dark .cookie-description { color: #c7cbd1; opacity: 0.92; }

/* Buttons row */
.cookie-buttons {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.cookie-button {
    border: 1px solid transparent;
    padding: 12px;
    cursor: pointer;
    border-radius: 12px;
    font-weight: 900;
    font-size: 14px;
    transition: transform 120ms ease, filter 120ms ease, background 120ms ease, border-color 120ms ease;
    text-align: center;
    width: 100%;
}

.cookie-button:hover { filter: brightness(0.96); }
.cookie-button:active { transform: translateY(1px); }
.cookie-button:focus-visible { outline: 3px solid rgba(0, 118, 249, 0.4); outline-offset: 2px; }

/* Accept — primary blue */
.cookie-accept { background: #0076f9; color: #fff; }
.cookie-accept:hover { background: #0066dd; }

/* Decline */
.cookie-decline {
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a2e;
    border-color: rgba(0, 0, 0, 0.12);
}
html.theme-dark .cookie-decline {
    background: rgba(255, 255, 255, 0.08);
    color: #e4e7eb;
    border-color: rgba(255, 255, 255, 0.18);
}

/* Customize / Save */
.cookie-settings {
    background: #f59e0b;
    color: #1a1a2e;
}

/* Links */
.cookie-links {
    margin-top: 10px;
    font-size: 12px;
    opacity: 0.7;
    color: #6b6b7b;
}
.cookie-links a { color: #0076f9; text-decoration: underline; }

html.theme-dark .cookie-links { color: #9ca3af; opacity: 0.95; }
html.theme-dark .cookie-links a { color: #60a5fa; }

@media (min-width: 520px) {
    .cookie-buttons { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---- Mini mode (pill) ---- */
#cookie-banner.mini {
    width: auto;
    max-width: min(360px, calc(100vw - 36px));
    padding: 10px 12px;
    border-radius: 999px;
    cursor: pointer;
}
#cookie-banner.mini .cookie-description,
#cookie-banner.mini .cookie-buttons { display: none; }
#cookie-banner.mini .cookie-status {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a2e;
    font-weight: 800;
    letter-spacing: 0.1px;
    opacity: 1;
}
html.theme-dark #cookie-banner.mini .cookie-status {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}
#cookie-banner.mini .cookie-mini-settings { display: inline-flex; }
#cookie-banner.mini .cookie-title-site { display: none; }
#cookie-banner.mini .cookie-title-generic { display: inline; }
#cookie-banner.mini .cookie-privacy,
#cookie-banner.mini .cookie-sep { display: none; }
#cookie-banner.mini .cookie-links { margin-top: 0; }
#cookie-banner.mini .cookie-links a { text-decoration: none; }
#cookie-banner.mini .cookie-links a:hover { text-decoration: underline; }

/* ---- Icon mode (post-consent) ---- */
#cookie-banner.icon {
    width: auto;
    max-width: none;
    padding: 0;
    border-radius: 999px;
    cursor: default;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    transform: none;
    opacity: 1;
}

#cookie-banner.icon .cookie-title,
#cookie-banner.icon .cookie-description,
#cookie-banner.icon .cookie-buttons,
#cookie-banner.icon .cookie-links,
#cookie-banner.icon .cookie-status { display: none; }

#cookie-banner.icon .cookie-mini-actions { gap: 0; }

#cookie-banner.icon .cookie-mini-settings {
    display: inline-flex;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: #1a1a2e;
}

html.theme-dark #cookie-banner.icon .cookie-mini-settings {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(18, 21, 26, 0.96);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    color: #e4e7eb;
}

/* ---- Backdrop ---- */
#cookie-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
}
#cookie-backdrop.show {
    display: block;
    animation: cookieBackdropIn 200ms ease forwards;
}

@keyframes cookieBackdropIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

html.theme-dark #cookie-backdrop { background: rgba(0, 0, 0, 0.68); }

/* ---- Modal ---- */
#cookie-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(780px, calc(100vw - 36px));
    max-height: min(80vh, 720px);
    max-height: min(80dvh, 720px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    color: #1a1a2e;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.15);
    text-align: left;
    z-index: 1001;
}
#cookie-modal.show {
    display: block;
    animation: cookieModalIn 200ms ease forwards;
}

@keyframes cookieModalIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

html.theme-dark #cookie-modal {
    background: rgba(18, 21, 26, 0.98);
    color: #e4e7eb;
    border-color: #2a2f38;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
}

/* Modal header */
.cookie-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.cookie-modal-title {
    margin: 0;
    font-weight: 950;
    letter-spacing: 0.2px;
    font-size: 20px;
}
.cookie-modal-subtitle {
    margin: 6px 0 0 0;
    color: #6b6b7b;
    font-size: 13px;
    line-height: 1.55;
}
html.theme-dark .cookie-modal-subtitle { color: #c7cbd1; }

.cookie-modal-close {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a2e;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 800;
    cursor: pointer;
    line-height: 1;
}
.cookie-modal-close:hover { background: rgba(0, 0, 0, 0.08); }

html.theme-dark .cookie-modal-close {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #e4e7eb;
}
html.theme-dark .cookie-modal-close:hover { background: rgba(255, 255, 255, 0.12); }

/* Summary card */
.cookie-summary {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
    border-radius: 14px;
    padding: 12px;
    margin: 10px 0 14px 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

html.theme-dark .cookie-summary {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.cookie-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    color: #6b6b7b;
}
.cookie-summary-row strong { color: #1a1a2e; }

html.theme-dark .cookie-summary-row { color: #c7cbd1; }
html.theme-dark .cookie-summary-row strong { color: #e4e7eb; }

.cookie-summary-note {
    font-size: 12px;
    color: #8e8e9a;
    line-height: 1.35;
}
.cookie-summary-note a { color: #0076f9; text-decoration: underline; }

html.theme-dark .cookie-summary-note { color: #9ca3af; }
html.theme-dark .cookie-summary-note a { color: #60a5fa; }

/* Pills */
.cookie-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a2e;
    font-weight: 800;
    font-size: 12px;
    white-space: nowrap;
}

html.theme-dark .cookie-pill {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #e4e7eb;
}

.cookie-pill.is-on {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.30);
    color: #15803d;
}
html.theme-dark .cookie-pill.is-on {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
    color: #4ade80;
}

.cookie-pill.is-off {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.25);
    color: #dc2626;
}
html.theme-dark .cookie-pill.is-off {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.32);
    color: #f87171;
}

.cookie-pill.is-security {
    background: rgba(34, 197, 94, 0.22);
    border-color: rgba(34, 197, 94, 0.50);
    color: #166534;
}
html.theme-dark .cookie-pill.is-security {
    background: rgba(34, 197, 94, 0.28);
    border-color: rgba(34, 197, 94, 0.55);
    color: #86efac;
}

.cookie-pill.is-info {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.45);
    color: #1e40af;
}
html.theme-dark .cookie-pill.is-info {
    background: rgba(59, 130, 246, 0.24);
    border-color: rgba(59, 130, 246, 0.50);
    color: #93bbfd;
}

.cookie-pill.is-accepted {
    background: rgba(34, 197, 94, 0.22);
    border-color: rgba(34, 197, 94, 0.50);
    color: #166534;
}
html.theme-dark .cookie-pill.is-accepted {
    background: rgba(34, 197, 94, 0.28);
    border-color: rgba(34, 197, 94, 0.55);
    color: #86efac;
}

.cookie-pill.is-declined {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.40);
    color: #991b1b;
}
html.theme-dark .cookie-pill.is-declined {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

.cookie-pill.is-custom {
    background: rgba(234, 179, 8, 0.18);
    border-color: rgba(234, 179, 8, 0.45);
    color: #854d0e;
}
html.theme-dark .cookie-pill.is-custom {
    background: rgba(234, 179, 8, 0.24);
    border-color: rgba(234, 179, 8, 0.50);
    color: #fde68a;
}

.cookie-pill.is-functional {
    background: rgba(139, 92, 246, 0.16);
    border-color: rgba(139, 92, 246, 0.40);
    color: #5b21b6;
}
html.theme-dark .cookie-pill.is-functional {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(139, 92, 246, 0.45);
    color: #c4b5fd;
}

/* Category cards grid */
.cookie-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
@media (min-width: 720px) {
    .cookie-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 720px) {
    .cookie-card-thirdparty { grid-column: 1 / -1; }
}

.cookie-card {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
    border-radius: 16px;
    padding: 14px;
}

html.theme-dark .cookie-card {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.cookie-card {
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.cookie-card:hover {
    border-color: rgba(0, 118, 249, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}
.cookie-card:focus-within {
    border-color: rgba(0, 118, 249, 0.35);
    box-shadow: 0 0 0 3px rgba(0, 118, 249, 0.12);
}

html.theme-dark .cookie-card:hover {
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
}
html.theme-dark .cookie-card:focus-within {
    border-color: rgba(96, 165, 250, 0.40);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.cookie-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.cookie-card-title {
    font-weight: 900;
    margin: 0;
    font-size: 15px;
}
.cookie-card-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #8e8e9a;
}
html.theme-dark .cookie-card-meta { color: #9ca3af; }

.cookie-card-desc {
    margin: 10px 0 0 0;
    font-size: 13px;
    line-height: 1.55;
    color: #6b6b7b;
}
html.theme-dark .cookie-card-desc { color: #c7cbd1; }

/* Toggle switch */
.cookie-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}
.cookie-switch input[type="checkbox"] {
    width: 48px;
    height: 28px;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 999px;
    position: relative;
    outline: none;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease;
}
.cookie-switch input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 140ms ease;
}
.cookie-switch input[type="checkbox"]:checked {
    background: #0076f9;
    border-color: #0066dd;
}
.cookie-switch input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}
.cookie-switch input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(0, 118, 249, 0.4);
    outline-offset: 2px;
}

html.theme-dark .cookie-switch input[type="checkbox"] {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.20);
}
html.theme-dark .cookie-switch input[type="checkbox"]::after {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: none;
}
html.theme-dark .cookie-switch input[type="checkbox"]:checked {
    background: rgba(0, 118, 249, 0.5);
    border-color: rgba(0, 118, 249, 0.7);
}
html.theme-dark .cookie-switch input[type="checkbox"]:focus-visible {
    outline-color: rgba(255, 255, 255, 0.35);
}

/* Cookie details / list */
.cookie-details {
    margin-top: 10px;
    border-top: 1px dashed rgba(0, 0, 0, 0.10);
    padding-top: 10px;
}
.cookie-details summary {
    cursor: pointer;
    font-weight: 800;
    font-size: 13px;
    color: #1a1a2e;
}

html.theme-dark .cookie-details { border-top-color: rgba(255, 255, 255, 0.16); }
html.theme-dark .cookie-details summary { color: rgba(255, 255, 255, 0.92); }

.cookie-cookie-list {
    margin: 8px 0 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: #6b6b7b;
}

html.theme-dark .cookie-cookie-list { color: #c7cbd1; }

.cookie-cookie-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

html.theme-dark .cookie-cookie-list li {
    border-color: rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.03);
}

.cookie-cookie-list code {
    color: #1a1a2e;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
}

html.theme-dark .cookie-cookie-list code { color: rgba(255, 255, 255, 0.92); }

/* Modal actions */
.cookie-modal-actions {
    margin-top: 14px;
    display: grid;
    gap: 10px;
}
@media (min-width: 520px) {
    .cookie-modal-actions { grid-template-columns: 1fr 1fr 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #cookie-banner { transition: none; transform: none; }
    .cookie-button { transition: none; }
    #cookie-modal.show, #cookie-backdrop.show { animation: none; }
    .cookie-card { transition: none; }
    .cookie-toast { transition: none; }
}

/* Card icon */
.cookie-card-icon {
    vertical-align: -2px;
    margin-right: 2px;
    opacity: 0.7;
}

/* Danger button */
.cookie-modal-danger {
    margin-top: 10px;
    text-align: center;
}

.cookie-danger {
    background: transparent;
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.25);
    font-size: 13px;
    padding: 10px 16px;
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cookie-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.40);
    filter: none;
}

html.theme-dark .cookie-danger {
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.30);
}
html.theme-dark .cookie-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
}

/* Toast */
.cookie-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #1a1a2e;
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, transform 200ms ease, visibility 200ms ease;
    z-index: 1002;
    pointer-events: none;
}

.cookie-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

html.theme-dark .cookie-toast {
    background: #e4e7eb;
    color: #1a1a2e;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Screen reader only */
.cookie-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
