/* whitepaper.css — Long-read reading page: equal-width outer frame + independent reading panel + light/dark
   theme + font-size control. Layered over style.css tokens. Body text is non-selectable on the reading panel
   (a reading + annotation surface choice; copyright is handled via the © watermark, copyright notice, and
   approved-reader provenance log, not by blocking copy). */

/* === Light/dark theme (active only when this file loads on whitepaper pages; overrides style.css :root tokens) === */
html[data-theme="dark"] {
    --bg-color: #0B1320;
    /* Brand deep navy as dark background */
    --bg-color-alt: #151D2B;
    /* Reading panel surface */
    --text-main: #ECE7DA;
    /* Warm white, echoes the oatmeal palette */
    --text-muted: #9AA4B2;
    --accent-white: #FFFFFF;
    --border-subtle: rgba(236, 231, 218, 0.14);
    --glass-bg: rgba(11, 19, 32, 0.85);
    --glass-border: rgba(236, 231, 218, 0.10);
}

.wp-body {
    padding-top: 96px;
    /* Clear the fixed nav */
}

/* === Whitepaper landing / apply page (standard site look, no reader theme toggle) === */
.page-header.whitepaper .page-header-bg {
    background-image: url('../assets/header_whitepaper.svg');
}

/* Chapter table-of-contents */
.wp-toc {
    margin: 0 0 56px;
}

.wp-toc-group-label {
    font-family: var(--font-heading);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin: 0 0 16px;
}

.wp-toc-item {
    display: flex;
    align-items: baseline;
    gap: 18px;
    padding: 16px 0;
    border-top: 1px solid var(--border-subtle);
    text-decoration: none;
}

.wp-toc-item:last-of-type {
    border-bottom: 1px solid var(--border-subtle);
}

.wp-toc-num {
    font-family: var(--font-heading);
    font-size: 14px;
    color: var(--text-muted);
    min-width: 2.2em;
}

.wp-toc-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 300;
    color: var(--text-main);
}

a.wp-toc-item:hover .wp-toc-title {
    color: var(--accent-white);
}

/* Status badge (open vs locked, visually paired) */
.wp-toc-open {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-muted);
}

a.wp-toc-item:hover .wp-toc-open {
    color: var(--accent-white);
}

/* Locked (gated) chapters: not clickable, dimmed + lock badge */
.wp-toc-item.locked {
    cursor: default;
}

.wp-toc-item.locked .wp-toc-title,
.wp-toc-item.locked .wp-toc-num {
    color: var(--text-muted);
    opacity: 0.6;
}

.wp-toc-lock {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-muted);
}

.wp-gate-note {
    margin: 18px 0 0;
    font-size: 12px;            /* note / fine-print tier; matches .wp-gdpr and footer disclaimer */
    color: var(--text-muted);
    line-height: 1.7;
    max-width: none;            /* override global p { max-width:600px } so the note spans the toc width */
}

.wp-gate-note::before {
    content: "\2139";            /* U+2139 INFORMATION SOURCE; plain typography (not emoji) for cross-platform consistency */
    margin-right: 6px;
    font-weight: 600;
    color: var(--text-main);     /* slightly darker than the muted body to read as an icon marker */
}

/* Apply form button hover: the global .btn-primary ::before slide fails to render inside the wp-apply card's
   stacking context, leaving only the text-color change (which makes hover look faded). Swap to a direct
   solid background on hover for the intended dark fill + light text look. */
.wp-apply .btn-primary::before,
.wp-apply .btn-primary:hover::before {
    display: none;
}

.wp-apply .btn-primary:hover {
    background: var(--text-main);
    color: var(--bg-color);
    border-color: var(--text-main);
}

/* Apply form textarea: distinct from input (bottom-line-only) style — full border on all sides so the edges
   are visible. Manual resize is disabled; JS auto-grows the height to match the wrapped line count. */
.wp-apply textarea {
    border: 1px solid var(--border-subtle);
    border-radius: 2px;
    padding: 12px;
    min-height: 84px;
    resize: none;
    overflow: hidden;
}

.wp-apply textarea:focus {
    border-color: var(--text-muted);
}

/* Apply form card */
.wp-apply {
    max-width: 560px;
    margin: 0 auto;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 40px clamp(20px, 5vw, 48px);
    background: var(--bg-color-alt);
}

