/* ============================================================================
   html/css/privacy-rights.css
   ============================================================================
   Storefront control + opt-out dialog + the tenant settings card.

   Rules of the house: theme tokens only, five type sizes (`--fs-*`), 4/8/12/16/24/32 spacing,
   1px hairlines. Nothing is inline-styled from JS — every class here is the whole story.

   The storefront control deliberately reuses `.sf-ada-trigger` (ada-engine.css) because it sits
   beside the accessibility preference trigger: two visitor-preference controls, one pill shape.
   ============================================================================ */

/* ---------------------------------------------------------------- storefront footer */
/* The storefront shell does not load theme.css, so the `--fs-*` scale this sheet is written
   against resolved to nothing and every size below inherited the 16px browser default — the
   control read as oversized and dated no matter what the rules said. Pin the scale once, scoped
   to the privacy surfaces, so the sizes in this file are the sizes that actually ship. */
.sf-privacy-bar,
.sf-privacy-panel,
.sf-privacy-modal-body,
#sf-privacy-dialog,
.cos-privacy-banner {
    --fs-label: 12px;
    --fs-body: 14px;
    --fs-subhead: 16px;
    --fs-head: 20px;
    --fs-display: 26px;
    --sf-t1: 11px;
    --sf-t2: 12px;
}

/* Guarantee the Storefront tab type, spacing, and radius tokens on #sf-privacy-card
   even when loaded outside #tab-storefront or alongside an un-warmed stylesheet. */
#sf-privacy-card {
    --sf-t1: var(--fs-label, 11px);
    --sf-t2: var(--fs-body, 12.5px);
    --sf-t3: var(--fs-subhead, 15px);
    --sf-t4: var(--fs-head, 20px);
    --sf-t5: var(--fs-display, 28px);
    --sf-s1: var(--space-1, 4px);
    --sf-s2: var(--space-2, 8px);
    --sf-s3: var(--space-3, 12px);
    --sf-s4: var(--space-4, 16px);
    --sf-s5: var(--space-5, 24px);
    --sf-s6: var(--space-6, 32px);
    --sf-radius: var(--radius-card, 12px);
    --sf-radius-sm: var(--radius-control, 8px);
}

/* A sibling row of the trust bar: same centred rhythm, no second top border. */
.sf-privacy-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px 16px;
    width: 100%;
    margin-top: 12px;
}

/* Quieter than the accessibility pill beside it: smaller type, tighter padding, same shape. */
.sf-privacy-trigger {
    text-decoration: none;
    gap: 6px;
    padding: 3px 10px;
    font-size: var(--fs-label);
}

.sf-privacy-trigger-label {
    white-space: nowrap;
}

/* The opt-out toggle sits on the pill's baseline. 20px wide keeps the 30:14 viewBox ratio, so the
   mark stays crisp instead of dominating a footer line set at 12px. */
.sf-privacy-icon {
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: middle;
    width: 20px;
    height: auto;
}

.sf-privacy-trigger:hover .sf-privacy-trigger-label,
.sf-privacy-trigger:focus-visible .sf-privacy-trigger-label {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* AdChoices: a disclosure, not a nav link — so it is quieter than the pill, and always underlined
   on hover because it leaves the site. */
.sf-privacy-adchoices {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--sf-ink-muted, var(--text-muted));
    font-size: var(--fs-label);
    /* A disclosure, not a headline: regular weight, so the accessibility and privacy controls read
       as one quiet footer row instead of the ad notice shouting louder than the page. */
    font-weight: 400;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.sf-privacy-adchoices:hover,
.sf-privacy-adchoices:focus-visible {
    color: var(--sf-ink, var(--text-main));
    text-decoration: underline;
    text-underline-offset: 4px;
}

.sf-privacy-adchoices-icon {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
}

.sf-privacy-adchoices-word {
    white-space: nowrap;
}

/* ---------------------------------------------------------------- the seeded page block */
.sf-privacy-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
    padding: 24px;
    border: 1px solid var(--sf-line, var(--border));
    border-radius: var(--sf-radius, 12px);
    background: var(--sf-bg-alt, var(--bg-card));
}

.sf-privacy-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sf-privacy-panel-title {
    margin: 0;
    font-size: var(--fs-head);
    color: var(--sf-ink, var(--text-main));
}

.sf-privacy-panel-text {
    margin: 0;
    font-size: var(--fs-body);
    line-height: 1.55;
    color: var(--sf-ink-muted, var(--text-muted));
}

