/* ============================================================
   Legal pages and the cookie notice: the one place their styles live.

   Privacy Policy, Terms of Service, and Consumer Health Data Privacy
   Policy are numbered sections (.legal-row), each pairing the formal
   wording (.legal-text) with what it means in plain English
   (.legal-plain), beside an "On This Page" list on wide screens.
   Templates: templates/landing/legal_layout.html and
   templates/landing/includes/legal/. Tokens come from theme.css.
   ============================================================ */

.legal-layout {
    display: grid;
    gap: 2.5rem;
    max-width: 72rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 5rem;
}

@media (min-width: 80rem) {
    .legal-layout {
        grid-template-columns: 12rem minmax(0, 1fr);
        padding-top: 3rem;
    }
}

/* ---------- Contents ---------- */

.legal-contents {
    display: none;
}

@media (min-width: 80rem) {
    .legal-contents {
        display: block;
    }
}

.legal-contents__inner {
    position: sticky;
    top: 6rem;
    max-height: calc(100svh - 8rem);
    overflow-y: auto;
    padding-bottom: 1.5rem;
}

.legal-contents__title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.legal-contents ol {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.75rem;
    border-left: 1px solid var(--border);
    font-size: 0.875rem;
}

.legal-contents a {
    display: block;
    margin-left: -1px;
    padding-left: 0.75rem;
    border-left: 1px solid transparent;
    color: var(--muted-foreground);
    text-decoration: none;
}

.legal-contents a:hover,
.legal-contents a:focus-visible {
    border-left-color: var(--foreground);
    color: var(--foreground);
}

/* ---------- Article ---------- */

.legal-prose {
    min-width: 0;
    color: var(--foreground);
}

.legal-header {
    max-width: 48rem;
}

.legal-eyebrow {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-ink, var(--accent));
}

.legal-prose h1 {
    margin-top: 0.5rem;
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    text-wrap: balance;
}

.legal-updated {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.legal-lead {
    margin-top: 1.25rem;
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--muted-foreground);
    text-wrap: pretty;
}

.legal-lead a,
.legal-text a,
.legal-plain a {
    color: var(--accent-ink, var(--accent));
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* Column captions over the first row, wide screens only. */
.legal-columns {
    display: none;
}

@media (min-width: 64rem) {
    .legal-columns {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 18rem;
        gap: 2.5rem;
        margin-top: 2.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--border);
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted-foreground);
    }
}

/* ---------- Sections ---------- */

.legal-row {
    display: grid;
    gap: 1rem;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
    scroll-margin-top: 5rem;
}

@media (min-width: 64rem) {
    .legal-row {
        grid-template-columns: minmax(0, 1fr) 18rem;
        grid-template-areas:
            "title title"
            "text plain";
        column-gap: 2.5rem;
    }

    .legal-row > h2 { grid-area: title; }
    .legal-row > .legal-text { grid-area: text; }
    .legal-row > .legal-plain { grid-area: plain; align-self: start; }
}

.legal-row > h2 {
    font-size: 1.75rem;
    scroll-margin-top: 5rem;
}

.legal-text {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--muted-foreground);
}

.legal-text > * + * {
    margin-top: 0.875rem;
}

.legal-text strong,
.legal-plain strong {
    color: var(--foreground);
    font-weight: 600;
}

.legal-text ul,
.legal-plain ul {
    display: grid;
    gap: 0.5rem;
    padding-left: 1.25rem;
    list-style: disc;
}

.legal-text code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.85em;
    color: var(--foreground);
}

.legal-plain {
    padding: 1rem 1.125rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0.75rem;
    background: var(--card);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--foreground);
}

.legal-plain > * + * {
    margin-top: 0.625rem;
}

.legal-plain-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-ink, var(--accent));
}

/* ---------- Tables and history ---------- */

.legal-table-wrap {
    overflow-x: auto;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.legal-table th,
.legal-table td {
    padding: 0.625rem 0.75rem 0.625rem 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.legal-table th {
    font-weight: 600;
    color: var(--foreground);
}

.legal-history dt {
    margin-top: 0.75rem;
    font-weight: 600;
    color: var(--foreground);
}

.legal-history dd {
    margin-top: 0.25rem;
}

/* ---------- Cookie notice ----------
   Informational: every cookie the site sets is strictly necessary, so it
   tells rather than asks. Markup and behavior: templates/shared/cookie_notice.html. */

.cookie-notice {
    position: fixed;
    right: 0.75rem;
    bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
    left: 0.75rem;
    z-index: 85;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--card);
    box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.35);
    color: var(--foreground);
    font-size: 0.875rem;
    animation: cookie-notice-in 200ms ease-out both;
}

.cookie-notice[hidden] {
    display: none;
}

@media (min-width: 40rem) {
    .cookie-notice {
        right: auto;
        bottom: 1rem;
        left: 1rem;
        max-width: 24rem;
    }
}

.cookie-notice__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground);
}

.cookie-notice__text {
    margin-top: 0.25rem;
    color: var(--muted-foreground);
    line-height: 1.5;
    text-wrap: pretty;
}

.cookie-notice__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

.cookie-notice__link {
    color: var(--muted-foreground);
    text-underline-offset: 0.2em;
}

.cookie-notice__link:hover,
.cookie-notice__link:focus-visible {
    color: var(--foreground);
    text-decoration: underline;
}

@keyframes cookie-notice-in {
    from {
        opacity: 0;
        transform: translateY(0.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-notice {
        animation: none;
    }
}

/* ---------- Dashboard legal links ---------- */

.legal-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1rem;
    padding: 2rem 1rem 7rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

@media (min-width: 64rem) {
    .legal-links {
        padding-bottom: 2rem;
    }
}

.legal-links a {
    color: inherit;
    text-underline-offset: 0.2em;
}

.legal-links a:hover,
.legal-links a:focus-visible {
    color: var(--foreground);
    text-decoration: underline;
}

/* One bottom prompt at a time: the add-email nudge waits until the cookie
   notice is closed, and on phones the notice clears the dashboard tab bar
   and its raised Add button. */
body:has(.cookie-notice:not([hidden])) #account-nudge {
    display: none;
}

/* On phones the install banner shares the notice's spot, so it waits too. */
@media (max-width: 639px) {
    body:has(.cookie-notice:not([hidden])) #install-banner {
        display: none !important;
    }
}

@media (max-width: 1023px) {
    body:has(#bottom-nav) .cookie-notice {
        bottom: calc(8rem + env(safe-area-inset-bottom, 0px));
    }
}

@media print {
    .cookie-notice {
        display: none !important;
    }
}
