/* ============================================================================
   CDARS JUSTICE DOMAIN - THE 24 PORTALS OF ORDER
   CRIMSON JURISDICTION (#D61E3B) · SHARP · HEAVY · AUTHORITATIVE
   SHARED LIVING PHYSICS · UNIQUE VISUAL IDENTITY
   ============================================================================ */

:root {
    /* Justice Identity - Crimson */
    --justice-red: #D61E3B;
    --justice-red-dim: rgba(214, 30, 59, 0.15);
    --justice-red-glow: rgba(214, 30, 59, 0.3);
    --justice-red-soft: rgba(214, 30, 59, 0.05);
    --justice-red-dark: #8B0000;
    --justice-gold: #FFD700;
    
    /* GATE FOUNDATION */
    --void: #05070c;
    --void-deep: #03040a;
    --abyss: #020308;
    
    /* Surface Layers */
    --panel: rgba(12, 16, 24, 0.85);
    --panel-deep: rgba(8, 12, 20, 0.95);
    --panel-edge: rgba(255, 255, 255, 0.08);
    --panel-edge-justice: rgba(214, 30, 59, 0.15);
    
    /* Typography */
    --text-primary: rgba(255, 255, 255, 0.98);
    --text-secondary: rgba(255, 255, 255, 0.82);
    --text-tertiary: rgba(255, 255, 255, 0.62);
    
    /* Spacing */
    --radius-large: 32px;
    --radius-medium: 20px;
    --radius-small: 12px;
    --radius-pill: 999px;
    
    /* Shadows */
    --shadow-cosmic: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    --shadow-justice: 0 0 40px rgba(214, 30, 59, 0.2);
    
    /* Transitions */
    --curve-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --curve-breathe: cubic-bezier(0.87, 0, 0.13, 1);
    --curve-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --curve-pressure: cubic-bezier(0.2, 0.9, 0.3, 1.2); /* For hover effect */
    
    /* Mouse position */
    --mouse-x: 50%;
    --mouse-y: 50%;
    
    /* Card index */
    --card-index: 0;
}

/* ============================================================================
   REALM BASE
   ============================================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    background: var(--void-deep);
    color: var(--text-primary);
    font-size: 16px;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    background: var(--void-deep);
    opacity: 0;
    animation: reality-manifest 1.2s var(--curve-smooth) forwards;
    line-height: 1.6;
    padding-bottom: 50px;
    position: relative;
    overflow-x: hidden;
    font-weight: 500; /* Heavier base weight for justice */
}

@keyframes reality-manifest {
    0% { opacity: 0; filter: blur(10px); }
    100% { opacity: 1; filter: blur(0); }
}

/* ============================================================================
   SHARED QUANTUM REALITY LAYER - SAME AS ACADEMY BUT CRIMSON
   ============================================================================ */
.quantum-reality-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.reality-thread {
    position: fixed;
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: screen;
    will-change: transform, opacity;
    opacity: 0.5;
    filter: blur(0.8px) brightness(1.3);
    box-shadow: 0 0 15px currentColor;
}

.quantum-particle {
    position: fixed;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--justice-red);
    filter: blur(2px);
    animation: particle-drift linear infinite;
    pointer-events: none;
    z-index: 4;
    opacity: 0.4;
    mix-blend-mode: screen;
}

@keyframes particle-drift {
    from { transform: translate(0, 0) rotate(0deg); }
    to { transform: translate(100vw, 100vh) rotate(360deg); }
}

/* ============================================================================
   CRIMSON VISUAL IDENTITY - SHARP · HEAVY · AUTHORITATIVE
   ============================================================================ */

/* All text is heavier */
h1, h2, h3, h4, .title, .kicker, .stat-number, .portal-tab, .back-button {
    font-weight: 800 !important;
    letter-spacing: -0.02em;
}

/* Sharp lines - smaller border radius */
.topbar, .hero-left, .hero-right, .portal-card, .search-input, .search-filter {
    border-radius: 12px; /* Sharper than Academy's 32px */
}

