/* static/css/hexflake-card.css */

.sandbox-container {
    display: flex; flex-wrap: wrap; gap: 4rem; padding: 4rem;
    justify-content: center; align-items: center;
    background: #050508; min-height: 100vh;
}

/* =========================================
   THE OMNI-SHELL BASE & INTERNAL LAYOUT
   ========================================= */
.omni-card {
    /* Clamp fluidly scales between 280px (mobile) and 320px (desktop) */
    --card-w: clamp(280px, 85vw, 320px);
    --card-h: calc(var(--card-w) * 1.4375); /* Maintains exact 320x460 proportion */
    
    --frame-bg: rgba(255, 255, 255, 0.12);
    --frame-pad: 1px;
    --glow: 0 20px 50px rgba(0,0,0,0.8);
    
    width: var(--card-w);
    height: var(--card-h);
    position: relative;
    border-radius: 18px;
    box-shadow: var(--glow);
    transform-style: preserve-3d;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.card-border {
    position: absolute; inset: 0;
    border-radius: 18px;
    padding: var(--frame-pad);
    background: var(--frame-bg);
    transition: background 0.3s ease, padding 0.3s ease;
}

.card-inner {
    width: 100%; height: 100%;
    border-radius: 16px;
    background: #0d1520; 
    position: relative;
    overflow: hidden;
}

/* Content Layout */
.card-content {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; 
    align-items: center; justify-content: space-between;
    padding: 1.5rem 1rem;
    z-index: 5;
}

.artifact-label {
    font-size: 1rem; letter-spacing: 0.2em;
    color: #94a3b8; 
}

.artifact-visual-container {
    width: 90%; aspect-ratio: 1/1;
    display: flex; justify-content: center; align-items: center;
    background: rgba(15, 23, 42, 0.6); 
    border: 1px solid rgba(56, 189, 248, 0.15); 
    border-radius: 12px; 
    box-shadow: inset 0 0 2rem rgba(0,0,0,0.8); 
    /* Absolute Centering Anchors */
    position: relative; 
    margin: 0 auto;
    transition: all 0.4s ease;
}

.artifact-visual-container canvas {
    /* Forcible Mathematical Centering */
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%; max-height: 90%;
    object-fit: contain;
    display: block;
    margin: 0;
}

/* UI Controls */
.artifact-desc-container {
    position: relative; /* Shifted from inline */
    display: flex; flex-direction: row; align-items: center; gap: 1.2em;
    background: rgba(30, 41, 59, 0.7); 
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 8px; padding: 0.5rem 1rem;
    width: 90%; justify-content: center;
    box-sizing: border-box; /* Forces border obedience */
}

/* New class targeting the presence of the copy button */
.artifact-desc-container.has-controls {
    padding-right: 3.5rem; 
}

.artifact-control-box {
    position: absolute; /* Shifted from inline */
    right: 0.5rem; 
    top: 50%; 
    transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 0.4em; padding-left: 0.8em;
    border-left: 1px solid rgba(56, 189, 248, 0.15); 
}

.btn-icon {
    display: flex; align-items: center; justify-content: center;
    width: 2.8em; height: 2.8em; border-radius: 0.6em;
    background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.3);
    color: #7dd3fc; cursor: pointer; transition: all 0.2s ease;
}
.btn-icon:hover { background: rgba(56, 189, 248, 0.3); box-shadow: 0 0 1em rgba(56, 189, 248, 0.2); }
.btn-icon:active { background: #7dd3fc; color: #000; }

.artifact-footer {
    font-size: 0.75rem; color: rgba(255,255,255,0.3); 
    letter-spacing: 0.1em;
}

/* =========================================
   DYNAMIC TEXT SIZING (The Grid Proportions)
   ========================================= */
.omni-card[data-tier="8"] .dna-block { 
    font-size: calc(var(--card-w) * 0.07); letter-spacing: 0.4em; line-height: 1.2; 
}
.omni-card[data-tier="32"] .dna-block { 
    font-size: calc(var(--card-w) * 0.055); letter-spacing: 0.3em; line-height: 1.4; 
}
.omni-card[data-tier="128"] .dna-block { 
    font-size: calc(var(--card-w) * 0.04); letter-spacing: 0.15em; line-height: 1.4; 
}
.omni-card[data-tier="512"] .dna-block { 
    font-size: calc(var(--card-w) * 0.024); letter-spacing: 0.1em; line-height: 1.5; 
    text-shadow: 0 0 0.3em rgba(102, 179, 255, 0.6); 
}

/* =========================================
   LAYER ARCHITECTURE (Mechanics & Effects)
   ========================================= */
.card-snow-layer, .holo-bg, .holo-sheen, .sparkles-container, .glare {
    position: absolute; inset: 0; pointer-events: none; display: none;
}

/* --- TIER 32: THE FROST RESONANCE (Uncommon) --- */
.omni-card[data-tier="32"] { 
    --frame-pad: 2px; 
    --frame-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.9), rgba(2, 132, 199, 0.1) 40%, rgba(2, 132, 199, 0.1) 60%, rgba(56, 189, 248, 0.9)); 
    --glow: 0 25px 60px rgba(56, 189, 248, 0.25); 
}
.omni-card[data-tier="32"] .artifact-visual-container {
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.15) 0%, rgba(15, 23, 42, 0.8) 70%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: inset 0 0 2rem rgba(56, 189, 248, 0.1), 0 0 15px rgba(56, 189, 248, 0.15);
}
.omni-card[data-tier="32"] .glare {
    display: block;
    background: linear-gradient(105deg, transparent 40%, rgba(186, 230, 253, 0.05) 45%, rgba(186, 230, 253, 0.25) 50%, rgba(186, 230, 253, 0.05) 55%, transparent 60%);
    animation: glareSweep 8s ease-in-out infinite reverse; 
}

