/* public/consent.css
 *
 * The cookie banner. Its own stylesheet because it is injected into every page
 * by server/pages.js — the game page loads style.css and the content pages load
 * pages.css, and this belongs to neither.
 *
 * Every colour is a token from tokens.css, which all five pages already load.
 */

.consent {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    /* Clear of the iOS home indicator and of the game's boost meter, which sits
       centred at the bottom of the canvas. */
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    z-index: 2000;

    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;

    width: min(680px, calc(100vw - 24px));
    box-sizing: border-box;
    padding: 14px 18px;

    background: var(--dialog);
    border: 1px solid var(--dialog-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--ink);
    font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.consent[hidden] {
    display: none;
}

/* The banner is fixed, so it sits *over* whatever is at the bottom of the page.
   On the menu that is "Create Public" and "Browse Lobbies" — buttons the
   visitor cannot reach until they answer, which turns a cookie banner into a
   blocker. consent.js measures the banner and publishes its height as
   `--consent-h`, zero whenever it is not on screen.

   These rules win over style.css and pages.css by load order: server/pages.js
   injects this stylesheet last. */
.panel {
    height: calc(100vh - var(--consent-h, 0px));
}

body {
    padding-bottom: var(--consent-h, 0px);
}

.consent-text {
    flex: 1 1 320px;
    margin: 0;
    color: var(--muted);
}

.consent-text a {
    color: var(--accent);
}

.consent-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.consent button {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.consent button:hover {
    border-color: var(--accent);
}

.consent button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Accept and Reject are the *same* weight on purpose.
   Styling Accept as the only filled button, or Reject as a faint link, makes
   refusing harder than agreeing — which regulators treat as a dark pattern and
   which invalidates the consent it collects. Both are filled; the accent is
   spent on neither. */
.consent .consent-yes,
.consent .consent-no {
    background: var(--surface-2);
    border-color: var(--card-border);
    color: var(--ink);
}

.consent .consent-yes:hover,
.consent .consent-no:hover {
    border-color: var(--accent);
}

.consent-details {
    /* Full width under the buttons, so opening it grows the banner downward
       rather than squeezing the text column. */
    flex: 1 0 100%;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
    max-height: min(46vh, 360px);
    overflow-y: auto;
}

.consent-details[hidden] {
    display: none;
}

.consent-row + .consent-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--card-border);
}

.consent-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
    cursor: pointer;
}

.consent-row-head input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    flex: none;
    cursor: pointer;
}

/* Necessary cookies need no consent, so there is nothing to toggle — but they
   are still listed, because a panel showing only the optional ones implies the
   site sets nothing else. */
.consent-always {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.consent-row-desc {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.consent-details-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.consent-save {
    background: var(--accent);
    border-color: var(--accent);
    color: #04231a;
}

@media (max-width: 520px) {
    .consent {
        gap: 10px;
        padding: 12px 14px;
    }

    .consent-actions {
        width: 100%;
        margin-left: 0;
        /* Wrap rather than squeeze: three buttons on one phone-width row makes
           each label truncate, and "Reject a…" is not a clear refusal. */
        flex-wrap: wrap;
    }

    .consent-actions button {
        flex: 1 1 calc(50% - 4px);
    }

    .consent-details {
        max-height: 40vh;
    }
}