/* Hover effect = pressure shift, not bounce */
.portal-card, .nav-item, .back-button, .search-filter {
    transition: transform 0.2s var(--curve-pressure), border-color 0.2s ease;
}

.portal-card:hover, .nav-item:hover, .back-button:hover, .search-filter:hover {
    transform: scale(1.02) translateY(-2px); /* Subtle, not bouncy */
    border-color: var(--justice-red);
}

/* ============================================================================
   MAIN CONTAINER
   ============================================================================ */
.wrap {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

/* ============================================================================
   NAVIGATION - JUSTICE STYLE
   ============================================================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding: 0.8rem 1.5rem;
    background: rgba(10, 14, 22, 0.6);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-edge-justice);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sigil {
    width: 40px;
    height: 40px;
    border-radius: 8px; /* Sharper */
    border: 1px solid rgba(255, 215, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.sigil::after {
    content: '';
    position: absolute;
    inset: -40%;
    background: 
        radial-gradient(6px 6px at 18% 30%, rgba(255,255,255,0.45), transparent 55%),
        radial-gradient(3px 3px at 65% 65%, rgba(255,255,255,0.30), transparent 55%);
    opacity: 0.8;
    animation: sigilSpin 18s linear infinite;
}

@keyframes sigilSpin {
    to { transform: rotate(360deg); }
}

.brand h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    background: linear-gradient(135deg, #fff, var(--justice-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.nav {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.nav-item {
    padding: 0.6rem 1.2rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px; /* Sharper */
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s var(--curve-pressure);
}

.nav-item:hover {
    border-color: var(--justice-red);
    background: var(--justice-red-dim);
    transform: scale(1.02) translateY(-2px);
}

.user-badge {
    background: var(--justice-red-dim);
    border: 1px solid var(--justice-red);
    color: var(--justice-red);
    padding: 0.3rem 1rem;
    border-radius: 8px; /* Sharper */
    font-size: 0.75rem;
    font-weight: 700;
}

.presence-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px; /* Sharper */
    border: 1px solid var(--justice-red);
}

.presence-pulse {
    width: 8px;
    height: 8px;
    background: #50ffb4;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.presence-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============================================================================
   HERO SECTION - JUSTICE STYLE
   ============================================================================ */
.hero {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 2rem;
    margin-bottom: 4rem;
    align-items: center;
}

.hero-left {
    padding: 2rem;
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-edge-justice);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s var(--curve-pressure);
    animation: justice-breathe 4.5s var(--curve-breathe) infinite;
    --card-index: 1;
}

.hero-left:hover {
    border-color: var(--justice-red);
    box-shadow: var(--shadow-justice);
    transform: translateY(-4px) scale(1.01); /* Subtler than Academy */
    animation-play-state: paused;
}

/* YOUR HERO IMAGE */
.hero-left::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('/assets/domains/justice/cdarsjusticehero.webp') center/cover no-repeat;
    opacity: 0.1;
    z-index: 0;
}

.hero-left::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
                var(--justice-red-glow), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.hero-left:hover::after {
    opacity: 0.3;
}

.hero-left > * {
    position: relative;
    z-index: 2;
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--justice-red-dim);
    border: 1px solid rgba(214, 30, 59, 0.3);
    border-radius: 8px; /* Sharper */
    color: var(--justice-red);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--justice-red);
    box-shadow: 0 0 15px var(--justice-red);
}

