/* ── CRT Bloom Effect (CSS-only) ── */

:root {
    --bloom-blur: 2px;
    --bloom-brightness: 1;
    --bloom-opacity: 1;
    --bloom-color: rgba(245, 245, 245, 0.35);
}

/* Glow on headings */
h1, h2 {
    text-shadow: 0 0 var(--bloom-blur) var(--bloom-color),
                 0 0 calc(var(--bloom-blur) * 3) var(--bloom-color);
}

/* Glow on section-colored elements */
.section-node, .toc a, .nav-prev, .nav-next {
    text-shadow: 0 0 var(--bloom-blur) var(--bloom-color);
}

/* Glow on file/folder icons */
.file .icon svg, .folder .icon svg {
    filter: drop-shadow(0 0 var(--bloom-blur) var(--bloom-color));
}

/* Glow on the header symbol image */
.headersymbol {
    filter: drop-shadow(0 0 calc(var(--bloom-blur) * 2) var(--bloom-color));
}

/* Glow on breadcrumb and section description */
.breadcrumb, .breadcrumb a, .section-desc {
    text-shadow: 0 0 var(--bloom-blur) var(--bloom-color);
}

/* Glow on sub-nodes (home page tree) */
.sub-node {
    text-shadow: 0 0 var(--bloom-blur) var(--bloom-color);
}

/* Glow on group labels (home page) */
.group-label {
    text-shadow: 0 0 var(--bloom-blur) var(--bloom-color),
                 0 0 calc(var(--bloom-blur) * 2) var(--bloom-color);
}

/* ── File preview modal ── */
.preview-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 5vh;
}

.preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 90%;
    max-width: 1000px;
    padding: 10px 0 6px 0;
    flex-shrink: 0;
}

