/* ═══════════════════════════════════════════════════════════════════════
   COSMOTECH ASTRIMANCY STYLESHEET
   Deep-space mysticism rendered through precision tech
   ═══════════════════════════════════════════════════════════════════════ */

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

/* ═══════════════════════════════════════════════════════════════════════
   ROOT VARIABLES — COSMOTECH PALETTE
   ═══════════════════════════════════════════════════════════════════════ */
:root {
    --void-black: #0a0a0f;
    --void-deep: #0f0f1a;
    --void-mid: #1a1a2e;
    --astral-indigo: #1e1b4b;
    --astral-violet: #4c1d95;
    --nebula-violet: #7c3aed;
    --nebula-magenta: #d946ef;
    --nebula-cyan: #06b6d4;
    --signal-violet: #a78bfa;
    --signal-cyan: #67e8f9;
    --signal-gold: #fbbf24;
    --glow-violet: rgba(167, 139, 250, 0.15);
    --glow-cyan: rgba(103, 232, 249, 0.12);
    --grain-opacity: 0.03;
}

/* ═══════════════════════════════════════════════════════════════════════
   BASE RESET & FOUNDATION
   ═══════════════════════════════════════════════════════════════════════ */
* {
    scroll-behavior: smooth;
    box-sizing: border-box;
}

*html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--nebula-violet);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    font-weight: 600;
    z-index: 9999;
    border-radius: 0 0 0.5rem 0;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--signal-cyan);
    outline-offset: 2px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a0a2e 50%, #0f0a1e 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Animated gradient overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 30%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(6, 182, 212, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(217, 70, 239, 0.1) 0%, transparent 60%);
    animation: gradientShift 20s ease-in-out infinite;
    pointer-events: none;
    z-index: -2;
}

/* Floating orbs effect */
body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(167, 139, 250, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(103, 232, 249, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(217, 70, 239, 0.07) 0%, transparent 50%);
    animation: floatingOrbs 30s ease-in-out infinite;
    pointer-events: none;
    z-index: -2;
}

@keyframes gradientShift {
    0%, 100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    33% {
        opacity: 0.8;
        transform: scale(1.1) rotate(5deg);
    }
    66% {
        opacity: 0.9;
        transform: scale(0.95) rotate(-5deg);
    }
}

@keyframes floatingOrbs {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(-5%, 5%) rotate(120deg);
    }
    66% {
        transform: translate(5%, -5%) rotate(240deg);
    }
}

body > * {
    position: relative;
    z-index: 2;
}

/* Focus indicators for keyboard navigation */
*:focus {
    outline: 2px solid var(--signal-violet);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--signal-violet);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.2);
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--signal-cyan);
    outline-offset: 3px;
}

/* Scroll reveal animations */
section {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease-out forwards;
}

section:nth-child(even) {
    animation-delay: 0.1s;
}

section:nth-child(odd) {
    animation-delay: 0.2s;
}

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

