/* ==========================================================
   Meaamor — Secondary pages (legal, policy, support)
   Layers on top of home.css: reuses its tokens, nav, footer
   and motion primitives, then adds the document layout.
   ========================================================== */

/* ---------- Nav (no hero behind it, so it stays legible) ---------- */
.nav-doc .nav-inner {
    background: rgba(255, 255, 255, .78);
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
}
.nav-doc.is-scrolled .nav-inner { box-shadow: var(--shadow-md); }
.nav-links a.is-current { color: var(--brand-deep); background: var(--lilac); font-weight: 600; }

/* ---------- Reading progress ---------- */
.read-progress {
    position: fixed; inset: 0 auto auto 0; z-index: 150;
    height: 3px; width: 100%;
    transform: scaleX(var(--p, 0)); transform-origin: 0 50%;
    background: linear-gradient(90deg, var(--brand-soft), var(--brand), var(--brand-deep));
    transition: transform .15s linear;
}

/* ---------- Document hero ---------- */
.doc-hero {
    position: relative; overflow: hidden;
    padding: clamp(118px, 15vw, 172px) 0 clamp(36px, 5vw, 60px);
}
.doc-hero::before {
    content: ''; position: absolute; inset: -180px 0 auto; height: 720px; z-index: -2;
    background:
        radial-gradient(54% 62% at 30% 22%, rgba(126, 116, 173, .26), transparent 68%),
        radial-gradient(44% 54% at 86% 8%, rgba(232, 105, 125, .16), transparent 68%);
}
.doc-hero::after {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image: radial-gradient(rgba(33, 28, 48, .14) 1px, transparent 1px);
    background-size: 26px 26px;
    -webkit-mask-image: radial-gradient(70% 80% at 50% 0%, #000, transparent 72%);
    mask-image: radial-gradient(70% 80% at 50% 0%, #000, transparent 72%);
    opacity: .5;
}
.doc-hero-inner { max-width: 840px; }
.doc-hero h1 {
    font-size: clamp(36px, 5.6vw, 62px);
    line-height: 1.02;
}
.doc-hero h1 em {
    font-family: var(--serif); font-style: italic; font-weight: 400;
    letter-spacing: -.01em; color: var(--brand);
}
.doc-lede { margin-top: 20px; font-size: clamp(17px, 2vw, 20px); color: var(--ink-2); max-width: 64ch; }

.doc-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.doc-meta-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 18px; border-radius: var(--r-sm);
    background: rgba(255, 255, 255, .72);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.doc-meta-label {
    font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.doc-meta-value { font-size: 15px; font-weight: 600; color: var(--ink); }

/* ---------- Two-column document layout ---------- */
.doc-layout {
    display: grid; grid-template-columns: 236px minmax(0, 1fr);
    gap: clamp(28px, 4vw, 56px);
    align-items: start;
    padding-bottom: var(--section-y);
}
.doc-layout > * { min-width: 0; }

/* ---------- Table of contents ---------- */
.doc-aside { position: sticky; top: 92px; }
.doc-toc {
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: rgba(255, 255, 255, .6);
    padding: 6px;
}
.doc-toc > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; cursor: pointer; list-style: none;
    font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
    border-radius: var(--r-sm);
}
.doc-toc > summary::-webkit-details-marker { display: none; }
.doc-toc > summary::after {
    content: ''; flex: none; width: 8px; height: 8px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px); transition: transform .3s var(--ease-out);
}
.doc-toc[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.doc-toc > summary:hover { background: rgba(33, 28, 48, .04); color: var(--ink-2); }
.doc-toc-list {
    display: flex; flex-direction: column;
    max-height: calc(100vh - 220px); overflow-y: auto;
    padding: 4px 0 6px; margin-left: 12px;
    border-left: 1px solid var(--line);
    scrollbar-width: thin;
}
.doc-toc-list a {
    padding: 7px 12px; margin-left: -1px;
    font-size: 13.5px; line-height: 1.35; color: var(--muted);
    border-left: 2px solid transparent;
    transition: color .2s, border-color .2s;
}
.doc-toc-list a:hover { color: var(--ink); }
.doc-toc-list a.is-active { color: var(--brand-deep); font-weight: 600; border-left-color: var(--brand); }

/* ---------- Prose card ---------- */
.doc-prose {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(26px, 4vw, 56px);
    font-size: 16.5px;
}
.doc-prose > :first-child { margin-top: 0; }

.doc-prose h2 {
    font-size: clamp(24px, 2.8vw, 32px);
    letter-spacing: -.03em; line-height: 1.12;
    margin-top: 56px; padding-top: 28px;
    border-top: 1px solid var(--line);
    scroll-margin-top: 96px;
}
.doc-prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.doc-prose h3 {
    font-size: 18px; font-weight: 600; letter-spacing: -.015em;
    color: var(--brand-deep);
    margin-top: 34px; scroll-margin-top: 96px;
}
.doc-prose h4 { font-size: 16px; font-weight: 600; margin-top: 24px; }

.doc-prose p { margin-top: 15px; color: var(--ink-2); line-height: 1.78; }
.doc-prose strong { color: var(--ink); font-weight: 600; }
.doc-prose em { font-style: italic; }
.doc-prose a {
    color: var(--brand-deep); font-weight: 600;
    text-decoration: underline; text-decoration-color: rgba(126, 116, 173, .4);
    text-underline-offset: 3px; transition: text-decoration-color .2s;
}
.doc-prose a:hover { text-decoration-color: var(--brand); }

.doc-prose ul, .doc-prose ol { display: grid; gap: 10px; margin-top: 16px; padding-left: 4px; }
.doc-prose li { position: relative; padding-left: 28px; color: var(--ink-2); line-height: 1.7; }
.doc-prose ul > li::before {
    content: ''; position: absolute; left: 4px; top: .62em;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--brand-soft);
}
.doc-prose ol { counter-reset: doc-ol; }
.doc-prose ol > li { counter-increment: doc-ol; }
.doc-prose ol > li::before {
    content: counter(doc-ol);
    position: absolute; left: 0; top: .1em;
    width: 20px; height: 20px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--lilac); color: var(--brand-deep);
    font-size: 11px; font-weight: 700;
}
.doc-prose li > ul, .doc-prose li > ol { margin-top: 10px; }

