/**
 * Remnant Thread D3 Visualization Styles
 * Shared CSS for all D3-powered visualizations
 * Companion to assets/js/visualizations.js
 */

/* ===========================================
   ARTICLE OVERRIDES FOR FULL-WIDTH VISUALIZATIONS
   =========================================== */

article.viz-page {
    max-width: 100% !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
}

article.viz-page > h1,
article.viz-page > p,
article.viz-page > blockquote,
article.viz-page > .text-content {
    max-width: 55ch;
    margin-left: auto;
    margin-right: auto;
}

/* ===========================================
   VISUALIZATION CONTAINERS
   =========================================== */

.viz-container {
    width: 100%;
    max-width: 100%;
    margin: 2rem auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.viz-container svg {
    display: block;
    margin: 0 auto;
}

/* Scroll hint for mobile */
.scroll-hint {
    display: none;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

@media (max-width: 1200px) {
    .scroll-hint {
        display: block;
    }
}

/* ===========================================
   TOOLTIPS
   =========================================== */

.viz-tooltip,
.remnant-tooltip {
    position: absolute;
    background: var(--bg);
    border: 1px solid var(--accent);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    max-width: 320px;
    pointer-events: none;
    opacity: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    line-height: 1.5;
    transition: opacity 0.2s;
}

.viz-tooltip h3,
.remnant-tooltip strong {
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: block;
}

.viz-tooltip p,
.remnant-tooltip span {
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0;
}

.viz-tooltip .source,
.remnant-tooltip .source {
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--muted);
    font-style: italic;
}

/* ===========================================
   LEGENDS
   =========================================== */

.viz-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem auto;
    max-width: 800px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status colors */
.legend-swatch.fulfilled,
.legend-swatch.status-fulfilled { background: var(--viz-fulfilled); }
.legend-swatch.present,
.legend-swatch.status-present { background: var(--viz-present); }
.legend-swatch.coming,
.legend-swatch.status-coming { background: var(--viz-coming); }

/* Type colors */
.legend-swatch.entity { background: var(--viz-entity); }
.legend-swatch.event { background: var(--viz-event); }
.legend-swatch.verse { background: var(--viz-verse); }
.legend-swatch.quote { background: var(--viz-quote); }
.legend-swatch.claim { background: var(--viz-claim); }

/* ===========================================
   TIMELINE STYLES
   =========================================== */

.timeline-line {
    stroke: var(--accent);
    stroke-width: 2;
}

.timeline-segment {
    stroke-linecap: round;
}

.timeline-segment.fulfilled { stroke: var(--viz-fulfilled); }
.timeline-segment.present { stroke: var(--viz-present); }
.timeline-segment.coming { stroke: var(--viz-coming); }

.event-marker {
    cursor: pointer;
}

.event-marker:hover circle {
    filter: brightness(1.2);
}

.event-label {
    font-size: 10px;
    fill: var(--muted);
}

.event-year {
    font-size: 12px;
    font-weight: bold;
    fill: var(--accent);
}

.event-title {
    font-size: 10px;
    fill: var(--muted);
}

/* Pulsing animation for present/current markers */
.pulse-marker {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        filter: drop-shadow(0 0 4px color-mix(in srgb, var(--viz-present) 40%, transparent));
    }
    50% {
        filter: drop-shadow(0 0 12px color-mix(in srgb, var(--viz-present) 80%, transparent));
    }
}

/* Span lines (for prophecy periods) */
.span-line {
    stroke: var(--border);
    stroke-width: 1;
    stroke-dasharray: 4,4;
    fill: none;
}

.span-text {
    fill: var(--accent);
    font-size: 14px;
    font-weight: bold;
}

/* ===========================================
   PHASE PROGRESS INDICATOR
   =========================================== */

.phase-progress {
    margin: 2rem 0;
}

.phase-marker {
    cursor: pointer;
    transition: transform 0.2s;
}

.phase-marker:hover {
    transform: scale(1.1);
}

/* ===========================================
   COMPARISON TABLES
   =========================================== */

.comparison-container {
    max-width: 800px;
    margin: 2rem auto;
}

