/* ═══════════════════════════════════════════════════
   Matrix of Destiny — Compatibility App Styles
   Dark cosmic theme with glassmorphism
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* ── Reset & Variables ─────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep: #06060f;
    --bg-mid: #0d0d24;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.15);
    
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --rose: #e91e8c;
    --rose-glow: rgba(233, 30, 140, 0.25);
    --cyan: #00d4ff;
    --cyan-glow: rgba(0, 212, 255, 0.2);
    --violet: #a855f7;
    --violet-glow: rgba(168, 85, 247, 0.2);
    
    --text-primary: #f0eef6;
    --text-secondary: rgba(240, 238, 246, 0.6);
    --text-muted: rgba(240, 238, 246, 0.35);
    
    --excellent: #22c55e;
    --good: #84cc16;
    --moderate: #eab308;
    --low: #f97316;
    --challenging: #ef4444;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --radius: 20px;
    --radius-sm: 12px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ── Cosmic Background ─────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(233, 30, 140, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(0, 212, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Animated stars */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.5px 1.5px at 40% 10%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 55% 65%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 70% 25%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.5px 1.5px at 85% 55%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 45% 85%, rgba(255,255,255,0.25), transparent),
        radial-gradient(1.5px 1.5px at 90% 90%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 60% 45%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 30% 55%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1.5px 1.5px at 75% 70%, rgba(255,255,255,0.35), transparent);
    pointer-events: none;
    z-index: 0;
    animation: twinkle 8s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ── Container ─────────────────────────────────────── */
.container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Header ────────────────────────────────────────── */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 2rem;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold), var(--rose), var(--violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.app-header .subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 300;
    max-width: 500px;
    margin: 0 auto;
}

/* ── Input Card ────────────────────────────────────── */
.input-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

.input-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), var(--rose), var(--violet), transparent);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-group label {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.partner-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.partner-label .partner-icon {
    font-size: 1.3rem;
}

.form-group input[type="date"] {
    font-family: var(--font-body);
    font-size: 1.05rem;
    padding: 0.9rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
    -webkit-appearance: none;
}

.form-group input[type="date"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

.calculate-btn {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bg-deep);
    background: linear-gradient(135deg, var(--gold), #f0c850);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: relative;
    overflow: hidden;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--gold-glow);
}

.calculate-btn:active {
    transform: translateY(0);
}

.calculate-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.calculate-btn:hover::after {
    left: 100%;
}

/* ── Results Section ───────────────────────────────── */
#results {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
    pointer-events: none;
}

#results.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* ── Overall Score ─────────────────────────────────── */
.overall-card {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2.5rem 2rem 2rem;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.overall-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 1rem;
}

.overall-gauge {
    position: relative;
    width: 280px;
    height: 160px;
    margin: 0 auto 0.5rem;
}

.overall-gauge svg {
    width: 100%;
    height: 100%;
}

.gauge-arc-bg {
    stroke: rgba(255, 255, 255, 0.06);
}

.gauge-arc-fill {
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-center-text {
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    text-align: center;
}

.gauge-center-text .gauge-percent {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.overall-label {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 0.8rem;
}

.overall-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Color variants for overall */
.score-excellent .gauge-arc-fill { stroke: var(--excellent); }
.score-excellent .gauge-percent, .score-excellent .overall-label { color: var(--excellent); }
.score-excellent { border-color: rgba(34, 197, 94, 0.15); }

.score-good .gauge-arc-fill { stroke: var(--good); }
.score-good .gauge-percent, .score-good .overall-label { color: var(--good); }
.score-good { border-color: rgba(132, 204, 22, 0.15); }

.score-moderate .gauge-arc-fill { stroke: var(--moderate); }
.score-moderate .gauge-percent, .score-moderate .overall-label { color: var(--moderate); }
.score-moderate { border-color: rgba(234, 179, 8, 0.15); }

.score-low .gauge-arc-fill { stroke: var(--low); }
.score-low .gauge-percent, .score-low .overall-label { color: var(--low); }
.score-low { border-color: rgba(249, 115, 22, 0.15); }

.score-challenging .gauge-arc-fill { stroke: var(--challenging); }
.score-challenging .gauge-percent, .score-challenging .overall-label { color: var(--challenging); }
.score-challenging { border-color: rgba(239, 68, 68, 0.15); }

/* ── Aspect Cards Grid ─────────────────────────────── */
.aspects-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

#aspect-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.aspect-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.8rem;
    text-align: center;
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease both;
    position: relative;
    overflow: hidden;
}

.aspect-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 2px;
    opacity: 0.6;
}