.title {
    font-family: 'Cinzel', serif;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff, var(--justice-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.desc {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    max-width: 600px;
    font-weight: 500;
}

.stats {
    display: flex;
    gap: 2rem;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 900;
    color: var(--justice-red);
    text-shadow: 0 0 20px var(--justice-red-glow);
}

.stat-label {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    font-weight: 600;
}

.hero-right {
    padding: 2rem;
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-edge-justice);
    border-radius: 12px;
    transition: all 0.4s var(--curve-pressure);
    animation: justice-breathe 4.5s var(--curve-breathe) infinite;
    animation-delay: 0.2s;
    --card-index: 2;
}

.hero-right:hover {
    border-color: var(--justice-red);
    box-shadow: var(--shadow-justice);
    transform: translateY(-4px) scale(1.01);
    animation-play-state: paused;
}

/* YOUR SEAL IMAGE */
.seal {
    aspect-ratio: 1/1;
    background: url('/assets/domains/justice/cdarsjusticeseat.webp') center/contain no-repeat;
    opacity: 0.9;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.seal:hover {
    opacity: 1;
    transform: scale(1.03);
    filter: drop-shadow(0 0 20px var(--justice-red));
}

.seal-meta {
    display: grid;
    gap: 0.8rem;
}

.meta-line {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-tertiary);
    font-weight: 500;
}

.meta-line span:last-child {
    color: var(--justice-red);
    font-weight: 700;
}

/* ============================================================================
   LEGENDARY CROWN - SHARED (COLORS UPDATED)
   ============================================================================ */
.legendary-crown {
    margin: 2rem 0 3rem;
    padding: 2rem 0 1.5rem;
    background: var(--panel-deep);
    border-top: 2px solid var(--panel-edge-justice);
    border-bottom: 2px solid var(--panel-edge-justice);
    border-radius: 12px;
    position: relative;
    overflow: visible;
    z-index: 50;
}

.crown-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle at 50% 50%, var(--justice-red-dim), transparent 70%);
    opacity: 0.3;
    pointer-events: none;
    animation: crown-pulse 8s ease-in-out infinite;
}

@keyframes crown-pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.05); }
}

.crown-header {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--justice-red);
    color: #000;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.2rem 1.2rem;
    border-radius: 6px; /* Sharper */
    letter-spacing: 0.2em;
    white-space: nowrap;
    box-shadow: 0 0 20px var(--justice-red);
    z-index: 55;
}

.crown-track-container {
    position: relative;
    overflow: visible;
    padding: 0 2rem;
}

.crown-gradient-left,
.crown-gradient-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100px;
    pointer-events: none;
    z-index: 52;
}

.crown-gradient-left {
    left: 0;
    background: linear-gradient(90deg, var(--panel-deep), transparent);
}

.crown-gradient-right {
    right: 0;
    background: linear-gradient(-90deg, var(--panel-deep), transparent);
}

.crown-track {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 0.5rem 2rem;
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--justice-red) var(--panel-edge);
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 51;
}

.crown-track::-webkit-scrollbar {
    height: 4px;
}

.crown-track::-webkit-scrollbar-track {
    background: var(--panel-edge);
    border-radius: 10px;
}

.crown-track::-webkit-scrollbar-thumb {
    background: var(--justice-red);
    border-radius: 4px;
}

.crown-jewel {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.4s var(--curve-spring);
    filter: drop-shadow(0 0 10px var(--jewel-color));
    z-index: 53;
}

.crown-jewel::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background: var(--jewel-color);
    opacity: 0;
    transition: opacity 0.3s ease;
    filter: blur(10px);
    z-index: -1;
}

.crown-jewel:hover::before {
    opacity: 0.5;
}

.crown-jewel:hover {
    transform: scale(1.2) translateY(-8px);
    z-index: 200;
}

.crown-jewel.active {
    transform: scale(1.1);
    filter: drop-shadow(0 0 20px var(--jewel-color));
}

.crown-jewel.active::after {
    content: '✦';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--jewel-color);
    font-size: 1rem;
    animation: active-star 2s ease-in-out infinite;
}

@keyframes active-star {
    0%, 100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.2); }
}

.jewel-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--jewel-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    box-shadow: 0 0 30px var(--jewel-color), inset 0 0 15px rgba(255,255,255,0.6);
    border: 2px solid rgba(255,255,255,0.4);
    position: relative;
    overflow: hidden;
}

