/* ReadWhitepaper.com — Custom styles (non-Tailwind) */
/* Fonts loaded via <link> in base.html for non-blocking rendering */

/* ── Reading progress bar ── */
#reading-progress {
    transition: width 100ms ease-out;
}

/* ── Brand/coin visual system ── */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
}

.coin-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.coin-logo-wrap-sm {
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
}

.coin-logo {
    width: 76%;
    height: 76%;
    object-fit: contain;
}

/* ── Home coin cards ── */
.coin-card {
    --coin: #2563eb;
    position: relative;
    overflow: hidden;
    background: #fff;
}

.coin-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(700px 220px at 20% 0%, color-mix(in srgb, var(--coin) 20%, transparent), transparent 70%),
        radial-gradient(600px 220px at 100% 40%, rgba(14, 165, 233, 0.12), transparent 70%);
    opacity: 0.8;
    transition: opacity 160ms ease;
    pointer-events: none;
}

.coin-card:hover::before {
    opacity: 1;
}

.coin-card > * {
    position: relative;
    z-index: 1;
}

/* ── Coin hero ── */
.coin-hero {
    --coin: #2563eb;
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background:
        radial-gradient(900px 300px at 20% 0%, rgba(255, 255, 255, 0.9), transparent 60%),
        linear-gradient(135deg, color-mix(in srgb, var(--coin) 85%, #0b1220) 0%, #0b1220 70%);
}

.coin-hero::after {
    content: "";
    position: absolute;
    inset: -2px;
    background:
        radial-gradient(600px 300px at 90% 10%, color-mix(in srgb, var(--coin) 45%, transparent), transparent 60%),
        radial-gradient(500px 240px at 10% 100%, rgba(34, 197, 94, 0.15), transparent 70%);
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0.9;
}

.coin-hero-inner {
    position: relative;
    z-index: 1;
}

.coin-hero-title {
    text-wrap: balance;
}

.coin-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0.75rem;
    padding: 0.6rem 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    backdrop-filter: blur(10px);
}

.coin-cta:hover {
    background: rgba(255, 255, 255, 0.14);
}

.coin-cta-secondary {
    background: rgba(255, 255, 255, 0.04);
}

.coin-meta {
    color: rgba(226, 232, 240, 0.88);
}

/* ── Prose typography enhancements ── */
.prose {
    color: #111827;
    line-height: 1.75;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.25;
    font-weight: 700;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
    margin: 1rem 0;
}

.prose ul,
.prose ol {
    padding-left: 1.5rem;
}

.prose ul {
    list-style: disc;
}

.prose ol {
    list-style: decimal;
}

.prose a {
    color: #1d4ed8;
    text-decoration: underline;
}

.prose blockquote {
    border-left: 3px solid #cbd5e1;
    padding-left: 1rem;
    color: #475569;
}

.prose pre {
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
}

.prose code {
    font-size: 0.875em;
}

/* ASCII art diagrams — preserve formatting */
.prose pre code {
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
}

/* Math formulas — KaTeX rendered */
.prose .math-block {
    overflow-x: auto;
    padding: 1rem;
    margin: 1rem 0;
}

.prose .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
    margin: 1rem 0;
}

.prose .katex {
    font-size: 1.05em;
}

/* Algorithm / definition / proof blocks */
.prose .algorithm-block {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    background: #f9fafb;
    font-family: 'Geist Mono', 'SF Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
}

.prose .algorithm-block-title {
    font-weight: 700;
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
    font-family: 'Geist', system-ui, sans-serif;
}

.dark .prose .algorithm-block {
    border-color: #374151;
    background: #111827;
}

/* ── Section heading link (copy permalink) ── */
.whitepaper-heading {
    position: relative;
}

.whitepaper-heading .heading-anchor {
    display: inline-block;
    margin-left: 0.4em;
    opacity: 0;
    color: #94a3b8;
    text-decoration: none;
    transition: opacity 150ms ease;
    font-weight: 400;
    cursor: pointer;
}

.whitepaper-heading:hover .heading-anchor {
    opacity: 1;
}

.whitepaper-heading .heading-anchor:hover {
    color: #2563eb;
}

.dark .whitepaper-heading .heading-anchor:hover {
    color: #60a5fa;
}

/* ── Font size controls ── */
.font-size-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.75rem;
    padding: 0.3rem 0.5rem;
    background: rgba(255, 255, 255, 0.04);
}

.font-size-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease;
}