.comparison-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.comparison-header > div {
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.comparison-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.comparison-row:hover {
    background: var(--quote-bg);
}

.comparison-row .cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comparison-row .cell.left { color: var(--viz-compare-left); }
.comparison-row .cell.right { color: var(--viz-compare-right); }

/* ===========================================
   FORCE GRAPH (KNOWLEDGE GRAPH)
   =========================================== */

.graph-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: var(--quote-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.graph-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.graph-search {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
}

.graph-search:focus {
    outline: none;
    border-color: var(--accent);
}

.graph-filter {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.graph-node {
    cursor: pointer;
}

.graph-node:hover circle {
    filter: brightness(1.2);
}

.graph-link {
    stroke-opacity: 0.6;
}

/* ===========================================
   STATISTICS BAR
   =========================================== */

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background: var(--quote-bg);
    border-radius: 4px;
    margin: 2rem auto;
    max-width: 700px;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent);
}

.stat-number.green { color: var(--success); }
.stat-number.amber { color: var(--warning); }
.stat-number.red { color: var(--danger); }

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===========================================
   BIG NUMBER DISPLAY
   =========================================== */

.year-count,
.big-number {
    text-align: center;
    margin: 2rem 0;
}

.year-count .number,
.big-number .number {
    font-size: clamp(3rem, 12vw, 5rem);
    font-weight: 300;
    color: var(--accent);
    letter-spacing: 0.15em;
}

.year-count .label,
.big-number .label {
    font-size: 1rem;
    color: var(--muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ===========================================
   PROPHETIC TIMELINE V2 (Three-Zone Layout)
   =========================================== */

.prophetic-timeline-v2 {
    display: block;
}

.zone-fulfilled,
.zone-present,
.zone-coming {
    /* Zone groups */
}

.now-line {
    stroke-dasharray: 6, 4;
}

.now-label {
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sequence-connector {
    stroke-linecap: round;
}

/* Mobile Vertical Layout */
.prophetic-timeline-vertical {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
}

.prophetic-timeline-vertical .timeline-section {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    padding-bottom: 0.5rem;
}

.prophetic-timeline-vertical .timeline-section.fulfilled {
    border-left-color: var(--viz-fulfilled, #2a7d4c);
}

.prophetic-timeline-vertical .timeline-section.present {
    border-left-color: var(--viz-present, #f59e0b);
}

.prophetic-timeline-vertical .timeline-section.coming {
    border-left-color: var(--viz-coming, #6b7280);
}

.prophetic-timeline-vertical .section-title {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.prophetic-timeline-vertical .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.prophetic-timeline-vertical .status-dot.fulfilled {
    background: var(--viz-fulfilled, #2a7d4c);
}

.prophetic-timeline-vertical .status-dot.coming {
    background: var(--viz-coming, #6b7280);
}

.prophetic-timeline-vertical .now-badge {
    background: var(--viz-present, #f59e0b);
    color: #000;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
}

.prophetic-timeline-vertical .pulse-text {
    animation: pulse-text 2s ease-in-out infinite;
}

.prophetic-timeline-vertical .timeline-event {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
}

.prophetic-timeline-vertical .event-year-badge {
    background: var(--accent);
    color: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.prophetic-timeline-vertical .event-dot {
    color: var(--viz-present, #f59e0b);
    font-size: 1.2rem;
    line-height: 1;
}

.prophetic-timeline-vertical .event-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--viz-coming, #6b7280);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    flex-shrink: 0;
}

.prophetic-timeline-vertical .timeline-event.highlight .event-number {
    background: var(--accent);
}

.prophetic-timeline-vertical .event-title-text {
    flex: 1;
    color: var(--text);
}

.prophetic-timeline-vertical .connector-arrow {
    text-align: center;
    color: var(--viz-coming, #6b7280);
    font-size: 1rem;
    padding-left: 5px;
    line-height: 1;
}

/* ===========================================
   SHARED MOBILE CARD STYLES
   =========================================== */

.viz-mobile-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.viz-mobile-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.viz-mobile-search:focus {
    outline: none;
    border-color: var(--accent);
}

.viz-mobile-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.viz-mobile-filter-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.viz-mobile-filter-btn.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.viz-mobile-card {
    border-left: 3px solid var(--border);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--quote-bg);
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background 0.2s;
}

.viz-mobile-card:hover {
    background: color-mix(in srgb, var(--quote-bg) 80%, var(--accent) 20%);
}

.viz-mobile-card.sabbath,
.viz-mobile-card.fulfilled,
.viz-mobile-card.success {
    border-left-color: var(--status-success);
}

.viz-mobile-card.sunday,
.viz-mobile-card.danger {
    border-left-color: var(--status-danger);
}

.viz-mobile-card.mixed,
.viz-mobile-card.warning,
.viz-mobile-card.present {
    border-left-color: var(--status-warning);
}

.viz-mobile-card.neutral,
.viz-mobile-card.coming {
    border-left-color: var(--status-neutral);
}

.viz-mobile-card.rome {
    border-left-color: var(--status-rome);
}

/* Era colors for timeline cards */
.viz-mobile-card.era-apostolic { border-left-color: var(--era-apostolic); }
.viz-mobile-card.era-early { border-left-color: var(--era-early); }
.viz-mobile-card.era-medieval { border-left-color: var(--era-medieval); }
.viz-mobile-card.era-reformation { border-left-color: var(--era-reformation); }
.viz-mobile-card.era-modern { border-left-color: var(--era-modern); }

.viz-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.viz-mobile-title {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
}

.viz-mobile-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
    background: var(--accent);
    color: var(--bg);
    white-space: nowrap;
}

.viz-mobile-badge.sabbath,
.viz-mobile-badge.success {
    background: var(--status-success);
    color: #fff;
}

.viz-mobile-badge.sunday,
.viz-mobile-badge.danger {
    background: var(--status-danger);
    color: #fff;
}

.viz-mobile-badge.mixed,
.viz-mobile-badge.warning {
    background: var(--status-warning);
    color: #000;
}

.viz-mobile-badge.neutral {
    background: var(--status-neutral);
    color: #fff;
}

.viz-mobile-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.viz-mobile-details {
    display: none;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1.5;
}

.viz-mobile-card.expanded .viz-mobile-details {
    display: block;
}

.viz-mobile-card .expand-icon {
    color: var(--muted);
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.viz-mobile-card.expanded .expand-icon {
    transform: rotate(180deg);
}

.viz-mobile-section {
    margin-bottom: 1.5rem;
}

.viz-mobile-section-title {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.viz-mobile-empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem;
    font-style: italic;
}

/* Arrow connector for flow-style mobile layouts */
.viz-mobile-arrow {
    text-align: center;
    color: var(--muted);
    font-size: 1.2rem;
    padding: 0.25rem 0;
}

/* ===========================================
   RESPONSIVE ADJUSTMENTS
   =========================================== */

@media (max-width: 768px) {
    .viz-legend {
        gap: 0.5rem;
    }

    .legend-item {
        font-size: 0.7rem;
    }

    .legend-swatch {
        width: 12px;
        height: 12px;
    }

    .stats-bar {
        gap: 1rem;
        padding: 0.75rem;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .comparison-header > div {
        font-size: 1rem;
    }

    .comparison-row {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}