.sf-privacy-panel-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Current-state chip: the visitor sees what they chose without opening anything. */
.sf-privacy-state {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border: 1px solid var(--sf-line, var(--border));
    border-radius: 999px;
    background: var(--sf-bg, var(--bg-inset));
    color: var(--sf-ink-muted, var(--text-muted));
    font-size: var(--fs-label);
    font-weight: 600;
    white-space: nowrap;
}

.sf-privacy-state[data-state="opted-out"] {
    border-color: var(--sf-accent-solid, var(--accent-blue));
    color: var(--sf-accent-solid, var(--accent-blue));
}

/* ---------------------------------------------------------------- the AdChoices / opt-out pages */
/* Both pages are the same shape: headings, prose, then the In/Out control and its confirmation. */
.sf-privacy-panel-sub {
    margin: 8px 0 0;
    font-size: var(--fs-subhead);
    color: var(--sf-ink, var(--text-main));
}

.sf-privacy-toggle {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* The In/Out pair is the accessibility dialog's option group — one control model across the site. */
.sf-privacy-toggle .sf-ada-options {
    max-width: 320px;
}

/* "Are you sure you want to opt back in?" — inline, because it belongs to the control above it. */
.sf-privacy-confirm {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid var(--sf-line, var(--border));
    border-radius: 8px;
    background: var(--sf-bg-alt, var(--bg-card));
    color: var(--sf-ink, var(--text-main));
    font-size: var(--fs-body);
}

.sf-privacy-confirm[hidden] {
    display: none;
}

.sf-privacy-note {
    margin: 0;
    font-size: var(--fs-label);
    line-height: 1.5;
    color: var(--sf-ink-muted, var(--text-muted));
}

.sf-privacy-passage {
    margin: 0;
    font-size: var(--fs-label);
    line-height: 1.6;
    color: var(--sf-ink-muted, var(--text-muted));
}

.sf-privacy-passage a {
    color: var(--sf-accent-solid, var(--accent-blue));
    text-decoration: underline;
    text-underline-offset: 4px;
}

.sf-privacy-foot-note {
    margin: 0;
    font-size: var(--fs-label);
    line-height: 1.6;
    color: var(--sf-ink-faint, var(--text-faint));
}

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


.cos-privacy-banner {
    position: fixed;
    inset: auto 16px 16px 16px;
    z-index: 9998;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 16px 24px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 8px 24px rgb(var(--rgb-black) / 0.28);
}

.cos-privacy-banner-body {
    flex: 1 1 320px;
    min-width: 0;
}

.cos-privacy-banner-title {
    display: block;
    font-size: var(--fs-subhead);
    margin-bottom: 4px;
}

.cos-privacy-banner-text {
    margin: 0;
    font-size: var(--fs-body);
    color: var(--text-subtle);
}

.cos-privacy-banner-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}


/* ---------------------------------------------------------------- the shared dialog's additions */
/* The dialog chrome is the accessibility dialog's own (.sf-ada-dialog*, ada-engine.css) — one modal
   in the storefront. All the privacy dialog adds is a paragraph and the footer's action cluster. */
.sf-privacy-dialog-note {
    margin: 0 0 16px;
    font-size: var(--fs-body);
    line-height: 1.55;
    color: var(--sf-ink-muted, var(--text-muted));
}

.sf-privacy-dialog-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* These three must never wrap mid-label: a wrapped "Save my choices" is what the screenshot showed. */
.sf-privacy-dialog-actions .sf-ada-trigger,
.sf-privacy-dialog-actions .sf-surface-btn {
    white-space: nowrap;
}

/* The policy is a link inside a dialog, not a third pill competing with the buttons. */
.sf-privacy-policy-link {
    color: var(--sf-ink-muted, var(--text-muted));
    font-size: var(--fs-label);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.sf-privacy-policy-link:hover,
.sf-privacy-policy-link:focus-visible {
    color: var(--sf-ink, var(--text-main));
}

/* Visible focus for the two footer controls this engine adds. */
.sf-privacy-trigger:focus-visible,
.sf-privacy-adchoices:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* The engine records the state on <html>; the styling hook is here so a tenant can theme it. */
html[data-privacy-state="opted-out"] .sf-privacy-trigger-label {
    text-decoration: underline;
    text-underline-offset: 4px;
}

@media (max-width: 600px) {
    .cos-privacy-banner {
        inset: auto 8px 8px 8px;
        padding: 16px;
    }

    .sf-privacy-panel {
        padding: 16px;
    }

    .sf-privacy-dialog-actions {
        justify-content: flex-end;
    }
}

/* ============================================================================
   TENANT SETTINGS CARD (admin)
   ============================================================================
   The card itself is the Storefront tab's own `.sf-card wide` / `.sf-bd`, with that tab's `.sf-lbl`,
   `.sf-note` and `.sf-inline`. Everything here is only what those primitives do not cover: the status
   pill, the switch rows, the field grid, and the preview. Spacing uses the tab's own scale (--sf-s*),
   so the card breathes exactly like the cards above it.
   ============================================================================ */

/* ---------------------------------------------------------------- status pill */
.prv-pill {
    display: inline-flex;
    align-items: center;
    padding: var(--sf-s1) var(--sf-s3);
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: var(--sf-t1);
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.prv-pill[data-state="on"] {
    border-color: var(--success-accent);
    color: var(--success-accent);
}

#sf-privacy-card .sf-lbl {
    display: flex;
    align-items: center;
    gap: var(--sf-s2);
    margin-top: var(--sf-s2);
    padding-top: var(--sf-s3);
    border-top: 1px solid var(--border-subtle);
}

#sf-privacy-card .sf-bd > .sf-lbl:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

/* ---------------------------------------------------------------- switch rows */
.prv-switches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sf-s2);
}