.font-size-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ── Whitepaper content images ── */
.prose img {
    max-width: 100%;
    height: auto;
    margin: 1.5rem auto;
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dark .prose img {
    border-color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.prose figure {
    margin: 2rem auto;
    text-align: center;
}

.prose figure img {
    margin-bottom: 0.5rem;
}

.prose figcaption {
    font-size: 0.875rem;
    color: #6b7280;
    font-style: italic;
    margin-top: 0.5rem;
}

.dark .prose figcaption {
    color: #9ca3af;
}

/* ── RTL support for Arabic ── */
[dir="rtl"] .prose {
    text-align: right;
}

[dir="rtl"] .prose ul,
[dir="rtl"] .prose ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

[dir="rtl"] .toc-link {
    text-align: right;
    padding-left: 0.5rem;
    padding-right: var(--toc-indent, 0.5rem);
}

/* ── Glossary link — highlighter effect ── */
.glossary-link {
    text-decoration: none;
    color: inherit;
    background-image: linear-gradient(to top, rgba(250, 204, 21, 0.35) 40%, transparent 40%);
    background-size: 100% 100%;
    transition: background-image 150ms ease;
    cursor: pointer;
    border-radius: 1px;
}

.glossary-link:hover {
    background-image: linear-gradient(to top, rgba(250, 204, 21, 0.55) 40%, transparent 40%);
}

.dark .glossary-link {
    background-image: linear-gradient(to top, rgba(250, 204, 21, 0.2) 40%, transparent 40%);
}

.dark .glossary-link:hover {
    background-image: linear-gradient(to top, rgba(250, 204, 21, 0.35) 40%, transparent 40%);
}

/* Highlighted term on glossary detail page */
.glossary-term-highlight {
    background-image: linear-gradient(to top, rgba(250, 204, 21, 0.45) 45%, transparent 45%);
    padding: 0 0.15em;
    border-radius: 2px;
    font-weight: 700;
}

/* Highlighted match in backlink context snippets */
.context-highlight {
    background-color: rgba(250, 204, 21, 0.3);
    border-radius: 2px;
    padding: 0 0.1em;
}

.dark .context-highlight {
    background-color: rgba(250, 204, 21, 0.2);
}

/* ── Glossary hover preview tooltip ── */
.glossary-preview {
    position: fixed;
    z-index: 100;
    width: 20rem;
    max-width: calc(100vw - 2rem);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 0.8125rem;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.glossary-preview.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.glossary-preview-term {
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: #111827;
}

.glossary-preview-def {
    color: #4b5563;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.glossary-preview-link {
    display: inline-block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #2563eb;
}

.dark .glossary-preview {
    background: #111827;
    border-color: #1f2937;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.dark .glossary-preview-term {
    color: #f3f4f6;
}

.dark .glossary-preview-def {
    color: #9ca3af;
}

.dark .glossary-preview-link {
    color: #60a5fa;
}

/* ── Dual mode panel sync highlight ── */
.dual-section .ring-2 {
    transition: box-shadow 150ms ease;
}

.dual-sentence {
    transition: background-color 150ms ease;
    border-radius: 3px;
}

/* ── Print styles ── */
@media print {
    header, footer, #toc-sidebar, #reading-progress-bar,
    .no-print, [x-data], .coin-cta, .glossary-preview,
    .lang-dropdown, #keyboard-help-modal {
        display: none !important;
    }

    body {
        font-size: 11pt;
        color: #000;
        background: #fff;
    }

    .dark body,
    .dark .prose {
        color: #000;
        background: #fff;
    }

    .prose {
        max-width: 100%;
    }

    .prose h1, .prose h2, .prose h3 {
        color: #000;
    }

    .prose pre {
        border: 1px solid #ccc;
        padding: 0.5rem;
        font-size: 9pt;
    }

    .prose code {
        background: #f3f4f6;
        padding: 0.1em 0.3em;
        border-radius: 2px;
    }

    .prose blockquote {
        border-left: 2pt solid #999;
        color: #333;
    }

    .coin-hero {
        background: none !important;
        border: 1px solid #ccc;
        border-radius: 0;
    }

    .coin-hero-title {
        color: #000 !important;
    }

    .coin-meta {
        color: #333 !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    .prose a[href^="#"]::after,
    .glossary-link::after {
        content: none;
    }

    .glossary-link {
        background-image: none;
    }

    img {
        max-width: 100% !important;
    }

    @page {
        margin: 2cm;
    }

    @page :first {
        margin-top: 3cm;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }

    pre, blockquote, figure, img {
        page-break-inside: avoid;
    }

    section {
        page-break-before: auto;
    }
}

/* ── Dark mode ── */
.dark .coin-logo-wrap {
    background: #0b1220;
    border-color: #1f2937;
    box-shadow: 0 2px 10px rgba(2, 6, 23, 0.5);
}

.dark .coin-hero {
    border-color: rgba(30, 41, 59, 0.85);
}

.dark .coin-card {
    background: #030712;
}

.dark .prose {
    color: #e5e7eb;
}

.dark .prose a {
    color: #93c5fd;
}

.dark .prose blockquote {
    border-left-color: #374151;
    color: #cbd5e1;
}

.dark .lang-dropdown::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* ── Language selector dropdown ── */
.lang-dropdown {
    max-height: 24rem;
    overflow-y: auto;
}

.lang-dropdown::-webkit-scrollbar {
    width: 4px;
}

.lang-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* ── External link indicator ── */
a[target="_blank"]::after,
a[rel~="noopener"]::after {
    content: " \2197";   /* ↗ */
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
    opacity: 0.6;
}

/* Exclude elements that already have their own icon (buttons, SVG-containing links) */
a[target="_blank"]:has(> svg)::after,
a[rel~="noopener"]:has(> svg)::after,
.coin-cta[target="_blank"]::after,
.coin-cta[rel~="noopener"]::after {
    content: none;
}

/* ── Smooth scroll ── */
html {
    scroll-behavior: smooth;
}

/* ── Line clamp utility ── */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Geist font utilities ── */
.font-geist {
    font-family: 'Geist', system-ui, sans-serif;
}

.font-geist-mono {
    font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ── Site footer (Airbridge-style layout) ── */
.site-footer {
    font-family: 'Geist', system-ui, sans-serif;
    font-size: 0.875rem;
}

.site-footer a {
    transition: color 150ms ease;
}

.site-footer-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.8125rem;
}

.site-footer-link:hover {
    color: #111827;
}

.dark .site-footer-link {
    color: #9ca3af;
}

.dark .site-footer-link:hover {
    color: #f3f4f6;
}

/* Suppress external-link arrow inside footer */
.site-footer a[target="_blank"]::after {
    content: none !important;
}

/* ── Glossary index search ── */
.glossary-search-results {
    max-height: 24rem;
    overflow-y: auto;
}

.glossary-search-results::-webkit-scrollbar {
    width: 4px;
}

.glossary-search-results::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.dark .glossary-search-results::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* ── Glossary card ── */
.glossary-card {
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.glossary-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.08);
}

.dark .glossary-card:hover {
    border-color: #1e40af;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.12);
}

/* ── Nav dropdown menus ── */
.nav-dd { position: relative; }
.nav-dd-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    color: inherit;
    text-decoration: none;
}
.nav-dd-trigger:hover { color: #2563eb; text-decoration: none; }
.dark .nav-dd-trigger:hover { color: #60a5fa; }
.nav-dd-chevron { font-size: 0.6rem; transition: transform 0.2s; }
.nav-dd.open .nav-dd-chevron { transform: rotate(180deg); }

.nav-dd-menu {
    position: absolute;
    top: calc(100% + 0.75rem);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    min-width: 290px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.04);
    padding: 0.35rem;
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}
.nav-dd.open .nav-dd-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.nav-dd-menu-wide { min-width: 380px; }

.dark .nav-dd-menu {
    background: #111827;
    border-color: #374151;
    box-shadow: 0 12px 32px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
}

.nav-dd-all {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #111827;
    text-decoration: none;
}
.nav-dd-all:hover { background: #f3f4f6; text-decoration: none; }
.dark .nav-dd-all { color: #f3f4f6; }
.dark .nav-dd-all:hover { background: #1f2937; }

.nav-dd-arrow {
    font-size: 0.8rem;
    color: #9ca3af;
    transition: transform 0.15s;
}
.nav-dd-all:hover .nav-dd-arrow { transform: translateX(3px); }

.nav-dd-sep { height: 1px; background: #e5e7eb; margin: 0.25rem 0.5rem; }
.dark .nav-dd-sep { background: #374151; }

.nav-dd-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    color: #111827;
    text-decoration: none;
}
.nav-dd-item:hover { background: #f3f4f6; text-decoration: none; }
.dark .nav-dd-item { color: #f3f4f6; }
.dark .nav-dd-item:hover { background: #1f2937; }

.nav-dd-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.3rem;
}

.nav-dd-meta { display: flex; flex-direction: column; gap: 0.05rem; }
.nav-dd-label { font-weight: 600; font-size: 0.82rem; }
.nav-dd-desc { font-size: 0.72rem; color: #9ca3af; line-height: 1.4; }
.dark .nav-dd-desc { color: #6b7280; }

.nav-dd-rss {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #9ca3af;
    text-decoration: none;
    font-family: 'Geist Mono', 'SF Mono', monospace;
}
.nav-dd-rss:hover { background: #f3f4f6; color: #111827; text-decoration: none; }
.dark .nav-dd-rss:hover { background: #1f2937; color: #f3f4f6; }

/* Glossary dropdown — compact 2-column grid */
.nav-dd-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.15rem;
}
.nav-dd-grid-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}
.nav-dd-grid-item:hover { background: #f3f4f6; text-decoration: none; }
.dark .nav-dd-grid-item { color: #d1d5db; }
.dark .nav-dd-grid-item:hover { background: #1f2937; }

.nav-dd-dot-sm {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Hide dropdown panels on mobile */
@media (max-width: 640px) {
    .nav-dd-menu { display: none !important; }
    .nav-dd-chevron { display: none; }
}

/* Suppress external-link arrow in nav dropdowns */
.nav-dd a::after { content: none !important; }

/* ── Story TOC (sidebar) ── */
.story-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.story-toc > ul > li {
    margin-bottom: 0.125rem;
}

.story-toc a {
    display: block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.story-toc a:hover {
    color: #2563eb;
    background-color: #f9fafb;
}

.dark .story-toc a {
    color: #9ca3af;
}

.dark .story-toc a:hover {
    color: #60a5fa;
    background-color: rgba(31, 41, 55, 0.5);
}

.story-toc ul ul {
    padding-left: 0.75rem;
}

.story-toc ul ul a {
    font-size: 0.75rem;
}