/* The Distant Starfield (Tier 32 Vault) */
.omni-card[data-tier="32"] .artifact-visual-container::before,
.omni-card[data-tier="32"] .artifact-visual-container::after {
    content: ''; 
    position: absolute; 
    inset: 0; 
    border-radius: 12px;
    pointer-events: none;
    z-index: 1;
}

/* Layer 1: Slow, deep pulse */
.omni-card[data-tier="32"] .artifact-visual-container::before {
    background-image: 
        radial-gradient(1.5px 1.5px at 15% 25%, #ffffff, transparent),
        radial-gradient(2px 2px at 75% 15%, #7dd3fc, transparent),
        radial-gradient(1px 1px at 85% 75%, #bae6fd, transparent),
        radial-gradient(1.5px 1.5px at 25% 80%, #ffffff, transparent);
    animation: frostTwinkle 4s ease-in-out infinite alternate;
}

/* Layer 2: Offset, asynchronous pulse */
.omni-card[data-tier="32"] .artifact-visual-container::after {
    background-image: 
        radial-gradient(1px 1px at 50% 10%, #ffffff, transparent),
        radial-gradient(2px 2px at 85% 45%, #e0f2fe, transparent),
        radial-gradient(1.5px 1.5px at 15% 60%, #7dd3fc, transparent),
        radial-gradient(1px 1px at 50% 85%, #bae6fd, transparent);
    animation: frostTwinkle 5.5s ease-in-out infinite alternate-reverse;
}

@keyframes frostTwinkle {
    0% { opacity: 0.1; }
    100% { opacity: 0.9; }
}

/* Ensure the canvas sits slightly above the stars */
.omni-card[data-tier="32"] .artifact-visual-container canvas {
    z-index: 2;
}

/* --- TIER 128: FOIL SNOW MECHANICS (Rare) --- */
.omni-card[data-tier="128"] .card-snow-layer {
    display: block; z-index: 1; transform-style: preserve-3d;
}
.snowflake { 
    position: absolute; width: var(--s); height: var(--s); 
    background: linear-gradient(120deg,#ff4d4d,#ffcc33,#33ff99,#33ccff,#9966ff,#ff4dd2); 
    mask-image: var(--mask); -webkit-mask-image: var(--mask);
    mix-blend-mode: screen; opacity: 0; 
    transform: translate3d(var(--x), var(--y), var(--z)); 
}
.mask-0 { --mask: repeating-conic-gradient(black 0 12deg, transparent 12deg 24deg), radial-gradient(circle, black 45%, transparent 65%); }
.mask-1 { --mask: repeating-conic-gradient(black 0 8deg, transparent 8deg 16deg), radial-gradient(circle, black 40%, transparent 70%); }
.mask-2 { --mask: linear-gradient(black, black), repeating-conic-gradient(black 0 30deg, transparent 30deg 60deg); }
.mask-3 { --mask: radial-gradient(circle, black 50%, transparent 70%); }

/* --- TIER 512: HOLOGRAPHIC MECHANICS (Mythic) --- */
.omni-card[data-tier="512"] .holo-bg, 
.omni-card[data-tier="512"] .holo-sheen, 
.omni-card[data-tier="512"] .sparkles-container, 
.omni-card[data-tier="512"] .glare { 
    display: block; 
}

.holo-bg {
    background: linear-gradient(135deg, #0a0a1a 0%, #0d1830 20%, #0a1525 40%, #0d1030 60%, #080d1a 80%, #0a0a1a 100%);
    overflow: hidden; border-radius: 16px;
}
.holo-snow-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.holo-prism {
    position: absolute; inset: 0;
    background: linear-gradient(115deg, transparent 20%, rgba(255,120,120,0.06) 25%, rgba(255,200,80,0.06) 30%, rgba(120,255,120,0.06) 35%, rgba(80,200,255,0.06) 40%, rgba(180,80,255,0.06) 45%, transparent 50%, transparent 70%, rgba(255,120,120,0.04) 75%, rgba(80,200,255,0.04) 80%, transparent 85%);
    mix-blend-mode: screen; z-index: 2;
    animation: prismShift 8s ease-in-out infinite alternate;
}
@keyframes prismShift { 0% { transform: translateX(-10%) rotate(-2deg); opacity: 0.6; } 100% { transform: translateX(10%) rotate(2deg); opacity: 1; } }

.holo-sheen {
    opacity: 0; z-index: 6;
    background: conic-gradient(from 0deg at var(--mx, 50%) var(--my, 50%), hsla(0,100%,70%,0.15), hsla(60,100%,70%,0.15), hsla(120,100%,70%,0.15), hsla(180,100%,70%,0.15), hsla(240,100%,70%,0.15), hsla(300,100%,70%,0.15), hsla(360,100%,70%,0.15));
    mix-blend-mode: screen; transition: opacity 0.3s;
}
.omni-card[data-active="true"]:hover .holo-sheen { opacity: 1; }

.sparkles-container { z-index: 7; }
.sparkle {
    position: absolute; width: 2px; height: 2px; border-radius: 50%;
    background: white; box-shadow: 0 0 4px 2px rgba(255,255,255,0.8);
    animation: sparkleAnim var(--dur, 3s) ease-in-out infinite var(--delay, 0s);
}
@keyframes sparkleAnim { 0%, 100% { opacity: 0; transform: scale(0); } 50% { opacity: 1; transform: scale(1); } }

.glare {
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.06) 45%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 55%, transparent 60%);
    animation: glareSweep 6s ease-in-out infinite; z-index: 10;
}
@keyframes glareSweep { 0% { transform: translateX(-100%) rotate(10deg); } 40%, 100% { transform: translateX(200%) rotate(10deg); } }

/* =========================================
   TIER BASELINE (Borders & Shadows)
   ========================================= */
.omni-card[data-tier="128"] {
    --frame-pad: 2px; 
    --frame-bg: linear-gradient(135deg, #38bdf8, #818cf8, #c084fc);
    --glow: 0 30px 70px rgba(139, 92, 246, 0.15); 
}

.omni-card[data-tier="512"] { 
    --frame-pad: 3px; 
    --glow: 0 40px 80px rgba(250, 204, 21, 0.2); 
}

.omni-card[data-frame="gold"] { 
    --frame-bg: linear-gradient(135deg, #c8a96e 0%, #f0d080 15%, #a87840 25%, #e8c060 35%, #ffd878 45%, #b08840 55%, #e8c060 65%, #f0d080 75%, #c8a96e 85%, #ffd878 100%); 
}

/* =========================================
   IDENTITY UI COMPONENTS 
   (Shared Avatar & DNA Badge Architecture)
   ========================================= */

/* The Avatar Scaffolding */
.profile-identity-group {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.profile-avatar-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    width: 160px;
    align-self: stretch; 
    /* NEW: Forces the 3D vanishing point to the center of the element, killing the tilt */
    perspective-origin: 50% 50%; 
}

.profile-avatar-container svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Adds an ambient, icy glow behind the animated SVG */
    filter: drop-shadow(0 0 15px rgba(56, 189, 248, 0.4)); 
}

/* 3D Core Animation */
@keyframes masterSpin {
    from { transform: rotateX(0deg) rotateY(0deg); }
    to { transform: rotateX(0deg) rotateY(-360deg); }
}

/* Ensure wrappers respect the 3D depth and force the spin */
#master-identity-wrapper, 
#landing-avatar-wrapper {
    transform-style: preserve-3d;
    transform-origin: center center;
    /* The !important flag punches through landing.css stagnation rules */
    animation: masterSpin 20s linear infinite !important; 
}

/* --- High-Density "Chip" Optimization (Overrides for Identity Badge) --- */
/* Base DNA Block Styling */
.dna-block {
    background: transparent; 
    border: none; 
    outline: none; 
    overflow: hidden; /* Hides internal scrollbars */
    
    font-family: 'Consolas', 'Courier New', monospace; 
    color: #7dd3fc; 
    text-shadow: 0 0 0.5em rgba(102, 179, 255, 0.4);
    text-align: center; 
    
    width: 100%; 
    resize: none; /* Destroys the draggable resize handle */
    white-space: pre-wrap; 
    word-break: break-all; 
    
    display: block; 
    margin: 0 auto;
}

.master-dna-container {
    width: fit-content;
    padding: 0.8rem 1rem; /* Slightly increased breathing room */
    background: rgba(8, 12, 24, 0.85); 
    border: 1px solid rgba(56, 189, 248, 0.4); 
    border-radius: 6px; 
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.9); 
    display: flex;
    justify-content: center;
    align-items: center;
}

.master-dna-container .dna-block {
    width: 8.5ch; /* Expanded to prevent character clipping against letter-spacing */
    height: 72px; /* Expanded to comfortably fit 4 rows of 6 characters */
    line-height: 1.3; /* Increased vertical breathing room */
    letter-spacing: 0.15em;
    padding: 0;
    margin: 0;
    text-align: center;
    
    /* THE DEADBOLT: Nuke all default browser textarea formatting */
    border: none !important; 
    outline: none !important;
    background-color: transparent !important;
    resize: none !important;
    overflow: hidden !important; /* Kills the scrollbar */
    
    font-size: 0.85rem;
    color: #7dd3fc;
    text-shadow: 0 0 5px rgba(56, 189, 248, 0.6);
    white-space: pre-wrap !important; 
    word-break: break-all;
}

/* =========================================
   DORMANT ARTIFACT STATE (Empty Vaults)
   ========================================= */

.vault-carousel[data-artifacts="[]"] {
    position: relative;
}

.vault-carousel[data-artifacts="[]"]::after {
    content: "UNSEQUENCED";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(56, 189, 248, 0.6);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.2em;
    font-size: .64rem;
    background: rgba(15, 23, 42, 0.85);
    padding: 0.4rem .64rem;
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 4px;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.9);
    animation: dormantFlicker 4s infinite alternate;
}

/* De-power the empty card */
.vault-carousel[data-artifacts="[]"] .omni-card {
    filter: grayscale(100%) opacity(0.25) blur(2px);
    pointer-events: none;
}

/* Hide the navigation arrows and counter when empty */
.vault-carousel[data-artifacts="[]"] .mini-arrow,
.vault-carousel[data-artifacts="[]"] .vault-counter {
    display: none !important;
}

@keyframes dormantFlicker {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(56, 189, 248, 0.5); }
    50% { opacity: 0.6; text-shadow: none; }
    55% { opacity: 0.9; }
    60% { opacity: 0.5; }
}

/* =========================================
   CAPTURE MODAL CLOSE BUTTON OVERRIDE
   ========================================= */
#hex-close-btn, #zen-viewer-close {
    position: absolute;
    width: 40px !important;
    height: 40px !important;
    font-size: 1.4rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6em;
    background: rgba(56, 189, 248, 0.1) !important;
    border: 1px solid rgba(56, 189, 248, 0.3) !important;
    color: #7dd3fc !important;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

#hex-close-btn:hover, #zen-viewer-close:hover {
    background: rgba(56, 189, 248, 0.3) !important;
    box-shadow: 0 0 1em rgba(56, 189, 248, 0.2) !important;
}

#hex-close-btn:active, #zen-viewer-close:active {
    background: #7dd3fc !important;
    color: #000 !important;
}

/* Specific Placements */
#hex-close-btn {
    top: -1.5rem;
    right: -3.5rem;
    z-index: 50;
}

#zen-viewer-close {
    top: 2rem;
    right: 3rem;
    z-index: 100000 !important;
}

@media (max-width: 480px) {
    #hex-close-btn { right: 0 !important; top: -3rem !important; }
    #zen-viewer-close { right: 1.5rem; top: 1.5rem; }
}

/* =========================================
   MOBILE RESPONSIVE: MODAL CLOSE BUTTON
   ========================================= */
@media (max-width: 480px) {
    #hex-close-btn {
        /* Pulls the button inward so it aligns perfectly with the right edge */
        right: 0 !important; 
        /* Pushes it higher up so it sits completely above the card, avoiding overlap */
        top: -3rem !important; 
    }
}