.wp-apply h3 {
    font-weight: 300;
    margin: 0 0 8px;
}

.wp-apply .wp-apply-intro {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 32px;
    line-height: 1.7;
}

.cf-turnstile {
    margin-bottom: 24px;
}

.wp-gdpr {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 20px 0 0;
}

.wp-form-status {
    font-size: 14px;
    margin-top: 18px;
}

.wp-form-status.ok,
.wp-form-status.err {
    padding: 10px 14px;
    border-radius: 4px;
    color: #fff;
    font-weight: 400;
}

.wp-form-status.ok { background: #4caf50; }
.wp-form-status.err { background: #c1554d; }

/* === Independent reading panel inside the equal-width outer frame (container same as site-wide 1200) === */
.wp-main {
    padding-top: 28px;
    padding-bottom: 96px;
}

.wp-reader {
    /* Equal-width outer frame: fills the container. Acts as a "reading desk" (solid) floating above the
       homepage particle animation. Selection disabled — this is a reading + annotation surface. */
    position: relative;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    background: var(--bg-color-alt);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    box-shadow: 0 2px 60px rgba(11, 19, 32, 0.10);
    padding: 64px clamp(20px, 5vw, 72px);
}

/* Subtle © watermark INSIDE the desk (copyright marking / provenance): only on the reading panel, never on
   the outer animation area. Two-layer multi-background: the second layer uses the same SVG at half opacity,
   offset by 150px to create a light/dark river-pattern texture. */
.wp-reader::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-repeat: repeat;
    background-image:
        url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='300'%20height='150'%3E%3Ctext%20x='10'%20y='80'%20transform='rotate(-28%20150%2075)'%20font-family='sans-serif'%20font-size='13'%20fill='%230B1320'%20fill-opacity='0.032'%3E%C2%A9%202026%20AENVIX%20LLC%3C/text%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='300'%20height='150'%3E%3Ctext%20x='10'%20y='80'%20transform='rotate(-28%20150%2075)'%20font-family='sans-serif'%20font-size='13'%20fill='%230B1320'%20fill-opacity='0.016'%3E%C2%A9%202026%20AENVIX%20LLC%3C/text%3E%3C/svg%3E");
    background-position: 0 0, 150px 0;
}

html[data-theme="dark"] .wp-reader::after {
    background-image:
        url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='300'%20height='150'%3E%3Ctext%20x='10'%20y='80'%20transform='rotate(-28%20150%2075)'%20font-family='sans-serif'%20font-size='13'%20fill='%23ECE7DA'%20fill-opacity='0.042'%3E%C2%A9%202026%20AENVIX%20LLC%3C/text%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='300'%20height='150'%3E%3Ctext%20x='10'%20y='80'%20transform='rotate(-28%20150%2075)'%20font-family='sans-serif'%20font-size='13'%20fill='%23ECE7DA'%20fill-opacity='0.021'%3E%C2%A9%202026%20AENVIX%20LLC%3C/text%3E%3C/svg%3E");
    background-position: 0 0, 150px 0;
}

/* === Reading typography (font-size driven by --wp-fs; children use em to reflow with it) === */
.wp-content {
    /* Independent reading column inside the frame: comfortable measure, centered (outer is equal-width,
       inner text stays readable). */
    max-width: 720px;
    margin: 0 auto;
    font-size: var(--wp-fs, 18px);
    line-height: 1.78;
    color: var(--text-main);
}

.wp-content h1 { font-size: 1.95em; line-height: 1.18; margin: 0 0 0.7em; font-weight: 300; }
.wp-content h2 { font-size: 1.45em; margin: 1.8em 0 0.5em; font-weight: 300; }
.wp-content h3 { font-size: 1.15em; margin: 1.4em 0 0.4em; font-weight: 400; }
.wp-content p  { font-size: 1em; max-width: none; margin: 0 0 1em; font-weight: 300; color: var(--text-main); }
.wp-content strong { font-weight: 500; }
.wp-content em { font-style: italic; }
.wp-content hr { border: none; border-top: 1px solid var(--border-subtle); margin: 2.2em 0; }

.wp-content blockquote {
    margin: 1.6em 0;
    padding: 0.9em 1.3em;
    background: var(--bg-color);
    border-left: 3px solid var(--text-muted);
    border-radius: 2px;
}

.wp-content blockquote p { font-size: 0.94em; margin: 0 0 0.5em; }
.wp-content blockquote p:last-child { margin: 0; }
.wp-content ul, .wp-content ol { margin: 0 0 1em 1.4em; }
.wp-content li { font-size: 1em; margin: 0.35em 0; font-weight: 300; color: var(--text-main); }
.wp-content a { color: var(--text-main); border-bottom: 1px solid var(--border-subtle); }

/* Tables: with cell borders; one notch smaller than body text (0.85em, relative to --wp-fs so A-/A/A+ scales it). */
.wp-content table {
    width: 100%;
    margin: 1.6em 0;
    border-collapse: collapse;
    font-size: 0.85em;
    line-height: 1.6;
}

.wp-content th,
.wp-content td {
    border: 1px solid var(--border-subtle);
    padding: 0.6em 0.8em;
    text-align: left;
    vertical-align: top;
    font-weight: 300;
    color: var(--text-main);
}

.wp-content thead th {
    font-family: var(--font-heading);
    font-weight: 500;
    background: var(--bg-color);
}

.wp-content tbody tr:nth-child(even) td {
    background: rgba(127, 127, 127, 0.04);
}

/* Paragraphs inside table cells: don't stack body margin/font-size on top of the cell padding. */
.wp-content td p,
.wp-content th p { font-size: 1em; margin: 0; }

.wp-foot-nav {
    max-width: 720px;
    margin: 32px auto 0;
    padding-top: 22px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.wp-foot-nav a {
    font-family: var(--font-heading);
    font-size: 14px;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* === Floating reader controls: theme + font size (A- A A+) === */
.wp-controls {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 6px 8px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(11, 19, 32, 0.10);
}

.wp-controls button {
    font-family: var(--font-heading);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 999px;
    padding: 6px 11px;
    line-height: 1;
    transition: var(--transition-smooth);
}

.wp-controls button:hover {
    color: var(--accent-white);
    background: var(--border-subtle);
}

#wp-fs-dec { font-size: 12px; }
#wp-fs-reset { font-size: 15px; }
#wp-fs-inc { font-size: 18px; }
#wp-theme { font-size: 16px; }

/* === Outer background: reuses the homepage particle animation (#bg-canvas + main.js). Sits behind content;
   hidden in dark mode (night reading wants quiet, and the particle palette is tuned for the light theme). === */
#bg-canvas {
    z-index: -1;
}

html[data-theme="dark"] #bg-canvas {
    display: none;
}

/* === Approved-reader CTA (the one exception in the zone-pure design; Worker injects it on /whitepaper/
   between the open and full sections) ===
   max-width:none overrides the global p { max-width:600px } so the <p> spans the parent's full width and the
   button can center on the container axis. Margin: top 0 (borrows the .wp-toc margin-bottom:56px above to
   avoid stacking to 88px), bottom 56 (matches the .wp-toc rhythm). */
.wp-cta-continue {
    max-width: none;
    margin: 0 0 56px;
}

.wp-cta-continue .btn-primary {
    display: block;
    width: fit-content;
    margin: 0 auto;
}

/* === Reader email watermark (3.2, the core provenance mechanism; only injected into gated pages by
   gateFull via HTMLRewriter inside .wp-reader). Position absolute + .wp-reader's position:relative make
   the watermark fill only the reading panel, not the outer animation area (same boundary as the © watermark
   in .wp-reader::after). Tile matches ::after at 300x150; email rotated +28° (© is -28°), forming an X-style
   shirt-cross-hatch pattern. */
.wm-user {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    background-repeat: repeat;
}

/* Light theme uses the dark-text SVG; dark theme uses the light-text SVG. Toggled by data-theme. */
html:not([data-theme="dark"]) .wm-user-dark { display: none; }
html[data-theme="dark"] .wm-user-light { display: none; }

/* Narrow screens: panel hugs the edge, controls shrink a bit. */
@media (max-width: 640px) {
    /* Smaller default reading size on phones (a step down from the 18px desktop default; 16.5 is a real
       A-/A/A+ step so the controls stay aligned). Set on <html> — the same element the reader JS writes a
       saved preference to as an inline style — so a user's chosen size (inline, higher priority) still
       overrides this, while first-time visitors get the smaller phone default. */
    html { --wp-fs: 15px; }
    .wp-reader { padding: 40px 20px; border-radius: 0; }
    .wp-controls { bottom: 14px; right: 14px; }
}