.jewel-face::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crown-jewel:hover .jewel-face::after {
    opacity: 0.6;
}

.jewel-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.3s ease;
}

.crown-jewel:hover .jewel-icon {
    transform: scale(1.1);
}

.jewel-name {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #000;
    text-shadow: 0 1px 3px rgba(255,255,255,0.8);
}

/* FLOATING HOVER PORTAL - NEVER CLIPPED */
.crown-hover-portal {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.crown-hover-portal.visible {
    opacity: 1;
}

.hover-card {
    background: var(--panel-deep);
    border: 2px solid var(--hover-color);
    border-radius: var(--radius-medium);
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 40px var(--hover-color);
    backdrop-filter: blur(12px);
    width: 280px;
    transform-origin: center;
    animation: hover-appear 0.3s var(--curve-spring);
}

.hover-card.below {
    transform-origin: top center;
}

@keyframes hover-appear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hover-arrow {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--panel-deep);
    border-right: 2px solid var(--hover-color);
    border-bottom: 2px solid var(--hover-color);
}

.hover-arrow.above {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
}

.hover-arrow.below {
    top: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(225deg);
}

.hover-title {
    display: block;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--hover-color);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.hover-domain {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.hover-meaning {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.hover-preview {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.hover-preview span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.hover-preview i {
    color: var(--hover-color);
    font-size: 0.9rem;
}

/* ============================================================================
   SEARCH SYSTEM
   ============================================================================ */
.search-section {
    margin: 2rem 0 3rem;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--justice-red);
    font-size: 1.2rem;
    opacity: 0.7;
    pointer-events: none;
    z-index: 2;
}

.search-input {
    width: 100%;
    padding: 1.5rem 1.5rem 1.5rem 4rem;
    background: var(--panel-deep);
    border: 2px solid var(--panel-edge-justice);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.2rem;
    transition: all 0.3s var(--curve-pressure);
    box-shadow: 0 0 30px rgba(0,0,0,0.3);
    font-weight: 600;
}

.search-input:focus {
    outline: none;
    border-color: var(--justice-red);
    box-shadow: 0 0 0 4px var(--justice-red-dim), 0 0 40px var(--justice-red-glow);
    transform: scale(1.01);
}

.search-input::placeholder {
    color: var(--text-tertiary);
    font-size: 1rem;
    font-style: italic;
}

.search-filters {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.search-filter {
    padding: 0.6rem 1.5rem;
    background: transparent;
    border: 1px solid var(--panel-edge-justice);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--curve-pressure);
}

.search-filter:hover {
    border-color: var(--justice-red);
    background: var(--justice-red-dim);
    color: #fff;
    transform: scale(1.02) translateY(-2px);
}

.search-filter.active {
    background: var(--justice-red);
    border-color: var(--justice-red);
    color: #000;
    font-weight: 800;
}

.search-results-count {
    margin-top: 2rem;
    padding: 1rem;
    text-align: center;
    font-size: 1.1rem;
    border-top: 1px solid var(--panel-edge-justice);
    color: var(--justice-red);
}

.search-results {
    margin-top: 2rem;
    max-height: 500px;
    overflow-y: auto;
    background: var(--panel);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--panel-edge-justice);
}

.result-group {
    margin-bottom: 1.5rem;
}

.result-group h4 {
    color: var(--justice-red);
    margin-bottom: 0.8rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

.result-item:hover {
    background: var(--justice-red-dim);
    transform: translateX(5px);
}

.result-type {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    background: var(--justice-red);
    color: #000;
    border-radius: 4px;
    text-transform: uppercase;
}

.result-title {
    color: var(--text-primary);
    font-weight: 500;
}

.result-more {
    padding: 0.5rem;
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
}

.no-results {
    text-align: center;
    padding: 3rem;
}

.no-results-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 1rem;
    display: block;
}

.no-results h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--text-tertiary);
}

