/* ==========================================================================
   HumanProse legal pages (Privacy Policy, Terms of Service)
   Loaded after hp-guides.css, which gives the header, banner, prose and
   footer. This file adds the reading layout: a sticky table of contents on
   desktop, numbered sections with self-links, the summary card and the
   cookie table. Tokens only, so dark mode follows; logical properties for RTL.
   ========================================================================== */

body.hp-ui.hp-legal .hpl-banner-link {
    color: var(--hx-on-stage); text-decoration: underline;
    text-decoration-color: rgba(240, 214, 170, .5); text-underline-offset: 4px;
}
body.hp-ui.hp-legal .hpl-banner-link:hover { text-decoration-color: var(--hx-cream); }

/* ---------- Layout: contents beside the reading column ---------- */
body.hp-ui.hp-legal .hpl-layout {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 0;
    margin-top: clamp(32px, 5vw, 56px);
}
body.hp-ui.hp-legal .hpl-main { min-width: 0; }
body.hp-ui.hp-legal .hpl-prose { margin: 28px auto 0; counter-reset: hpl-section; }
body.hp-ui.hp-legal .hpl-contact { margin-top: 56px; }

@media (min-width: 1024px) {
    body.hp-ui.hp-legal .hpl-layout {
        grid-template-columns: 248px minmax(0, 68ch);
        justify-content: center; align-items: start; column-gap: clamp(40px, 5vw, 72px);
    }
    body.hp-ui.hp-legal .hpl-prose { margin-top: 0; }
    body.hp-ui.hp-legal .hpl-contact { max-width: none; }
    body.hp-ui.hp-legal .hpl-toc { position: sticky; top: 96px; }
}

/* ---------- Table of contents ---------- */
body.hp-ui.hp-legal .hpl-toc-box {
    background: var(--hx-surface); border: 1px solid var(--hx-line); border-radius: 20px;
    box-shadow: var(--hx-shadow);
}
body.hp-ui.hp-legal .hpl-toc-summary {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; cursor: pointer; list-style: none; border-radius: 20px;
    font-size: .72rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--hx-quill-ink);
}
body.hp-ui.hp-legal .hpl-toc-summary::-webkit-details-marker { display: none; }
body.hp-ui.hp-legal .hpl-toc-summary svg {
    width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    transition: transform .2s var(--hx-ease);
}
body.hp-ui.hp-legal .hpl-toc-box[open] .hpl-toc-summary svg { transform: rotate(180deg); }
body.hp-ui.hp-legal .hpl-toc-list {
    list-style: none; margin: 0; padding: 0 10px 12px; counter-reset: hpl-toc;
}
body.hp-ui.hp-legal .hpl-toc-list li { counter-increment: hpl-toc; }
body.hp-ui.hp-legal .hpl-toc-list a {
    display: grid; grid-template-columns: 2.1em minmax(0, 1fr); align-items: baseline;
    padding: 7px 10px; border-radius: 10px; border-inline-start: 2px solid transparent;
    color: var(--hx-ink-2); text-decoration: none; font-size: .9rem; line-height: 1.4;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
body.hp-ui.hp-legal .hpl-toc-list a::before {
    content: counter(hpl-toc, decimal-leading-zero);
    font-size: .74rem; font-weight: 700; color: var(--hx-ink-3); font-variant-numeric: tabular-nums;
}
body.hp-ui.hp-legal .hpl-toc-list a:hover { color: var(--hx-ink); background: var(--hx-surface-2); }
body.hp-ui.hp-legal .hpl-toc-list a[aria-current="true"] {
    color: var(--hx-royal-ink); background: var(--hx-royal-soft); border-inline-start-color: var(--hx-quill); font-weight: 600;
}
body.hp-ui.hp-legal .hpl-toc-list a[aria-current="true"]::before { color: var(--hx-quill-ink); }

@media (min-width: 1024px) {
    body.hp-ui.hp-legal .hpl-toc-box { background: transparent; border: 0; box-shadow: none; }
    body.hp-ui.hp-legal .hpl-toc-box[open] .hpl-toc-summary { cursor: default; padding: 0 10px 12px; }
    body.hp-ui.hp-legal .hpl-toc-box[open] .hpl-toc-summary svg { display: none; }
    body.hp-ui.hp-legal .hpl-toc-list { padding: 0; max-height: calc(100vh - 150px); overflow-y: auto; scrollbar-width: thin; }
}

/* ---------- Summary card ---------- */
body.hp-ui.hp-legal .hpl-summary {
    margin: 0 0 2.4em; padding: 22px 26px 8px; border-radius: 20px;
    background: var(--hx-surface); border: 1px solid var(--hx-line); border-inline-start: 3px solid var(--hx-quill);
    box-shadow: var(--hx-shadow);
}
body.hp-ui.hp-legal .hpl-prose .hpl-summary-title {
    margin: 0 0 12px; font-size: .72rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--hx-quill-ink);
}
body.hp-ui.hp-legal .hpl-prose .hpl-summary ul { padding-inline-start: 1.2em; }
body.hp-ui.hp-legal .hpl-prose .hpl-summary li { font-size: 1rem; line-height: 1.65; }