/* Enhanced card hover effects */
.card-node,
.strand-widget,
.fluon-chamber,
.mechanic-chamber {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.card-node::before,
.strand-widget::before,
.fluon-chamber::before,
.mechanic-chamber::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(167, 139, 250, 0.15), transparent 60%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card-node:hover::before,
.strand-widget:hover::before,
.fluon-chamber:hover::before,
.mechanic-chamber:hover::before {
    opacity: 1;
}

button, .btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

button::before, .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

button:active::before, .btn:active::before {
    width: 300px;
    height: 300px;
}

/* ═══════════════════════════════════════════════════════════════════════
   TYPOGRAPHY — RITUAL WEIGHT & DECODED CLARITY
   ═══════════════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: #f3f4f6;
}

h1 { font-size: clamp(2.5rem, 6vw, 5rem); font-weight: 700; }
h2 { font-size: clamp(2rem, 5vw, 3.75rem); font-weight: 700; }
h3 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; }
h4 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); font-weight: 600; }

p {
    line-height: 1.85;
    letter-spacing: -0.008em;
    color: #e5e7eb;
}

strong {
    font-weight: 600;
    color: #f3f4f6;
}

/* ═══════════════════════════════════════════════════════════════════════
   INSTRUMENTAL PANELS — CARDS & SECTIONS
   ═══════════════════════════════════════════════════════════════════════ */
.card {
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
    position: relative;
    background: rgba(15, 15, 26, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(167, 139, 250, 0.12);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, 
        rgba(167, 139, 250, 0.3) 0%, 
        rgba(217, 70, 239, 0.2) 50%,
        rgba(103, 232, 249, 0.15) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.5s ease;
}

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

.card:hover {
    transform: translateY(-4px) scale(1.01);
    border-color: rgba(167, 139, 250, 0.3);
    box-shadow: 
        0 12px 32px rgba(124, 58, 237, 0.25),
        0 6px 16px rgba(217, 70, 239, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.card:active {
    transform: translateY(-2px) scale(1.005);
    transition-duration: 0.1s;
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 0.5rem;
    filter: brightness(0.95) contrast(1.05);
    transition: filter 0.4s ease;
}

.card:hover .card-image {
    filter: brightness(1.05) contrast(1.1);
}

/* ═══════════════════════════════════════════════════════════════════════
   STRAND WIDGETS — COSMOTECH COLLAPSIBLE CHAMBERS
   ═══════════════════════════════════════════════════════════════════════ */
.strand-widget {
    position: relative;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.strand-widget::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: radial-gradient(800px 400px at 50% 0%, rgba(255, 255, 255, 0.08), transparent 60%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 1;
}

.strand-widget:hover::before {
    opacity: 1;
}

.strand-header {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.strand-header::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, currentColor, transparent);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.strand-header:hover {
    background: rgba(0, 0, 0, 0.2);
}

.strand-header:hover::after {
    width: 100%;
}

.strand-icon-container {
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease;
}

.strand-widget:hover .strand-icon-container {
    transform: scale(1.1) rotate(3deg);
}

/* Card nodes within widgets */
.card-node {
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-node:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: translateY(-4px) !important;
}

.card-node:active {
    transform: translateY(-2px) scale(0.98) !important;
    transition-duration: 0.1s;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Card image parallax effect */
.card-node:hover img {
    transform: scale(1.05);
}

.card-node img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card number badge animations */
.card-number-badge {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-node:hover .card-number-badge {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Viewed card visual states - grayed out when viewed */
.card-node.is-viewed,
.strand-overlay .card-node.is-viewed,
.card-node[data-card-key].is-viewed {
    opacity: 0.6 !important;
    filter: grayscale(30%) saturate(70%) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.card-node.is-viewed:hover,
.strand-overlay .card-node.is-viewed:hover,
.card-node[data-card-key].is-viewed:hover {
    opacity: 0.85 !important;
    filter: grayscale(15%) saturate(85%) !important;
}

.card-node.is-viewed img,
.strand-overlay .card-node.is-viewed img,
.card-node[data-card-key].is-viewed img {
    filter: brightness(0.8) grayscale(20%) !important;
    transition: filter 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.card-node.is-viewed:hover img,
.strand-overlay .card-node.is-viewed:hover img,
.card-node[data-card-key].is-viewed:hover img {
    filter: brightness(0.95) grayscale(5%) !important;
}

.card-node.is-viewed h4,
.strand-overlay .card-node.is-viewed h4,
.card-node[data-card-key].is-viewed h4 {
    color: #9ca3af !important;
    transition: color 0.3s ease !important;
}

.card-node.is-viewed:hover h4,
.strand-overlay .card-node.is-viewed:hover h4,
.card-node[data-card-key].is-viewed:hover h4 {
    color: #d1d5db !important;
}

.card-node.is-viewed .text-xs,
.strand-overlay .card-node.is-viewed .text-xs,
.card-node[data-card-key].is-viewed .text-xs {
    opacity: 0.6 !important;
    transition: opacity 0.3s ease !important;
}

.card-node.is-viewed:hover .text-xs,
.strand-overlay .card-node.is-viewed:hover .text-xs,
.card-node[data-card-key].is-viewed:hover .text-xs {
    opacity: 0.8 !important;
}

/* Favorited card visual states - gold accent only */
.card-node.is-favorited,
.strand-overlay .card-node.is-favorited,
.card-node[data-card-key].is-favorited {
    border-color: rgba(251, 191, 36, 0.3) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(251, 191, 36, 0.2) !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   FAVORITE STAR BUTTON - Rebuilt System
   ═══════════════════════════════════════════════════════════════════════ */
.favorite-star {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fbbf24;
    font-size: 14px;
    z-index: 50;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.favorite-star:hover {
    background: rgba(0, 0, 0, 0.95);
    border-color: rgba(251, 191, 36, 0.4);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.favorite-star:active {
    transform: scale(0.95);
}

/* Unfavorited state - outline star */
.favorite-star i.far {
    color: rgba(251, 191, 36, 0.6);
}

.favorite-star:hover i.far {
    color: rgba(251, 191, 36, 0.9);
}

/* Favorited state - filled star */
.favorite-star i.fas {
    color: #fbbf24;
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
}

.card-node.is-favorited .favorite-star {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.4);
    box-shadow: 0 2px 12px rgba(251, 191, 36, 0.3), 0 0 0 2px rgba(251, 191, 36, 0.1);
}

.card-node.is-favorited .favorite-star:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4), 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.card-node.is-favorited .favorite-star:hover i {
    color: #ef4444;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
}

/* Favorited card visual state */
.card-node.is-favorited {
    border-color: rgba(251, 191, 36, 0.3) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(251, 191, 36, 0.2) !important;
}

.card-node.is-favorited::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 10% 10%, rgba(251, 191, 36, 0.08), transparent 60%);
    pointer-events: none;
    z-index: 1;
}

/* Favorites filter button */
.favorites-filter-btn {
    cursor: pointer;
    user-select: none;
}

.favorites-filter-btn:hover {
    background: rgba(251, 191, 36, 0.25) !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.2);
}

.favorites-filter-btn:active {
    transform: scale(0.98);
}

/* Star button pulse animation on favorite */
@keyframes starPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3) rotate(15deg);
    }
    100% {
        transform: scale(1);
    }
}

.favorite-star.pulse {
    animation: starPulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Strand content animation */
.strand-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
    opacity: 0;
}

.strand-content:not(.hidden) {
    max-height: 3000px;
    opacity: 1;
}

/* Badge styling */
.badge {
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.strand-widget:hover .badge {
    transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════════════════
   FLUON CHAMBERS — MOTION ENERGY FIELDS (REDESIGNED)
   ═══════════════════════════════════════════════════════════════════════ */
.fluon-chamber {
    position: relative;
    overflow: hidden;
    min-height: 480px;
}

.fluon-visual-header {
    position: relative;
}

.fluon-icon-container {
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.fluon-chamber:hover .fluon-icon-container {
    transform: scale(1.1) rotate(5deg);
}

.fluon-chamber::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05), transparent 70%);
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.fluon-chamber:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.fluon-chamber:hover::after {
    opacity: 1;
}

.fluon-item {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.fluon-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(167, 139, 250, 0.2);
}

.fluon-item:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

/* Fluon stinger images */
.fluon-stinger {
    position: relative;
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.fluon-item:hover .fluon-stinger {
    opacity: 0.3;
}

/* Video hover effects */
.fluon-item video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 5;
}

.fluon-item:hover video {
    opacity: 1;
}

/* Ensure text remains readable on hover */
.fluon-item:hover .fluon-stinger strong,
.fluon-item:hover .fluon-stinger p {
    text-shadow: 0 0 8px currentColor, 0 0 16px rgba(0, 0, 0, 0.8);
}

/* Ambient breathing animation for Fluon chambers */
@keyframes fluonBreath {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

.fluon-chamber::before {
    animation: fluonBreath 8s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════
   MECHANIC CHAMBERS — ADVANCED MECHANICS (REDESIGNED)
   ═══════════════════════════════════════════════════════════════════════ */
.mechanic-chamber {
    position: relative;
    overflow: hidden;
    min-height: 600px;
}

.mechanic-chamber .w-16 {
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.mechanic-chamber:hover .w-16 {
    transform: scale(1.15) rotate(-5deg);
}

/* Equal height columns for mechanics */
@media (min-width: 1024px) {
    .mechanic-chamber {
        display: flex;
        flex-direction: column;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY: REDUCED MOTION SUPPORT
   ═══════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .animate-pulse-slow,
    .animate-drift {
        animation: none !important;
    }
    
    video {
        display: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --grain-opacity: 0;
    }
    
    body::before,
    body::after {
        opacity: 0;
    }
    
    .card,
    .strand-widget,
    .fluon-chamber {
        border-width: 2px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   PERFORMANCE: OPTIMIZED BACKDROP BLUR
   ═══════════════════════════════════════════════════════════════════════ */
/* Reduce backdrop blur in deep sections for better performance */
.fluon-chamber,
.mechanic-chamber,
#trinkets .grid > div {
    backdrop-filter: blur(4px);
}

/* Keep stronger blur only on hero and nav */
nav {
    backdrop-filter: blur(24px);
}

/* ═══════════════════════════════════════════════════════════════════════
   RELATIONSHIP MATRIX — RESPONSIVE LATTICE (REDESIGNED)
   ═══════════════════════════════════════════════════════════════════════ */
.relationship-matrix-container {
    width: 100%;
    overflow: hidden;
    position: relative;
}

#relationship-matrix {
    width: 100%;
    overflow: visible;
}

/* Responsive table scaling */
#relationship-matrix table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.5rem, 0.8vw, 0.75rem);
    min-width: 0;
}

.relationship-header {
    padding: clamp(0.2rem, 0.4vw, 0.3rem) clamp(0.15rem, 0.3vw, 0.25rem);
    text-align: center;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    font-size: clamp(0.45rem, 0.7vw, 0.65rem);
    min-width: 70px;
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Smaller font for 'Ðethapart' specifically */
.relationship-header.strand-special {
    font-size: clamp(0.4rem, 0.6vw, 0.55rem);
}

.relationship-cell {
    padding: clamp(0.25rem, 0.5vw, 0.4rem) clamp(0.15rem, 0.3vw, 0.25rem);
    text-align: center;
    font-weight: 600;
    border: 1px solid rgba(167, 139, 250, 0.08);
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    background: rgba(10, 10, 15, 0.6);
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
    min-width: 70px;
    max-width: 90px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    line-height: 1;
}

/* Relationship cell tooltips */
.relationship-cell {
    position: relative;
}

.relationship-cell:hover::before {
    content: attr(data-relationship);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.relationship-cell:hover::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.9);
    z-index: 1000;
    pointer-events: none;
    margin-bottom: -0.25rem;
}

.relationship-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    background: radial-gradient(circle at center, currentColor, transparent);
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.relationship-cell:hover {
    transform: scale(1.08) translateY(-2px);
    z-index: 10;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.relationship-cell:hover::after {
    opacity: 0.1;
}

.relationship-cell:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
}

.relationship-header {
    background: linear-gradient(135deg, var(--astral-violet) 0%, var(--astral-indigo) 100%);
    font-weight: 700;
    padding: clamp(0.5rem, 1vw, 0.875rem);
    text-align: center;
    border: 1px solid rgba(167, 139, 250, 0.2);
    position: sticky;
    top: 0;
    z-index: 5;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: clamp(0.6rem, 1vw, 0.75rem);
}

/* Mobile strand selector */
#strand-selector {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a78bfa'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.5rem;
    padding-right: 3rem;
}

.relationship-best-friend {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #d1fae5;
    box-shadow: inset 0 0 20px rgba(5, 150, 105, 0.2);
}

.relationship-ally {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #dbeafe;
    box-shadow: inset 0 0 20px rgba(37, 99, 235, 0.2);
}

.relationship-friend {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    color: #cffafe;
    box-shadow: inset 0 0 20px rgba(8, 145, 178, 0.2);
}

.relationship-acquaintance {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    color: #e5e7eb;
    box-shadow: inset 0 0 20px rgba(75, 85, 99, 0.2);
}

.relationship-mortal-enemy {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: #fecaca;
    box-shadow: inset 0 0 20px rgba(220, 38, 38, 0.3);
}

.relationship-self {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #6b7280;
    box-shadow: inset 0 0 20px rgba(31, 41, 55, 0.4);
}

/* ═══════════════════════════════════════════════════════════════════════
   MODAL — RITUAL FOCUS STATE
   ═══════════════════════════════════════════════════════════════════════ */
#card-modal {
    backdrop-filter: blur(16px);
    z-index: 60;
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(16px);
    }
}

#card-modal > div {
    animation: modalSlideUp 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: center;
}

#card-modal.hidden {
    animation: fadeOut 0.2s ease;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(60px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

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

/* Try a Reading Section Styles */
.perspective-btn {
    color: #9ca3af;
    transition: all 0.3s ease;
}

.perspective-btn.active {
    color: white;
}

.perspective-btn:hover {
    color: #d1d5db;
}

.reading-card-slot {
    transition: all 0.3s ease;
}

.reading-card-slot:hover {
    transform: translateY(-4px);
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════
   STRAND OVERLAY — EXPANSION CHAMBER
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes overlayFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

@keyframes overlayFadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
}

@keyframes overlaySlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.strand-overlay-content {
    position: relative;
}

.strand-overlay-content::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: radial-gradient(800px 400px at 50% 0%, rgba(255, 255, 255, 0.1), transparent 60%);
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

/* Scrollbar styling for overlay */
.strand-overlay-content .overflow-y-auto::-webkit-scrollbar {
    width: 8px;
}

.strand-overlay-content .overflow-y-auto::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.strand-overlay-content .overflow-y-auto::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.strand-overlay-content .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════
   SCROLLBAR — ASTRAL TRACK
   ═══════════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--void-deep);
    border-left: 1px solid rgba(167, 139, 250, 0.08);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, 
        var(--nebula-violet) 0%, 
        var(--nebula-magenta) 100%);
    border-radius: 10px;
    border: 2px solid var(--void-deep);
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.4);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, 
        var(--signal-violet) 0%, 
        var(--nebula-magenta) 100%);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.6);
}