.prv-switch-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: flex-start;
    gap: var(--sf-s3);
    margin: 0;
    padding: var(--sf-s3);
    background: var(--bg-inset);
    border: 1px solid var(--border-subtle);
    border-radius: var(--sf-radius-sm);
    cursor: pointer;
    transition: border-color .14s ease, background-color .14s ease;
}

.prv-switch-row:hover {
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

.prv-switch {
    width: 18px;
    height: 18px;
    margin: 2px 0 0 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.prv-switch-text {
    display: flex;
    flex-direction: column;
    gap: var(--sf-s1);
    min-width: 0;
}

.prv-switch-title {
    font-size: var(--sf-t2);
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-main);
}

.prv-switch-hint {
    font-size: var(--sf-t1);
    line-height: 1.45;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------- table engine surface */
#sf-privacy-card .admin-table-wrapper {
    border: 1px solid var(--border-subtle);
    border-radius: var(--sf-radius-sm);
    overflow: auto;
    background: var(--bg-inset);
    scrollbar-gutter: auto;
}

#sf-privacy-card .admin-table-wrapper.is-overflowing-y {
    scrollbar-gutter: stable;
}

#sf-privacy-card .admin-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--sf-t2);
}

#sf-privacy-card .admin-table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: var(--sf-s2) var(--sf-s3);
    background: var(--bg-panel);
    background-clip: padding-box;
    box-shadow: 0 1px 0 var(--border);
    border-bottom: 1px solid var(--border);
    font-size: var(--sf-t1);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
    vertical-align: middle;
    line-height: 1.3;
    white-space: nowrap;
    word-break: normal;
}

#sf-privacy-card .admin-table tbody td {
    padding: var(--sf-s3);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    line-height: 1.45;
    word-break: normal;
    overflow-wrap: break-word;
    vertical-align: middle;
    position: static !important;
    z-index: auto !important;
}

#sf-privacy-card .admin-table tbody tr:last-child td {
    border-bottom: 0;
}

#sf-privacy-card .admin-table-empty {
    padding: var(--sf-s4) var(--sf-s3);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--sf-t2);
}

/* ---------------------------------------------------------------- fields */
.prv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sf-s3) var(--sf-s4);
}

@media (max-width: 1100px) {
    .prv-grid {
        grid-template-columns: 1fr;
    }
}

.prv-field {
    display: flex;
    flex-direction: column;
    gap: var(--sf-s1);
    min-width: 0;
}

.prv-field-wide {
    grid-column: 1 / -1;
}

.prv-label {
    font-size: var(--sf-t1);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.prv-hint {
    margin: 0;
    font-size: var(--sf-t1);
    line-height: 1.45;
    color: var(--text-faint);
}

.prv-hint code {
    padding: 0 var(--sf-s1);
    border-radius: var(--sf-radius-sm);
    background: var(--bg-inset);
    color: var(--text-subtle);
    font-family: monospace;
}

/* ---------------------------------------------------------------- preview */
/* A dashed surface, because it is a picture of something else, not a control. */
.prv-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sf-s4);
    border: 1px dashed var(--border-strong);
    border-radius: var(--sf-radius-sm);
    background: var(--bg-inset);
}

.prv-preview .sf-privacy-bar {
    margin-top: 0;
}

/* ada-engine.css is not loaded in the console, so the preview restates the storefront pill here. */
.prv-preview .sf-ada-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--sf-s2);
    padding: var(--sf-s1) var(--sf-s3);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: var(--sf-t2);
    font-weight: 600;
}

.prv-preview .sf-privacy-adchoices {
    color: var(--text-muted);
    font-size: var(--sf-t1);
    font-weight: 600;
    text-decoration: none;
}