.aspect-card.score-excellent::before { background: var(--excellent); }
.aspect-card.score-good::before { background: var(--good); }
.aspect-card.score-moderate::before { background: var(--moderate); }
.aspect-card.score-low::before { background: var(--low); }
.aspect-card.score-challenging::before { background: var(--challenging); }

.aspect-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aspect-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.aspect-icon {
    font-size: 1.4rem;
}

.aspect-name {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Individual Gauges ─────────────────────────────── */
.gauge-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
}

.gauge-container svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-container .gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 6;
}

.gauge-container .gauge-fill {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-container .gauge-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-container .gauge-percent {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
}

/* Apply score colors to aspect cards */
.aspect-card.score-excellent .gauge-fill { stroke: var(--excellent); }
.aspect-card.score-excellent .gauge-percent { color: var(--excellent); }

.aspect-card.score-good .gauge-fill { stroke: var(--good); }
.aspect-card.score-good .gauge-percent { color: var(--good); }

.aspect-card.score-moderate .gauge-fill { stroke: var(--moderate); }
.aspect-card.score-moderate .gauge-percent { color: var(--moderate); }

.aspect-card.score-low .gauge-fill { stroke: var(--low); }
.aspect-card.score-low .gauge-percent { color: var(--low); }

.aspect-card.score-challenging .gauge-fill { stroke: var(--challenging); }
.aspect-card.score-challenging .gauge-percent { color: var(--challenging); }

/* ── Badge Card (Soul Match) ──────────────────────── */
.badge-card {
    border-color: rgba(168, 85, 247, 0.15) !important;
}

.badge-card::before {
    background: linear-gradient(90deg, var(--violet), var(--rose)) !important;
}

.badge-image-container {
    width: 110px;
    height: 110px;
    margin: 0 auto 0.8rem;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    box-shadow:
        0 0 20px rgba(168, 85, 247, 0.2),
        0 0 40px rgba(168, 85, 247, 0.1);
    animation: badgePulse 3s ease-in-out infinite;
}

.badge-image-container::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(168, 85, 247, 0.3);
    pointer-events: none;
}

.badge-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.badge-label {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--violet);
    margin-bottom: 0.6rem;
    letter-spacing: 0.02em;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 20px rgba(168, 85, 247, 0.2), 0 0 40px rgba(168, 85, 247, 0.1); }
    50% { box-shadow: 0 0 25px rgba(168, 85, 247, 0.35), 0 0 50px rgba(168, 85, 247, 0.15); }
}

/* Mini badge in detail header */
.detail-badge-mini {
    margin-left: auto;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.25);
}

.detail-badge-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Description ───────────────────────────────────── */
.aspect-description {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Footer ────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 2rem 0 3rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.app-footer a {
    color: var(--gold);
    text-decoration: none;
}

/* ── Detail Overlay (Flip-Expand) ──────────────────── */
.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 6, 15, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: all 0.4s ease;
    padding: 2rem;
}