.doc-prose hr {
    border: 0; height: 1px; margin: 40px 0 0;
    background: linear-gradient(90deg, var(--line-strong), transparent);
}
/* A rule straight before a heading would double the heading's own divider */
.doc-prose hr + h2 { margin-top: 32px; padding-top: 0; border-top: 0; }
.doc-prose hr:has(+ h2) { display: none; }

.doc-prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .88em; padding: 2px 7px; border-radius: 7px;
    background: var(--lilac); color: var(--brand-deep);
}

.doc-prose blockquote {
    margin-top: 20px; padding: 18px 22px;
    border-left: 3px solid var(--brand-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--lilac);
}
.doc-prose blockquote p { margin-top: 0; color: var(--ink); }

/* Tables scroll inside their own box on narrow screens */
.doc-table-wrap { overflow-x: auto; margin-top: 22px; border-radius: var(--r-md); border: 1px solid var(--line); }
.doc-prose table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 460px; }
.doc-prose thead th {
    text-align: left; padding: 14px 18px; white-space: nowrap;
    background: var(--lilac); color: var(--brand-deep);
    font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.doc-prose tbody td { padding: 14px 18px; border-top: 1px solid var(--line); color: var(--ink-2); vertical-align: top; }
.doc-prose tbody tr:nth-child(even) { background: rgba(126, 116, 173, .035); }

/* ---------- Callout / contact card ---------- */
.doc-callout {
    margin-top: 28px; padding: 24px 26px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--lilac), var(--blush));
    border: 1px solid var(--line);
}
.doc-callout h3 { margin-top: 0; color: var(--ink); }
.doc-callout p { color: var(--ink-2); }