/* ---------- Numbered sections with a link to each ---------- */
body.hp-ui.hp-legal .hpl-prose h2 { counter-increment: hpl-section; scroll-margin-top: 104px; position: relative; }
body.hp-ui.hp-legal .hpl-prose h2::before {
    content: counter(hpl-section, decimal-leading-zero);
    display: block; margin-bottom: 10px;
    font-family: var(--hx-f-body); font-size: .76rem; font-weight: 700; letter-spacing: .16em;
    color: var(--hx-quill-ink); font-variant-numeric: tabular-nums;
}
body.hp-ui.hp-legal .hpl-prose h2 + p { margin-top: 0; }
body.hp-ui.hp-legal .hpl-prose h3 { font-size: 1.05rem; }
body.hp-ui.hp-legal .hpl-prose .hpl-anchor {
    margin-inline-start: .35em; padding: 0 .15em; border-radius: 6px;
    font-family: var(--hx-f-body); font-size: .62em; font-weight: 700; text-decoration: none;
    color: var(--hx-quill); opacity: 0; transition: opacity .2s ease;
}
body.hp-ui.hp-legal .hpl-prose h2:hover .hpl-anchor,
body.hp-ui.hp-legal .hpl-prose .hpl-anchor:focus-visible { opacity: 1; }
body.hp-ui.hp-legal .hpl-prose h2:target { color: var(--hx-royal-ink); }
@media (hover: none) {
    body.hp-ui.hp-legal .hpl-prose .hpl-anchor { opacity: .55; }
}

/* ---------- Cookie table ---------- */
body.hp-ui.hp-legal .hpl-table-wrap {
    margin: 1.4em 0 1.8em; overflow: hidden;
    background: var(--hx-surface); border: 1px solid var(--hx-line); border-radius: 18px;
}
body.hp-ui.hp-legal .hpl-table { width: 100%; border-collapse: collapse; font-size: .94rem; line-height: 1.55; }
body.hp-ui.hp-legal .hpl-table th {
    padding: 12px 16px; text-align: start; background: var(--hx-surface-2);
    font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--hx-ink-3);
}
body.hp-ui.hp-legal .hpl-table td { padding: 14px 16px; vertical-align: top; border-top: 1px solid var(--hx-line); color: var(--hx-ink-2); }
body.hp-ui.hp-legal .hpl-table td:first-child { white-space: nowrap; }
body.hp-ui.hp-legal .hpl-table td:last-child { color: var(--hx-ink); font-weight: 600; }
body.hp-ui.hp-legal .hpl-prose code {
    padding: 2px 7px; border-radius: 7px; background: var(--hx-royal-soft); color: var(--hx-royal-ink);
    font-family: var(--hx-f-mono); font-size: .82em; direction: ltr; unicode-bidi: isolate;
}

body.hp-ui.hp-legal .hpl-prose a[dir="ltr"] { white-space: nowrap; unicode-bidi: isolate; }

/* ---------- Contact card ---------- */
body.hp-ui.hp-legal .hpl-contact-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Arabic ---------- */
html[lang="ar"] body.hp-ui.hp-legal :is(.hpl-toc-summary, .hpl-prose .hpl-summary-title, .hpl-table th) { letter-spacing: 0; font-size: .86rem; }
html[lang="ar"] body.hp-ui.hp-legal .hpl-toc-list a { font-size: .95rem; line-height: 1.6; }
html[lang="ar"] body.hp-ui.hp-legal .hpl-prose .hpl-summary li { line-height: 1.85; }
html[lang="ar"] body.hp-ui.hp-legal .hpl-prose h2::before { letter-spacing: .08em; }

/* ---------- Phone ---------- */
@media (max-width: 640px) {
    body.hp-ui.hp-legal .hpl-summary { padding: 18px 18px 4px; }
    body.hp-ui.hp-legal .hpl-banner .hpg-banner-meta { flex-direction: column; align-items: flex-start; gap: 8px; }
    body.hp-ui.hp-legal .hpl-banner .hpg-banner-meta > [aria-hidden="true"] { display: none; }
    body.hp-ui.hp-legal .hpl-table-wrap { background: transparent; border: 0; border-radius: 0; overflow: visible; }
    body.hp-ui.hp-legal .hpl-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    body.hp-ui.hp-legal .hpl-table, body.hp-ui.hp-legal .hpl-table tbody, body.hp-ui.hp-legal .hpl-table tr, body.hp-ui.hp-legal .hpl-table td { display: block; }
    body.hp-ui.hp-legal .hpl-table tr {
        margin-bottom: 12px; padding: 14px 16px; border-radius: 16px;
        background: var(--hx-surface); border: 1px solid var(--hx-line);
    }
    body.hp-ui.hp-legal .hpl-table td { padding: 0; border: 0; white-space: normal !important; }
    body.hp-ui.hp-legal .hpl-table td + td { margin-top: 8px; }
    body.hp-ui.hp-legal .hpl-table td:not(:first-child)::before {
        content: attr(data-label); display: block; margin-bottom: 2px;
        font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--hx-ink-3);
    }
    html[lang="ar"] body.hp-ui.hp-legal .hpl-table td::before { letter-spacing: 0; font-size: .8rem; }
    body.hp-ui.hp-legal .hpl-contact-actions .hp-btn { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(body.hp-ui.hp-legal) { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
    body.hp-ui.hp-legal :is(.hpl-toc-list a, .hpl-toc-summary svg, .hpl-anchor) { transition: none !important; }
}

@media print {
    body.hp-ui.hp-legal :is(.hpl-toc, .hpl-contact, .hpl-anchor) { display: none !important; }
    body.hp-ui.hp-legal .hpl-layout { display: block; }
}