.detail-overlay.active {
    background: rgba(6, 6, 15, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.detail-overlay.closing {
    background: rgba(6, 6, 15, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

/* ── Detail Card ───────────────────────────────────── */
.detail-card {
    position: relative;
    width: 100%;
    max-width: 620px;
    max-height: 85vh;
    overflow-y: auto;
    background: linear-gradient(145deg, rgba(20, 18, 40, 0.95), rgba(12, 10, 30, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 2.5rem;
    
    /* Entry animation — flip + scale in */
    transform: perspective(800px) rotateY(90deg) scale(0.7);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.detail-card.active {
    transform: perspective(800px) rotateY(0deg) scale(1);
    opacity: 1;
}

.detail-card.closing {
    transform: perspective(800px) rotateY(-90deg) scale(0.7);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.36, 0, 0.66, -0.56);
}

/* Top accent bar inherits score color */
.detail-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.detail-card.score-excellent::before { background: linear-gradient(90deg, var(--excellent), rgba(34, 197, 94, 0.3)); }
.detail-card.score-good::before { background: linear-gradient(90deg, var(--good), rgba(132, 204, 22, 0.3)); }
.detail-card.score-moderate::before { background: linear-gradient(90deg, var(--moderate), rgba(234, 179, 8, 0.3)); }
.detail-card.score-low::before { background: linear-gradient(90deg, var(--low), rgba(249, 115, 22, 0.3)); }
.detail-card.score-challenging::before { background: linear-gradient(90deg, var(--challenging), rgba(239, 68, 68, 0.3)); }

/* Subtle inner glow */
.detail-card.score-excellent { box-shadow: inset 0 0 60px rgba(34, 197, 94, 0.05), 0 25px 80px rgba(0,0,0,0.5); }
.detail-card.score-good { box-shadow: inset 0 0 60px rgba(132, 204, 22, 0.05), 0 25px 80px rgba(0,0,0,0.5); }
.detail-card.score-moderate { box-shadow: inset 0 0 60px rgba(234, 179, 8, 0.04), 0 25px 80px rgba(0,0,0,0.5); }
.detail-card.score-low { box-shadow: inset 0 0 60px rgba(249, 115, 22, 0.04), 0 25px 80px rgba(0,0,0,0.5); }
.detail-card.score-challenging { box-shadow: inset 0 0 60px rgba(239, 68, 68, 0.04), 0 25px 80px rgba(0,0,0,0.5); }

/* Scrollbar styling */
.detail-card::-webkit-scrollbar {
    width: 4px;
}
.detail-card::-webkit-scrollbar-track {
    background: transparent;
}
.detail-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ── Close Button ──────────────────────────────────── */
.detail-close {
    position: absolute;
    top: 1rem; right: 1rem;
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
    padding: 0;
}

.detail-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--glass-border-hover);
    transform: rotate(90deg);
}

/* ── Detail Header ─────────────────────────────────── */
.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-right: 2.5rem; /* space for close button */
}

.detail-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
}

.detail-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.detail-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.detail-score-badge {
    margin-left: auto;
    flex-shrink: 0;
}

.detail-score-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
}

.detail-card.score-excellent .detail-score-value { color: var(--excellent); }
.detail-card.score-good .detail-score-value { color: var(--good); }
.detail-card.score-moderate .detail-score-value { color: var(--moderate); }
.detail-card.score-low .detail-score-value { color: var(--low); }
.detail-card.score-challenging .detail-score-value { color: var(--challenging); }

/* ── Detail Body Sections ──────────────────────────── */
.detail-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detail-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 1.3rem 1.5rem;
}

.detail-section-heading {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
}

.detail-section-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
    #aspect-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }
    
    .input-card {
        padding: 1.5rem;
    }
    
    #aspect-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .overall-gauge {
        width: 150px;
        height: 150px;
    }
    
    .overall-gauge .gauge-percent {
        font-size: 2.2rem;
    }
    
    .narrative-tile-body {
        -webkit-line-clamp: 4;
    }
}

/* ── Narrative Insight Tiles ────────────────────────── */

.insights-title {
    margin-top: 3rem;
}

#narrative-insights {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.narrative-tile {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 1.25rem 1.5rem;
    animation: fadeSlideUp 0.6s ease-out both;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.narrative-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--violet), var(--cyan), var(--violet));
    opacity: 0.5;
    transition: opacity 0.3s;
}

.narrative-tile:hover {
    background: var(--bg-card-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.08);
}

.narrative-tile:hover::before {
    opacity: 1;
}

.narrative-tile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.narrative-tile-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(168, 85, 247, 0.12);
    border-radius: 10px;
    flex-shrink: 0;
}

.narrative-tile-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.narrative-tile-subtitle {
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 2px 0 0;
    letter-spacing: 0.02em;
}

.narrative-tile-body {
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    max-height: 4.95em;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.narrative-tile-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2em;
    background: linear-gradient(transparent, var(--bg-deep));
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
}

.narrative-tile-body p {
    margin: 0;
}

.narrative-tile-body strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Expanded state */
.narrative-tile.expanded .narrative-tile-body {
    -webkit-line-clamp: unset;
    max-height: 50em;
    display: block;
}

.narrative-tile.expanded .narrative-tile-body::after {
    opacity: 0;
}