.preview-filename {
    color: #F5F5F5;
    font-family: 'DepartureMono', monospace;
    font-size: 14px;
    opacity: 0.8;
    text-align: left;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 12px;
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.preview-btn {
    background: #1a1a1a;
    color: #F5F5F5;
    border: 1px solid #333;
    padding: 5px 14px;
    font-family: 'DepartureMono', monospace;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.preview-btn:hover {
    border-color: #888;
    background: #222;
}

/* Summary tab content */
.preview-summary {
    padding: 40px;
    color: #ccc;
    font-family: 'DepartureMono', monospace;
    font-size: 15px;
    line-height: 1.8;
}

.preview-summary p {
    margin: 0 0 14px 0;
}

.preview-summary p:last-child {
    margin-bottom: 0;
}

/* Tab bar */
.preview-tabs {
    display: flex;
    gap: 0;
    width: 90%;
    max-width: 1000px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.preview-tab {
    background: none;
    color: #888;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 20px;
    font-family: 'DepartureMono', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-tab:hover {
    color: #ccc;
}

.preview-tab.active {
    color: #F5F5F5;
    border-bottom-color: var(--section-color, #F5F5F5);
    text-shadow: 0 0 8px var(--bloom-color, rgba(245,245,245,0.35));
}

.preview-tab.listen-tab {
    margin-left: auto;
}

.preview-tab.listen-tab.playing {
    color: #ACDE70;
    border-bottom-color: #ACDE70;
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 4px rgba(172,222,112,0.3); }
    50% { text-shadow: 0 0 12px rgba(172,222,112,0.6); }
}

/* Content frame */
.preview-frame {
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    border: 1px solid #222;
    border-top: none;
    background: #0a0a0a;
    overflow-y: auto;
}

/* Document tab: page images */
.preview-frame .doc-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-frame .doc-page {
    display: block;
    width: 100%;
    height: auto;
    border-bottom: 1px solid #1a1a1a;
}

/* Text tab: rendered markdown */
.preview-frame .text-content {
    padding: 30px 40px;
    color: #ddd;
    font-family: 'DepartureMono', monospace;
    font-size: 14px;
    line-height: 1.7;
}

.preview-frame .text-content h1 {
    font-size: 20px;
    color: #F5F5F5;
    margin: 30px 0 12px 0;
    border-bottom: 1px solid #333;
    padding-bottom: 6px;
}

.preview-frame .text-content h2 {
    font-size: 17px;
    color: #F5F5F5;
    margin: 24px 0 10px 0;
}

.preview-frame .text-content h3 {
    font-size: 15px;
    color: #ccc;
    margin: 20px 0 8px 0;
}

.preview-frame .text-content p {
    margin: 0 0 14px 0;
}

.preview-frame .text-content ul, .preview-frame .text-content ol {
    margin: 0 0 14px 24px;
}

.preview-frame .text-content li {
    margin-bottom: 4px;
}

.preview-frame .text-content img {
    max-width: 100%;
    height: auto;
    margin: 12px 0;
    border: 1px solid #222;
}

.preview-frame .text-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}

.preview-frame .text-content th,
.preview-frame .text-content td {
    border: 1px solid #333;
    padding: 8px 12px;
    text-align: left;
}

.preview-frame .text-content th {
    background: #1a1a1a;
    color: #F5F5F5;
    font-weight: 600;
}

.preview-frame .text-content td {
    background: #0f0f0f;
}

.preview-frame .text-content tr:hover td {
    background: #151515;
}

.preview-frame .text-content hr {
    border: none;
    border-top: 1px solid #333;
    margin: 24px 0;
}

.preview-frame .text-content blockquote {
    border-left: 3px solid #444;
    margin: 12px 0;
    padding: 8px 16px;
    color: #aaa;
}

/* Zoom controls */
.doc-zoom-controls {
    position: sticky;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.text-actions {
    position: sticky;
    top: 0;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 8px 0;
    z-index: 10;
    background: inherit;
}

.doc-zoom-btn {
    pointer-events: auto;
    background: #1a1a1a;
    color: #F5F5F5;
    border: 1px solid #444;
    width: 32px;
    height: 32px;
    font-family: 'DepartureMono', monospace;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.doc-zoom-btn:hover {
    border-color: #888;
    background: #222;
}

.doc-zoom-label {
    pointer-events: none;
    color: #888;
    font-family: 'DepartureMono', monospace;
    font-size: 13px;
    min-width: 40px;
    text-align: center;
}

/* Loading state */
.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #F5F5F5;
    font-family: 'DepartureMono', monospace;
    font-size: 14px;
}

/* ── TTS ── */

/* TTS generation progress (inside modal) */
.tts-gen-progress {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 20px;
    background: #0a0a0a;
    border-bottom: 1px solid #333;
}

.tts-gen-label {
    color: #ACDE70;
    font-family: 'DepartureMono', monospace;
    font-size: 14px;
    white-space: pre;
    text-shadow: 0 0 6px rgba(172, 222, 112, 0.4);
    letter-spacing: 0.05em;
}

/* TTS text highlight */
.tts-highlight {
    background: rgba(172, 222, 112, 0.1);
    border-left: 2px solid #ACDE70;
    padding-left: 8px;
    transition: background 0.3s ease;
}

.tts-gen-bar.pulsing {
    animation: tts-pulse 1s ease-in-out infinite;
}

@keyframes tts-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Search footer link */
.search-footer {
    display: block;
    text-align: center;
    margin: 30px auto 10px auto;
    font-size: 14px;
    opacity: 0.6;
}

/* Disable all bloom on mobile */
@media (max-width: 800px) {
    h1, h2,
    .section-node, .toc a, .nav-prev, .nav-next,
    .tab-name, .tab-desc,
    .breadcrumb, .breadcrumb a, .section-desc,
    .sub-node, .group-label {
        text-shadow: none;
    }
    .file .icon svg, .folder .icon svg,
    .headersymbol {
        filter: none;
    }
    .tab-card {
        box-shadow: none;
    }
}