/* ═══════════════════════════════════════════════════════════════════════
   TEXT SELECTION
   ═══════════════════════════════════════════════════════════════════════ */
::selection {
    background: rgba(167, 139, 250, 0.3);
    color: #f3f4f6;
    text-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════
   ANIMATIONS — COSMOTECH AMBIENT MOTION
   Slow, breathing, controlled — never jittery or chaotic
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes slowPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes slowDrift {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

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

/* Gentle rotation for icons */
@keyframes gentleRotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(3deg); }
}

/* Subtle glow pulse */
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(167, 139, 250, 0.2); }
    50% { box-shadow: 0 0 30px rgba(167, 139, 250, 0.4); }
}

/* Mobile menu animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.animate-pulse-slow {
    animation: slowPulse 8s ease-in-out infinite;
}

.animate-drift {
    animation: slowDrift 12s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════════════════════════════ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(167, 139, 250, 0.2);
    border-radius: 50%;
    border-top-color: var(--signal-violet);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading skeleton for cards */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error state styling */
.error-state {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #fca5a5;
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
}

/* Image loading placeholder */
img[src=""],
img:not([src]) {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(217, 70, 239, 0.1));
    min-height: 100px;
}

/* Smooth image fade-in */
img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.loaded,
img[src]:not([data-src]) {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════
   SECTION TRANSITIONS & ATMOSPHERIC DEPTH — COSMOTECH CHAMBERS
   Each section is a chamber with intentional spatial separation
   ═══════════════════════════════════════════════════════════════════════ */
section {
    position: relative;
    margin-bottom: 4rem;
}

section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(167, 139, 250, 0.15), 
        transparent);
    opacity: 0.6;
}

