/*
 * Legal pages — newsroom-grade editorial layout.
 *   - Breadcrumb above title
 *   - Hero header with eyebrow, large serif title, meta row
 *   - Two-column body: sticky TOC sidebar (lg+) + max-width article
 *   - Editorial typography (Georgia serif for headings, system for body)
 *   - Section permalinks (hover #)
 *   - Sticky back-to-top button
 *   - Print-optimised stylesheet
 *   - Dark-mode variant
 */

/* ============================================================
   Shell
   ============================================================ */

.legal-page {
    padding: 0 0 80px;
    background: #ffffff;
    color: #0f172a;
    min-height: 70vh;
    position: relative;
}

.legal-page__container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   Breadcrumb
   ============================================================ */

.legal-page__breadcrumb {
    padding: 18px 0 8px;
    font-size: 0.85rem;
}

.legal-page__breadcrumb ol {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: #64748b;
}

.legal-page__breadcrumb li {
    display: inline-flex;
    align-items: center;
}

.legal-page__breadcrumb li + li::before {
    content: '›';
    margin: 0 8px;
    color: #cbd5e1;
}

.legal-page__breadcrumb a {
    color: #64748b;
    text-decoration: none;
}

.legal-page__breadcrumb a:hover,
.legal-page__breadcrumb a:focus-visible {
    color: #1d4ed8;
    text-decoration: underline;
    outline: none;
}

.legal-page__breadcrumb [aria-current="page"] {
    color: #0f172a;
    font-weight: 600;
}

/* ============================================================
   Header
   ============================================================ */

.legal-page__header {
    padding: 16px 0 28px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 40px;
}

.legal-page__eyebrow {
    margin: 0 0 10px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #dc2626;
}

.legal-page__title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.12;
    margin: 0 0 18px;
    color: #0f172a;
    letter-spacing: -0.02em;
}

@media (max-width: 640px) {
    .legal-page__title {
        font-size: 2rem;
    }
}

.legal-page__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    font-size: 0.85rem;
    color: #475569;
    align-items: center;
}

.legal-page__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legal-page__meta-item svg {
    color: #94a3b8;
    flex-shrink: 0;
}

.legal-page__meta-item--desk {
    font-style: italic;
    color: #64748b;
}

.legal-page__meta-item time {
    font-weight: 600;
    color: #0f172a;
}

.legal-page__pending {
    display: inline-flex;
    align-items: center;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: help;
}

/* ============================================================
   Body — two-column layout
   ============================================================ */

.legal-page__body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 48px;
}

@media (min-width: 1024px) {
    .legal-page__body {
        grid-template-columns: 240px minmax(0, 1fr);
        gap: 64px;
    }
}

/* ---------- TOC sidebar ---------- */

.legal-page__toc {
    display: none;
}

@media (min-width: 1024px) {
    .legal-page__toc {
        display: block;
    }
}

.legal-page__toc-inner {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding-right: 8px;
    border-left: 1px solid #e5e7eb;
    padding-left: 20px;
}

.legal-page__toc-label {
    margin: 0 0 14px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #94a3b8;
}

.legal-page__toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: tocnum;
}

.legal-page__toc-list li {
    counter-increment: tocnum;
    margin-bottom: 0;
}

.legal-page__toc-list a {
    display: block;
    padding: 8px 0 8px 28px;
    font-size: 0.88rem;
    line-height: 1.4;
    color: #475569;
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -22px;
    padding-left: 22px;
    transition: color 120ms ease, border-color 120ms ease;
    position: relative;
}

.legal-page__toc-list a::before {
    content: counter(tocnum, decimal-leading-zero);
    position: absolute;
    left: 22px;
    top: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #cbd5e1;
    letter-spacing: 0.05em;
    width: 24px;
}

.legal-page__toc-list a {
    padding-left: 50px;
}

.legal-page__toc-list a:hover,
.legal-page__toc-list a:focus-visible {
    color: #0f172a;
    outline: none;
}

.legal-page__toc-list a.is-active {
    color: #1d4ed8;
    border-left-color: #1d4ed8;
    font-weight: 600;
}

.legal-page__toc-list a.is-active::before {
    color: #1d4ed8;
}

/* ---------- Article content ---------- */

.legal-page__article {
    max-width: 720px;
    font-size: 1.05rem;
    line-height: 1.75;
    color: #1f2937;
}

.legal-page__article > *:first-child {
    margin-top: 0;
}

.legal-page__article p {
    margin: 0 0 18px;
}

.legal-page__article .legal-page__lede {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.3rem;
    line-height: 1.55;
    color: #0f172a;
    margin: 0 0 36px;
    padding: 0 0 24px;
    border-bottom: 1px solid #e5e7eb;
}

.legal-page__article section {
    margin: 36px 0;
    scroll-margin-top: 90px;
}

.legal-page__article h2 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 16px;
    color: #0f172a;
    letter-spacing: -0.01em;
    scroll-margin-top: 90px;
    position: relative;
}