/* =========================================
   THE ZEN VIEWER (Global Overlay)
   ========================================= */

/* Base UI Transitions for smooth fading */
#main-content-container,
#hexflake-modal,
#stake-drawer-modal {
    transition: opacity 1.5s ease !important; /* Increased to 1.5s */
}

/* Fade out everything except the background canvases and the Zen Viewer */
body.artifact-zen-mode #main-content-container,
body.artifact-zen-mode #hexflake-modal,
body.artifact-zen-mode #stake-drawer-modal {
    opacity: 0 !important;
    pointer-events: none !important;
}

#zen-artifact-viewer {
    position: fixed;
    inset: 0;
    z-index: 99999 !important;
    
    /* Deepened the opacity at all stages to swallow the background contrast */
    background: radial-gradient(circle at center, rgba(10, 15, 30, 0.98) 0%, rgba(5, 8, 15, 0.85) 55%, rgba(0, 0, 0, 0.6) 100%);
    
    /* Increased blur to separate the sharp hexflake from the background elements */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease;
}

#zen-artifact-viewer.active {
    opacity: 1;
    pointer-events: auto;
}

.zen-viewer-inner {
    position: relative;
    width: 85vmin;
    height: 85vmin;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: scale(0.7); 
    transition: transform 1.5s cubic-bezier(0.2, 0.8, 0.2, 1); /* Increased to 1.5s */
}

#zen-artifact-viewer.active .zen-viewer-inner {
    transform: scale(1);
}

/* =========================================
   LAYERED CLICKS (Card -> Modal -> Zen)
   ========================================= */

/* 1. All cards act as buttons to open the modal */
.omni-card {
    cursor: pointer;
}

/* Ensure text selection still works on the DNA */
.omni-card .dna-block {
    cursor: text;
}

/* 2. ONLY the hexflake inside the active modal triggers Zen Mode */
#hexflake-modal .artifact-visual-container {
    cursor: zoom-in;
}