/* Hero Section Grounding */
#intro::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    height: 900px;
    background: radial-gradient(circle, 
        rgba(124, 58, 237, 0.1) 0%, 
        rgba(217, 70, 239, 0.05) 40%,
        transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: slowPulse 20s ease-in-out infinite;
}

/* Section-specific atmospheric backgrounds */
#fluons::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, 
        rgba(6, 182, 212, 0.06) 0%, 
        transparent 60%);
    pointer-events: none;
    z-index: 0;
    animation: slowDrift 18s ease-in-out infinite;
}

#advanced::before {
    content: '';
    position: absolute;
    top: 30%;
    right: 10%;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, 
        rgba(239, 68, 68, 0.05) 0%, 
        rgba(251, 146, 60, 0.03) 50%,
        transparent 70%);
    pointer-events: none;
    z-index: 0;
}

#relationships::before {
    content: '';
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, 
        rgba(217, 70, 239, 0.06) 0%, 
        transparent 65%);
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   TYPOGRAPHY REFINEMENTS — COSMOTECH HIERARCHY
   Silence is structure. Negative space is signal.
   ═══════════════════════════════════════════════════════════════════════ */

/* Section headings - cosmic weight */
section h2 {
    letter-spacing: -0.03em;
    margin-bottom: 2rem;
    text-shadow: 0 0 40px currentColor;
}