/* ============================================================================
   PORTAL TABS
   ============================================================================ */
.portal-tabs {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 2rem 0;
}

.portal-tab {
    padding: 1rem 2rem;
    background: transparent;
    border: 2px solid var(--panel-edge-justice);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s var(--curve-pressure);
    text-transform: uppercase;
}

.portal-tab:hover {
    border-color: var(--justice-red);
    background: var(--justice-red-dim);
    transform: scale(1.02) translateY(-2px);
}

.portal-tab.active {
    background: var(--justice-red);
    border-color: var(--justice-red);
    color: #000;
    box-shadow: 0 0 30px var(--justice-red-glow);
}

/* ============================================================================
   PORTALS GRID
   ============================================================================ */
.portals-section {
    display: none;
    margin: 3rem 0;
}

.portals-section.active {
    display: block;
}

.portals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.portal-card {
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-edge-justice);
    border-radius: 12px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s var(--curve-pressure);
    position: relative;
    overflow: hidden;
    min-height: 250px;
}

.portal-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--justice-red);
    box-shadow: var(--shadow-justice);
}

.portal-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(800px 400px at 30% 30%, var(--justice-red-dim), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.portal-card:hover::before {
    opacity: 0.2;
}

.portal-number {
    font-size: 0.8rem;
    color: var(--justice-red);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
    font-weight: 800;
}

.portal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 900;
    margin-bottom: 1rem;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
    line-height: 1.3;
}

.portal-desc {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
    font-weight: 500;
}

.portal-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1rem;
    position: relative;
    z-index: 2;
    font-weight: 600;
}

.portal-meta span:last-child {
    color: var(--justice-red);
    font-weight: 800;
}

/* ============================================================================
   PORTAL DETAIL PANEL
   ============================================================================ */
.portal-detail-panel {
    display: none;
    margin-top: 2rem;
    animation: slide-up 0.5s var(--curve-smooth);
}

.portal-detail-panel.active {
    display: block;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.back-button {
    padding: 0.6rem 1.2rem;
    background: var(--justice-red-dim);
    border: 1px solid var(--justice-red);
    border-radius: 8px;
    color: var(--justice-red);
    cursor: pointer;
    font-weight: 800;
    transition: all 0.2s var(--curve-pressure);
}

.back-button:hover {
    background: var(--justice-red);
    color: #000;
    transform: translateX(-4px) scale(1.02);
}

.panel-title {
    font-size: 2rem;
    font-family: 'Cinzel', serif;
    color: var(--justice-red);
}

.portal-detail-content {
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-edge-justice);
    border-radius: 12px;
    padding: 2rem;
}

/* ============================================================================
   COLOR MEANING PANEL
   ============================================================================ */
.color-meaning {
    margin: 3rem 0;
    padding: 2rem;
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-edge-justice);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    animation: justice-breathe 4.5s var(--curve-breathe) infinite;
    animation-delay: 0.3s;
    --card-index: 3;
}

.color-meaning:hover {
    animation-play-state: paused;
    border-color: var(--justice-red);
    transform: scale(1.01);
}

@keyframes justice-breathe {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }
    50% {
        transform: scale(1.01);
        box-shadow: 0 8px 24px var(--justice-red-dim);
    }
}

.meaning-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}

.meaning-color {
    width: 60px;
    height: 60px;
    border-radius: 8px; /* Square for justice - sharp */
    background: var(--justice-red);
    box-shadow: 0 0 30px var(--justice-red);
}

.meaning-title {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    color: var(--justice-red);
}

.meaning-text {
    position: relative;
    z-index: 2;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    max-width: 800px;
    font-weight: 500;
}

.meaning-text strong {
    color: var(--justice-red);
}

/* ============================================================================
   PRESENCE BUBBLES
   ============================================================================ */
