/**
 * =============================================================================
 * DINPROXY — Legal pages (Terms of Service / Privacy Policy)
 * =============================================================================
 * Layout, typography and the sticky section navigation, built on the shared
 * dark-glass design tokens defined in styles.css (var(--ios-*), --primary-purple,
 * --radius-*, etc.). Everything here is scoped under `body.legal-page`, so the
 * auth screens that load the same stylesheet are never affected.
 *
 * These pages inherit from styles.css: the reset, the fixed breathing backdrop
 * (body::before), the custom scrollbar, focus-visible rings and smooth scroll.
 * We override only what a long-form reading document needs: the auth flex-
 * centering, list styling, and a comfortable reading type scale.
 */

body.legal-page {
    /* Legal-specific layout tokens layered on the shared system */
    --legal-max: 1400px;        /* shell width  */
    --legal-aside: 262px;       /* section-nav column */
    --legal-gap: 60px;          /* content ↔ nav gutter */
    --legal-text: rgba(255, 255, 255, 0.82);   /* body copy — brighter than the
                                                   dim --ios-text-secondary so a
                                                   long read stays comfortable  */
    --legal-hairline: rgba(255, 255, 255, 0.08);

    /* Override the auth screens' full-viewport flex centering: a legal document
       flows from the top and scrolls. */
    display: block;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
 * Shell + top bar
 * ------------------------------------------------------------------------ */
.legal-shell {
    max-width: var(--legal-max);
    margin: 0 auto;
    padding: 30px 24px 96px;
}

.legal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 26px;
    margin-bottom: 44px;
    border-bottom: 1px solid var(--border-light);
}

.legal-brand {
    display: inline-flex;
    align-items: center;
    color: var(--ios-text-primary);
}

.legal-brand .wordmark {
    display: block;
    width: auto;
    height: 18px;
}

.legal-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ios-text-secondary);
    padding: 9px 17px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-capsule);
    transition: color var(--transition-fast),
                border-color var(--transition-fast),
                background var(--transition-fast);
}

.legal-back:hover {
    color: var(--ios-text-primary);
    border-color: rgba(147, 114, 255, 0.55);
    background: rgba(147, 114, 255, 0.09);
}

.legal-back .arrow { transition: transform var(--transition-fast); }
.legal-back:hover .arrow { transform: translateX(-3px); }

/* --------------------------------------------------------------------------
 * Two-column grid: reading column + sticky section nav
 * ------------------------------------------------------------------------ */
.legal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--legal-aside);
    gap: var(--legal-gap);
    align-items: start;
}

/* --------------------------------------------------------------------------
 * Reading column — frosted glass panel (the system's signature surface)
 * ------------------------------------------------------------------------ */
.legal-main {
    background: var(--ios-card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-card);
    padding: 46px 52px;
    box-shadow: var(--shadow-diffuse);
    -webkit-backdrop-filter: blur(30px) saturate(140%);
    backdrop-filter: blur(30px) saturate(140%);
}

.legal-header {
    margin-bottom: 8px;
}

.legal-title {
    font-size: clamp(30px, 4.4vw, 42px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.08;
    color: var(--ios-text-primary);
    margin-bottom: 16px;
}

.legal-updated {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-text-secondary);
    padding: 6px 13px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-capsule);
}

.legal-updated .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success-green);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16);
}

.legal-intro {
    margin-top: 24px;
    font-size: 18px;
    line-height: 1.75;
    color: var(--legal-text);
}

/* Sections ---------------------------------------------------------------- */
.legal-section {
    scroll-margin-top: 24px;   /* headings don't glue to the viewport top on jump */
    margin-top: 34px;
    padding-top: 32px;
    border-top: 1px solid var(--legal-hairline);
}

.legal-section:first-of-type {
    margin-top: 30px;
    padding-top: 0;
    border-top: 0;
}

.legal-section h2 {
    display: flex;
    gap: 14px;
    align-items: baseline;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.35;
    color: var(--ios-text-primary);
    margin-bottom: 14px;
}

.legal-section h2 .sec-num {
    flex: none;
    min-width: 1.5em;
    color: var(--primary-purple);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.legal-main p,
.legal-main li {
    font-size: 17px;
    line-height: 1.75;
    color: var(--legal-text);
}

.legal-main p { margin-bottom: 14px; }
.legal-main p:last-child { margin-bottom: 0; }

/* Restore list semantics (styles.css strips bullets globally) as custom
   accent dots that match the brand. */
.legal-main ul,
.legal-main ol {
    list-style: none;
    margin: 6px 0 4px;
    padding: 0;
}

.legal-main li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 10px;
}

.legal-main li:last-child { margin-bottom: 0; }

.legal-main li::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 11px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-purple);
    opacity: 0.72;
}

.legal-main a {
    color: var(--primary-purple);
    font-weight: 500;
}

.legal-main a:hover { text-decoration: underline; }

/* Bold lead-ins (used to surface the key rule of a clause, e.g. refunds). */
.legal-main strong {
    color: var(--ios-text-primary);
    font-weight: 700;
}

.legal-contact {
    margin-top: 42px;
    padding-top: 22px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--ios-text-secondary);
}

/* --------------------------------------------------------------------------
 * Sticky section navigation  ("On this page")
 * The one crafted element: it follows the scroll and tracks the active clause
 * with a purple rail that grows on the current item.
 * ------------------------------------------------------------------------ */
.legal-aside {
    position: sticky;
    top: 32px;
}

.legal-toc {
    border: 1px solid var(--border-light);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.028);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 20px 16px;
}

.legal-toc-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-text-secondary);
    margin: 0 0 14px;
    padding-left: 13px;
}

.legal-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-link {
    position: relative;
    display: flex;
    gap: 11px;
    align-items: baseline;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--ios-text-secondary);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.toc-link .n {
    flex: none;
    min-width: 1.2em;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.34);
    transition: color var(--transition-fast);
}

.toc-link:hover {
    color: var(--ios-text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.toc-link.is-active {
    color: var(--ios-text-primary);
    background: rgba(147, 114, 255, 0.12);
}

.toc-link.is-active .n { color: var(--primary-purple); }

/* The moving rail: a purple bar on the left edge that grows in on the active
   item (and shrinks away from the previous one). */
.toc-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    border-radius: 0 3px 3px 0;
    background: var(--primary-purple);
    transition: height var(--transition-normal);
}

.toc-link.is-active::before { height: 58%; }

/* --------------------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------------------ */
@media (max-width: 900px) {
    .legal-grid { grid-template-columns: 1fr; }
    .legal-aside { display: none; }          /* short docs — nav folds away */
    .legal-main { padding: 34px 26px; }
}

@media (max-width: 640px) {
    .legal-shell { padding: 22px 18px 72px; }
    .legal-topbar { margin-bottom: 30px; }
    .legal-main { padding: 28px 22px; border-radius: 22px; }
    .legal-section h2 { font-size: 18.5px; }
}

/* Honour reduced-motion: kill the global smooth scroll and rail animation. */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .toc-link::before,
    .legal-back .arrow { transition: none; }
}