/* Dense instructional blocks - breathing room */
.space-y-4 > div {
    margin-top: 0.25rem;
}

/* Principle quotes - enhanced visibility and weight */
.principle-quote,
section p.italic.text-sm.text-center,
section p.italic.text-xs.text-center {
    font-size: 0.95rem !important;
    text-shadow: 0 0 12px currentColor;
    opacity: 0.9;
    line-height: 1.8;
    font-style: italic;
    letter-spacing: 0.01em;
}

/* Dense explanatory text - improved line height */
#advanced .text-sm.leading-relaxed,
#advanced p.leading-relaxed {
    line-height: 1.8;
}

/* Subheadings within chambers */
.fluon-chamber h3,
.mechanic-chamber h3 {
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════════════════════
   CALLOUTS & PURPOSE BOXES — INTENTIONAL EMPHASIS
   ═══════════════════════════════════════════════════════════════════════ */

/* Purpose/principle boxes with left accent */
.purpose-box {
    border-left: 3px solid currentColor;
    padding-left: 1.25rem;
    position: relative;
}

.purpose-box::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: currentColor;
    opacity: 0.6;
    filter: blur(2px);
}

/* Final Principle emphasis */
.bg-gradient-to-br.from-yellow-900\/30.to-orange-900\/20:has(h3:contains("Final Principle")) {
    padding-top: 4rem;
    padding-bottom: 4rem;
    animation: glowPulse 12s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════
   NAVIGATION ENHANCEMENTS — SUBTLE WAYFINDING
   ═══════════════════════════════════════════════════════════════════════ */

nav {
    backdrop-filter: blur(24px);
}

nav a {
    position: relative;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

nav a:hover {
    text-shadow: 0 0 12px rgba(167, 139, 250, 0.8);
    transform: translateY(-1px);
}

nav a:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

nav a span.absolute {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --grain-opacity: 0.02;
    }

    .relationship-cell,
    .relationship-header {
        font-size: 0.65rem;
        padding: 0.4rem;
    }

    body::before {
        opacity: 0.7;
    }
    
    /* Mobile grid adjustments */
    #trinkets .grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Improve text contrast on mobile */
    p,
    .text-gray-400 {
        color: #d1d5db;
    }
    
    /* Reduce animations on mobile for performance */
    .animate-pulse-slow,
    .animate-drift {
        animation-duration: 20s;
    }
    
    /* Fluon chambers stack on mobile */
    .fluon-chamber {
        min-height: 400px;
    }
    
    /* Mechanic chambers stack on mobile */
    .mechanic-chamber {
        min-height: auto;
    }
    
    /* Increase mobile card padding */
    #trinkets .grid > div {
        padding: 1.5rem;
    }
    
    /* Hide desktop matrix on mobile, show selector */
    .relationship-matrix-container {
        display: none;
    }
}