/* ---------- Support page cards ---------- */
.support-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 28px; }
.support-card {
    padding: 24px; border-radius: var(--r-md);
    background: var(--surface); border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.support-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.support-icon {
    width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center; margin-bottom: 16px;
    background: var(--lilac); color: var(--brand-deep);
}
.support-icon svg { width: 22px; height: 22px; }
.support-card h3 { margin-top: 0; color: var(--ink); font-size: 18px; }
.support-card p { margin-top: 10px; font-size: 15.5px; color: var(--ink-2); }
.support-card .support-meta { margin-top: 14px; font-size: 13px; color: var(--muted); }
.support-card a {
    color: var(--brand-deep); font-weight: 600;
    text-decoration: underline; text-decoration-color: rgba(126, 116, 173, .4);
    text-underline-offset: 3px; transition: text-decoration-color .2s;
}
.support-card a:hover { text-decoration-color: var(--brand); }
.support-card .tick-list { margin-top: 14px; }
.support-card .tick-list li { font-size: 15px; }

.support-hero-card {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px;
    margin-top: 28px; padding: clamp(24px, 3vw, 36px);
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--night), var(--night-2));
    color: #fff;
    box-shadow: var(--shadow-lg);
}
.support-hero-card h2 { color: #fff; font-size: clamp(24px, 3vw, 34px); }
.support-hero-card p { margin-top: 10px; color: rgba(255, 255, 255, .72); }

/* ---------- Numbered policy sections (CSAE) ---------- */
.doc-section { position: relative; scroll-margin-top: 96px; }
.doc-section + .doc-section { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.doc-section-number {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px; border-radius: 12px; margin-bottom: 14px;
    background: var(--lilac); color: var(--brand-deep);
    font-size: 14px; font-weight: 700;
}
.doc-section > h2 { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- Document footer grid (CSAE sign-off) ---------- */
.doc-signoff {
    margin-top: 40px; padding: clamp(22px, 3vw, 32px);
    border-radius: var(--r-md);
    background: var(--bg); border: 1px solid var(--line);
}
.doc-signoff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; }
.doc-signoff-item { display: flex; flex-direction: column; gap: 4px; }
.doc-signoff-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.doc-signoff-value { font-size: 15px; font-weight: 600; color: var(--ink); }

/* ---------- Related pages strip ---------- */
.doc-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 32px; }
.doc-related a {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 22px; border-radius: var(--r-md);
    background: var(--surface); border: 1px solid var(--line);
    font-weight: 600; box-shadow: var(--shadow-sm);
    transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out), border-color .3s;
}
.doc-related a:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.doc-related svg { flex: none; width: 16px; height: 16px; color: var(--brand); transition: transform .3s var(--ease-out); }
.doc-related a:hover svg { transform: translateX(4px); }
.doc-related small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- 404 ---------- */
.error-path {
    margin-top: 22px; font-size: 14px; color: var(--muted);
}
.error-path code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .92em; padding: 3px 9px; margin-left: 4px;
    border-radius: 8px; background: var(--lilac); color: var(--brand-deep);
    overflow-wrap: anywhere;
}
.error-help {
    margin-top: 32px; font-size: 15px; color: var(--ink-2);
}
.error-help a {
    color: var(--brand-deep); font-weight: 600;
    text-decoration: underline; text-decoration-color: rgba(126, 116, 173, .4);
    text-underline-offset: 3px; transition: text-decoration-color .2s;
}
.error-help a:hover { text-decoration-color: var(--brand); }

/* ---------- Back to top ---------- */
.to-top {
    position: fixed; right: clamp(16px, 3vw, 28px); bottom: clamp(16px, 3vw, 28px); z-index: 90;
    width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
    display: grid; place-items: center; cursor: pointer;
    background: rgba(255, 255, 255, .84); color: var(--ink);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none;
    transition: opacity .3s var(--ease-out), transform .4s var(--ease-spring), background .2s;
}
.to-top.is-in { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: #fff; transform: translateY(-2px); }
.to-top svg { width: 18px; height: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    /* minmax(0,1fr), not 1fr: an auto minimum lets the widest table push the
       whole column past the viewport instead of scrolling inside its wrapper */
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
    .doc-aside { position: static; top: auto; }
    .doc-toc-list { max-height: 50vh; }
}

@media (max-width: 860px) {
    /* home.css hides nav links on mobile; doc pages need them to move around */
    .nav-doc .nav-links { display: flex; gap: 0; }
    .nav-doc .nav-links a { padding: 8px 10px; font-size: 14px; }
    .nav-doc .nav-download { display: none; }
}

@media (max-width: 600px) {
    .nav-doc .nav-inner { padding: 8px 10px; }
    .nav-doc .nav-logo span { display: none; }
    .nav-doc .nav-links a { padding: 8px; font-size: 13px; }
    .doc-meta-item { flex: 1 1 140px; }
    .support-hero-card { flex-direction: column; align-items: flex-start; }
}

/* ---------- Print ---------- */
@media print {
    .nav, .to-top, .read-progress, .doc-aside, .footer, .doc-related, .skip-link { display: none !important; }
    body { background: #fff; font-size: 11pt; }
    .doc-hero { padding: 0 0 18pt; }
    .doc-hero::before, .doc-hero::after { display: none; }
    .doc-layout { display: block; padding-bottom: 0; }
    .doc-prose { border: 0; box-shadow: none; padding: 0; }
    .doc-prose h2 { break-after: avoid; }
    .doc-prose a { color: inherit; text-decoration: none; }
}