.narrative-tile.expanded {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(168, 85, 247, 0.25);
}

/* Expand hint */
.narrative-tile-header::after {
    content: '↓ Read more';
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--violet);
    opacity: 0.6;
    margin-left: auto;
    transition: all 0.3s;
    flex-shrink: 0;
}

.narrative-tile.expanded .narrative-tile-header::after {
    content: '↑ Collapse';
}

/* ── Magnetic Tension Badge (Large, Side-by-Side) ──── */

.overall-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.overall-content-wrapper.has-badge {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 2.5rem;
}

.overall-gauge-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.vector-badge-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    z-index: 10;
    flex: 1;
    min-width: 0;
    max-width: 220px;
    padding-top: 0.5rem;
    transition: transform 0.3s ease;
}

.vector-badge-container:hover {
    transform: translateY(-4px);
}

.vector-badge-glow {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.25) 0%, rgba(168, 85, 247, 0.1) 50%, transparent 70%);
    filter: blur(25px);
    animation: vectorGlowPulse 3s ease-in-out infinite;
    pointer-events: none;
}

.vector-badge-img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid rgba(239, 68, 68, 0.45);
    box-shadow:
        0 0 20px rgba(239, 68, 68, 0.35),
        0 0 40px rgba(239, 68, 68, 0.15),
        0 0 60px rgba(168, 85, 247, 0.1);
    transition: all 0.3s;
    position: relative;
    z-index: 1;
    animation: vectorPulse 2.5s ease-in-out infinite;
}

.vector-badge-container:hover .vector-badge-img {
    transform: scale(1.08);
    box-shadow:
        0 0 30px rgba(239, 68, 68, 0.5),
        0 0 60px rgba(239, 68, 68, 0.25),
        0 0 80px rgba(168, 85, 247, 0.15);
}

.vector-badge-label {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: #ef4444;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
}

.vector-badge-sublabel {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

@keyframes vectorPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.35), 0 0 40px rgba(239, 68, 68, 0.15); }
    50% { box-shadow: 0 0 30px rgba(239, 68, 68, 0.5), 0 0 55px rgba(239, 68, 68, 0.25); }
}

/* ── Vector Popup Overlay ───────────────────────────── */

.vector-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 15, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    padding: 2rem;
}

.vector-overlay.active {
    opacity: 1;
}

.vector-overlay.closing {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.vector-popup {
    position: relative;
    background: linear-gradient(160deg, rgba(30, 10, 40, 0.95), rgba(15, 5, 25, 0.98));
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    padding: 2.5rem 2rem 2rem;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
    transform: scale(0.8) translateY(40px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.vector-popup.active {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.vector-popup.closing {
    transform: scale(0.85) translateY(30px);
    opacity: 0;
}

/* Backlight glow behind badge */
.vector-popup-badge-glow {
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.35) 0%, rgba(168, 85, 247, 0.15) 50%, transparent 70%);
    filter: blur(20px);
    animation: vectorGlowPulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes vectorGlowPulse {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.2); }
}

.vector-popup-badge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.3);
    margin: 0 auto 1rem;
    display: block;
    position: relative;
    z-index: 1;
}

.vector-popup-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 5;
}

.vector-popup-close:hover {
    color: #ef4444;
}

.vector-popup-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: #ef4444;
    margin-bottom: 0.25rem;
}

.vector-popup-subtitle {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.vector-role {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.vector-role strong {
    color: var(--text-primary);
}

.vector-role em {
    color: var(--rose);
    font-style: normal;
    font-weight: 500;
}

.vector-popup-body {
    text-align: left;
}

.vector-section {
    margin-bottom: 1.25rem;
}

.vector-section:last-child {
    margin-bottom: 0;
}

.vector-section h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.vector-section p {
    font-family: var(--font-body);
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

/* Responsive for vector popup */
@media (max-width: 600px) {
    .vector-popup {
        padding: 2rem 1.25rem 1.5rem;
    }
    
    .vector-popup-badge {
        width: 80px;
        height: 80px;
    }
    
    .vector-badge-img {
        width: 100px;
        height: 100px;
    }
    
    .overall-content-wrapper.has-badge {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .vector-badge-label {
        font-size: 0.9rem;
    }
}