/* Hide matrix on medium screens too if needed */
@media (max-width: 1024px) {
    .relationship-matrix-container {
        display: none;
    }
    
    .mt-12.lg\\:hidden {
        display: block !important;
    }
}

@media (min-width: 640px) {
    #trinkets .grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    #fluons .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    #trinkets .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) {
    /* Show desktop matrix, hide mobile selector */
    #strand-selector {
        display: none;
    }
}

@media (min-width: 1024px) {
    #trinkets .grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    /* Fluon chambers in 2-column grid */
    .fluon-chamber {
        min-height: 500px;
    }
    
    /* Mechanic chambers equal height */
    .mechanic-chamber {
        min-height: 650px;
    }
    
    /* Relationship matrix optimal sizing */
    .relationship-cell {
        font-size: 0.75rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════ */
.glow-violet {
    box-shadow: 0 0 24px rgba(167, 139, 250, 0.4);
}

.glow-cyan {
    box-shadow: 0 0 24px rgba(103, 232, 249, 0.4);
}

.text-glow {
    text-shadow: 0 0 16px currentColor;
}

.purpose-box {
    border-left: 3px solid currentColor;
    padding-left: 1.25rem;
}

.border-glow {
    box-shadow: 
        0 0 20px rgba(167, 139, 250, 0.3),
        inset 0 0 20px rgba(167, 139, 250, 0.1);
}

/* Touch target sizing for mobile */
@media (pointer: coarse) {
    button,
    a,
    [role="button"] {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Improve tap targets on mobile */
    .strand-header,
    .card-node,
    .fluon-item {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover::before,
    .strand-widget:hover::before,
    .fluon-chamber:hover .fluon-icon-container {
        transform: none;
    }
}

/* Smooth state transitions */
.transition-smooth {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Hover lift effect */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Scroll progress indicator */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--nebula-violet), var(--nebula-magenta), var(--nebula-cyan));
    z-index: 9999;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.6);
}