.legal-page__article h3 {
    font-size: 1.12rem;
    font-weight: 700;
    margin: 26px 0 10px;
    color: #1f2937;
}

.legal-page__article ul,
.legal-page__article ol {
    margin: 0 0 18px;
    padding-left: 22px;
}

.legal-page__article li {
    margin-bottom: 10px;
}

.legal-page__article li::marker {
    color: #1d4ed8;
}

.legal-page__article code {
    background: #f1f5f9;
    color: #b91c1c;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.legal-page__article a {
    color: #1d4ed8;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.legal-page__article a:hover,
.legal-page__article a:focus-visible {
    color: #1e40af;
    text-decoration-thickness: 2px;
    outline: none;
}

/* Hover-revealed permalink # marker before each h2 */
.legal-page__permalink {
    position: absolute;
    left: -28px;
    color: #cbd5e1;
    font-weight: 400;
    text-decoration: none;
    opacity: 0;
    transition: opacity 120ms ease;
}

.legal-page__article h2:hover .legal-page__permalink,
.legal-page__permalink:focus-visible {
    opacity: 1;
    text-decoration: none;
    outline: none;
}

.legal-page__permalink:hover {
    color: #1d4ed8;
}

@media (max-width: 1023px) {
    /* On mobile the permalink would offset off-screen — show it inline as
       a small chip after the heading instead. */
    .legal-page__permalink {
        position: static;
        opacity: 1;
        font-size: 0.7em;
        margin-right: 8px;
        color: #94a3b8;
    }
}

/* Address block (Grievance Officer / newsroom contact) */
.legal-page__address {
    background: #f9fafb;
    border-left: 3px solid #1d4ed8;
    padding: 16px 20px;
    margin: 16px 0;
    font-style: normal;
    line-height: 1.7;
    border-radius: 0 6px 6px 0;
}

/* DPDP anchor block — visually highlighted */
.legal-page__anchor {
    background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 28px 32px;
    margin: 40px 0;
}

@media (max-width: 600px) {
    .legal-page__anchor {
        padding: 22px 20px;
    }
}

/* Pending-block — visible signal for unconfigured legal copy */
.legal-page__pending-block {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.6;
}

.legal-page__pending-block strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
}

.legal-page__close {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.95rem;
    color: #4b5563;
    font-style: italic;
}

.legal-page__article-foot {
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.88rem;
    color: #64748b;
    line-height: 1.6;
}

/* ============================================================
   Related-policies footer
   ============================================================ */

.legal-page__related {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid #e5e7eb;
}

.legal-page__related h2 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 18px;
    color: #0f172a;
}

.legal-page__related ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.legal-page__related a {
    display: block;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
}

.legal-page__related a:hover,
.legal-page__related a:focus-visible {
    background: #eff6ff;
    border-color: #1d4ed8;
    outline: none;
}

.legal-page__related a:active {
    transform: translateY(1px);
}

/* ============================================================
   Back-to-top sticky button
   ============================================================ */

.legal-page__top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1070;
    width: 44px;
    height: 44px;
    border: none;
    background: #0f172a;
    color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 6px 20px -6px rgba(15, 23, 42, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 120ms ease, transform 120ms ease, opacity 200ms ease;
}

.legal-page__top:hover,
.legal-page__top:focus-visible {
    background: #1e293b;
    transform: translateY(-2px);
    outline: 2px solid #1d4ed8;
    outline-offset: 2px;
}

.legal-page__top[hidden] {
    display: none;
}

/* ============================================================
   Dark mode
   ============================================================ */

@media (prefers-color-scheme: dark) {
    .legal-page {
        background: #0f172a;
        color: #f1f5f9;
    }
    .legal-page__breadcrumb,
    .legal-page__breadcrumb a {
        color: #94a3b8;
    }
    .legal-page__breadcrumb [aria-current="page"] {
        color: #f1f5f9;
    }
    .legal-page__breadcrumb li + li::before {
        color: #475569;
    }
    .legal-page__header,
    .legal-page__related,
    .legal-page__close,
    .legal-page__article .legal-page__lede,
    .legal-page__article-foot {
        border-color: rgba(255, 255, 255, 0.08);
    }
    .legal-page__title,
    .legal-page__article h2 {
        color: #f9fafb;
    }
    .legal-page__article,
    .legal-page__article h3 {
        color: #e2e8f0;
    }
    .legal-page__article .legal-page__lede {
        color: #f1f5f9;
    }
    .legal-page__meta,
    .legal-page__meta-item--desk,
    .legal-page__article-foot {
        color: #94a3b8;
    }
    .legal-page__meta-item time {
        color: #f1f5f9;
    }
    .legal-page__toc-inner {
        border-color: rgba(255, 255, 255, 0.08);
    }
    .legal-page__toc-label {
        color: #64748b;
    }
    .legal-page__toc-list a {
        color: #94a3b8;
    }
    .legal-page__toc-list a:hover {
        color: #f1f5f9;
    }
    .legal-page__toc-list a.is-active {
        color: #93c5fd;
        border-left-color: #93c5fd;
    }
    .legal-page__anchor {
        background: linear-gradient(180deg, rgba(29, 78, 216, 0.08) 0%, rgba(15, 23, 42, 0) 100%);
        border-color: rgba(96, 165, 250, 0.3);
    }
    .legal-page__address {
        background: rgba(255, 255, 255, 0.04);
        border-left-color: #60a5fa;
    }
    .legal-page__article code {
        background: #1f2937;
        color: #fca5a5;
    }
    .legal-page__article a {
        color: #93c5fd;
    }
    .legal-page__article a:hover {
        color: #bfdbfe;
    }
    .legal-page__related h2 {
        color: #f9fafb;
    }
    .legal-page__related a {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.1);
        color: #93c5fd;
    }
    .legal-page__related a:hover {
        background: rgba(29, 78, 216, 0.15);
        border-color: #60a5fa;
    }
    .legal-page__top {
        background: #f1f5f9;
        color: #0f172a;
    }
    .legal-page__top:hover {
        background: #e2e8f0;
    }
}

