/* ============================================
   The Lux Particle — Reader
   ============================================ */

:root {
    --bg: #0a0a0a;
    --bg-elevated: #111111;
    --border: #1f1f1f;
    --border-hover: #333333;
    --text: #e4e4e7;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --accent: #f59e0b;
    --accent-dim: rgba(245, 158, 11, 0.12);
    --accent-glow: rgba(245, 158, 11, 0.25);
    --sans: 'JetBrains Mono', 'SF Mono', monospace;
    --serif: 'Lora', 'Georgia', serif;
    --prose-max: 42rem;
    --header-h: 56px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.lux-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: calc(var(--prose-max) + 96px);
    margin: 0 auto;
    padding: 0 24px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    transition: color 0.2s var(--ease);
    flex-shrink: 0;
}

.back-link:hover {
    color: var(--accent);
}

.back-link .hex {
    opacity: 0.7;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.action-btn {
    font-family: var(--sans);
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-2);
    cursor: pointer;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
    white-space: nowrap;
}

.action-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.action-btn-accent {
    background: var(--accent-dim);
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--accent);
}

.action-btn-accent:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--accent);
    color: #fbbf24;
}

.action-btn.success {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.4);
}

/* --- Reader --- */
.reader {
    flex: 1;
    max-width: calc(var(--prose-max) + 96px);
    margin: 0 auto;
    padding: 48px 24px 80px;
    width: 100%;
}

.title-block {
    text-align: center;
    margin-bottom: 56px;
    padding-bottom: 48px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.title-block::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 1px;
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.label {
    font-family: var(--sans);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent);
    margin-bottom: 16px;
}

.title-block h1 {
    font-family: var(--serif);
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 12px;
}

.subtitle {
    font-family: var(--serif);
    font-size: 1rem;
    font-style: italic;
    color: var(--text-3);
}

/* --- Prose --- */
.prose {
    font-family: var(--serif);
    font-size: clamp(1.05rem, 2.5vw, 1.15rem);
    line-height: 1.85;
    color: var(--text);
    max-width: var(--prose-max);
    margin-left: auto;
    margin-right: auto;
    hyphens: none !important;
    -webkit-hyphens: none !important;
    -moz-hyphens: none !important;
    font-optical-sizing: none;
    text-wrap: wrap;
}

.prose,
.prose * {
    hyphens: none !important;
    -webkit-hyphens: none !important;
    -moz-hyphens: none !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

.prose > p,
.prose p {
    margin-bottom: 1.35em;
    text-align: left;
}

.prose > p:last-child,
.prose p:last-child {
    margin-bottom: 0;
}

.prose em {
    font-style: italic;
}

.prose strong {
    font-weight: 500;
    color: #fafafa;
}

.prose h1,
.prose h2,
.prose h3 {
    font-family: var(--sans);
    font-weight: 600;
    color: var(--text);
    margin: 2em 0 0.75em;
    line-height: 1.3;
}

.prose h1 { font-size: 1.4rem; }
.prose h2 { font-size: 1.15rem; color: var(--accent); }
.prose h3 { font-size: 1rem; }

.prose ul,
.prose ol {
    margin: 0 0 1.35em 1.25em;
}

.prose li {
    margin-bottom: 0.5em;
}

.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5em 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin: 1.5em 0;
    font-family: var(--sans);
}

.prose th,
.prose td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
}

.prose th {
    background: var(--bg-elevated);
    color: var(--accent);
    font-weight: 600;
}

.loading {
    text-align: center;
    color: var(--text-3);
    font-family: var(--sans);
    font-size: 0.85rem;
    padding: 48px 0;
}

/* --- Rules prose (modal) --- */
.rules-prose {
    font-size: 0.95rem;
    line-height: 1.75;
}

.rules-prose h1 {
    display: none;
}

.rules-prose h2 {
    font-size: 0.95rem;
    margin-top: 2em;
}

.rules-prose h3 {
    font-size: 0.85rem;
    color: var(--text-2);
}

/* --- Footer --- */
.lux-footer {
    border-top: 1px solid var(--border);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    max-width: calc(var(--prose-max) + 96px);
    margin: 0 auto;
    width: 100%;
}

.footer-link {
    font-family: var(--sans);
    font-size: 0.75rem;
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}

.footer-link:hover {
    color: var(--accent);
}

.footer-copy {
    font-size: 0.72rem;
    color: var(--text-3);
}

/* --- Modal --- */
.modal {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    max-width: min(680px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    width: 100%;
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    z-index: 1;
}

.modal-header h2 {
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.modal-close:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100dvh - 140px);
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
    z-index: 200;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- Mobile --- */
@media (max-width: 600px) {
    .header-inner {
        padding: 0 16px;
        height: auto;
        min-height: var(--header-h);
        flex-wrap: wrap;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .action-btn {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
        font-size: 0.62rem;
    }

    .reader {
        padding: 32px 20px 64px;
    }

    .title-block {
        margin-bottom: 40px;
        padding-bottom: 36px;
    }

    .lux-footer {
        flex-direction: column;
        text-align: center;
        padding: 20px 16px;
    }
}

/* --- Print / PDF --- */
@media print {
    :root {
        --bg: #ffffff;
        --text: #1a1a1a;
        --text-2: #444444;
        --text-3: #666666;
        --border: #dddddd;
        --accent: #b45309;
    }

    body {
        background: white;
        color: #1a1a1a;
    }

    .lux-header,
    .lux-footer,
    .modal,
    .toast {
        display: none !important;
    }

    .reader {
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .title-block {
        border-bottom: 1px solid #ccc;
        margin-bottom: 2em;
        padding-bottom: 1.5em;
    }

    .title-block::after {
        display: none;
    }

    .title-block h1 {
        font-size: 22pt;
        color: #1a1a1a;
    }

    .label {
        color: #b45309;
    }

    .subtitle {
        color: #666;
    }

    .prose {
        font-size: 11pt;
        line-height: 1.7;
        color: #1a1a1a;
    }

    .prose p {
        orphans: 3;
        widows: 3;
        page-break-inside: avoid;
    }

    @page {
        margin: 2cm 2.5cm;
        size: letter;
    }
}