.presence-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.presence-bubble {
    background: var(--panel-deep);
    border: 1px solid var(--justice-red);
    border-radius: 8px; /* Sharper */
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px var(--justice-red-glow);
    animation: bubble-appear 0.3s var(--curve-spring);
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.2s var(--curve-pressure);
    position: relative;
}

.presence-bubble:hover {
    transform: scale(1.02) translateX(-5px);
    border-color: var(--justice-gold);
    box-shadow: 0 0 30px var(--justice-gold);
}

.presence-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: #000;
    box-shadow: 0 0 15px currentColor;
}

.presence-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.presence-location {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.presence-role {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--panel-deep);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid currentColor;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.presence-bubble:hover .presence-role {
    opacity: 1;
}

@keyframes bubble-appear {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================================================================
   JOURNEY PATH
   ============================================================================ */
.journey-path {
    position: fixed;
    top: 100px;
    left: 20px;
    z-index: 9998;
    background: var(--panel-deep);
    border: 1px solid var(--justice-red);
    border-radius: 8px;
    padding: 8px 16px;
    backdrop-filter: blur(8px);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 20px var(--justice-red-glow);
    animation: journey-appear 0.5s var(--curve-spring);
    pointer-events: none;
    font-weight: 600;
}

.journey-icon {
    color: var(--justice-red);
    font-size: 1rem;
}

.journey-steps {
    display: flex;
    gap: 5px;
    color: var(--text-secondary);
}

.journey-step {
    display: flex;
    align-items: center;
    gap: 5px;
}

.journey-step.active {
    color: var(--justice-red);
    font-weight: 800;
}

.journey-step::after {
    content: '→';
    margin-left: 5px;
    color: var(--text-tertiary);
}

.journey-step:last-child::after {
    display: none;
}

@keyframes journey-appear {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================================================================
   3D CARDS
   ============================================================================ */
.portal-card {
    transition: transform 0.6s var(--curve-3d);
    transform-style: preserve-3d;
    position: relative;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: inherit;
    padding: 2rem;
    background: inherit;
    border: inherit;
    box-shadow: inherit;
    top: 0;
    left: 0;
}

.card-back {
    transform: rotateY(180deg);
    background: var(--panel-deep);
    border-color: var(--justice-red);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.card-back h4 {
    color: var(--justice-red);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 900;
}

.card-back p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.card-back .btn {
    background: var(--justice-red-dim);
    border: 1px solid var(--justice-red);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    color: var(--justice-red);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s ease;
}

.card-back .btn:hover {
    background: var(--justice-red);
    color: #000;
}

.portal-card.flipped {
    transform: rotateY(180deg);
}

/* ============================================================================
   FOOTER
   ============================================================================ */
.footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(214, 30, 59, 0.2);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    font-weight: 600;
}

.quantum-signature {
    margin-top: 1rem;
    font-size: 0.7rem;
    color: var(--justice-red);
    letter-spacing: 0.2em;
    font-weight: 700;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 1000px) {
    .hero {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .portals-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .wrap { padding: 1rem; }
    .title { font-size: 2rem; }
    .stats { flex-direction: column; gap: 1rem; }
    .meaning-header { flex-direction: column; text-align: center; }
    
    .portal-tabs {
        flex-direction: column;
        align-items: center;
    }
    
    .portal-tab {
        width: 100%;
        max-width: 300px;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: center;
    }
    
    .search-filter {
        width: 100%;
        max-width: 300px;
    }
    
    .crown-jewel {
        width: 70px;
        height: 70px;
    }
    
    .jewel-icon {
        font-size: 1.6rem;
    }
    
    .jewel-name {
        font-size: 0.65rem;
    }
    
    .journey-path {
        top: auto;
        bottom: 20px;
        left: 20px;
    }
}

@media (max-width: 480px) {
    .crown-jewel {
        width: 60px;
        height: 60px;
    }
    
    .jewel-icon {
        font-size: 1.4rem;
    }
    
    .jewel-name {
        font-size: 0.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
    
    .quantum-reality-layer {
        display: none;
    }
}