/* ============================================================
   Print stylesheet — clean printable legal policy
   ============================================================ */

@media print {
    .legal-page {
        padding: 0;
        color: #000;
        background: #fff;
    }
    .legal-page__breadcrumb,
    .legal-page__toc,
    .legal-page__top,
    .legal-page__related,
    .legal-page__pending {
        display: none !important;
    }
    .legal-page__body {
        grid-template-columns: 1fr !important;
    }
    .legal-page__article {
        max-width: 100%;
        font-size: 11pt;
        color: #000;
    }
    .legal-page__title {
        font-size: 24pt;
        color: #000;
    }
    .legal-page__article h2 {
        font-size: 14pt;
        page-break-after: avoid;
        color: #000;
    }
    .legal-page__article h3 {
        font-size: 12pt;
        color: #000;
    }
    .legal-page__article a {
        color: #000;
        text-decoration: underline;
    }
    .legal-page__article a[href^="http"]::after,
    .legal-page__article a[href^="/"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #555;
    }
    .legal-page__article a[href^="#"]::after,
    .legal-page__article a[href^="mailto:"]::after,
    .legal-page__article a[href^="tel:"]::after {
        content: "";
    }
    .legal-page__permalink {
        display: none !important;
    }
    .legal-page__anchor {
        background: none;
        border: 1px solid #000;
    }
}

/* ============================================================
   /policies hub
   ============================================================ */

.policy-hub__lede {
    margin: 8px 0 0;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #475569;
    max-width: 720px;
}

.policy-hub__sections {
    display: flex;
    flex-direction: column;
    gap: 56px;
    margin-top: 40px;
}

.policy-hub__section-head {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0f172a;
}

.policy-hub__section-eyebrow {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #dc2626;
}

.policy-hub__section-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.policy-hub__grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.policy-hub__card {
    margin: 0;
    padding: 0;
}

.policy-hub__card-link {
    display: block;
    height: 100%;
    padding: 18px 20px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 80ms ease;
}

.policy-hub__card-link:hover,
.policy-hub__card-link:focus-visible {
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px -4px rgba(29, 78, 216, 0.18);
    outline: none;
}

.policy-hub__card-link:active {
    transform: translateY(1px);
}

.policy-hub__card--featured .policy-hub__card-link {
    border-color: #1d4ed8;
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.policy-hub__card-title {
    margin: 0 0 8px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.3;
    color: #0f172a;
}

.policy-hub__card-summary {
    margin: 0 0 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #475569;
}

.policy-hub__card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 0.74rem;
    color: #64748b;
}

.policy-hub__card-pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.policy-hub__card-approved {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Counsel-reviewed pill on the single-page header (mirrors __pending). */
.legal-page__approved {
    display: inline-flex;
    align-items: center;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@media (prefers-color-scheme: dark) {
    .policy-hub__lede { color: #cbd5e1; }
    .policy-hub__section-head { border-bottom-color: rgba(255,255,255,0.4); }
    .policy-hub__section-title { color: #f9fafb; }
    .policy-hub__card-link {
        background: #1f2937;
        border-color: rgba(255, 255, 255, 0.08);
        color: #e5e7eb;
    }
    .policy-hub__card-link:hover {
        border-color: #60a5fa;
    }
    .policy-hub__card-title { color: #f9fafb; }
    .policy-hub__card-summary { color: #cbd5e1; }
    .policy-hub__card-meta { color: #94a3b8; }
    .policy-hub__card--featured .policy-hub__card-link {
        background: linear-gradient(135deg, #1f2937 0%, rgba(29, 78, 216, 0.12) 100%);
    }
}

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .legal-page__related a,
    .legal-page__top,
    .legal-page__article a {
        transition: none;
    }
}
