/* ── Loading overlay — Lani Boot Sequence ────────── */
/* ── Boot Overlay ─────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.04);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Storage-contract gate replaces the animated boot scene before any workspace
   data or runtime worker opens. The three offset cells echo Prime's graph
   topology while making the destructive boundary unmistakable. */
.loading-overlay.storage-contract-gate {
    padding: 24px;
    box-sizing: border-box;
    background:
        radial-gradient(circle at 50% 35%, rgba(0, 180, 234, 0.08), transparent 34%),
        var(--bg-primary);
}
.storage-contract-card {
    width: min(520px, 100%);
    padding: 36px;
    box-sizing: border-box;
    border: 1px solid color-mix(in srgb, var(--border) 80%, #00b4ea 20%);
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg-panel) 94%, #00b4ea 6%);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
    color: var(--text-primary);
}
.storage-contract-mark {
    position: relative;
    width: 42px;
    height: 28px;
    margin-bottom: 22px;
}
.storage-contract-mark span {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(0, 180, 234, 0.8);
    border-radius: 5px;
    transform: rotate(45deg);
}
.storage-contract-mark span:nth-child(1) { left: 0; top: 5px; }
.storage-contract-mark span:nth-child(2) { left: 12px; top: 5px; border-color: rgba(237, 26, 119, 0.72); }
.storage-contract-mark span:nth-child(3) { left: 24px; top: 5px; border-color: rgba(192, 132, 252, 0.72); }
.storage-contract-role {
    margin-bottom: 8px;
    color: #5dd8ff;
    font: 600 10px/1.2 'SF Mono', 'Consolas', monospace;
    letter-spacing: 0.16em;
}
.storage-contract-card h1 {
    margin: 0 0 12px;
    font-size: clamp(24px, 5vw, 34px);
    font-weight: 650;
    letter-spacing: -0.035em;
}
.storage-contract-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
}
.storage-contract-detail {
    margin-top: 16px !important;
    padding: 10px 12px;
    border-left: 2px solid rgba(237, 26, 119, 0.65);
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-muted) !important;
    font: 11px/1.55 'SF Mono', 'Consolas', monospace !important;
    overflow-wrap: anywhere;
}
.storage-contract-action {
    margin-top: 24px;
    padding: 11px 16px;
    border: 1px solid rgba(0, 180, 234, 0.58);
    border-radius: 7px;
    background: rgba(0, 180, 234, 0.14);
    color: #dff8ff;
    font: 600 13px/1.2 inherit;
    cursor: pointer;
}
.storage-contract-action:hover { background: rgba(0, 180, 234, 0.22); }
.storage-contract-action:focus-visible {
    outline: 2px solid #5dd8ff;
    outline-offset: 3px;
}
.storage-contract-footnote {
    margin-top: 18px !important;
    color: var(--text-muted) !important;
    font-size: 11px !important;
}

@media (max-width: 560px) {
    .storage-contract-card { padding: 28px 22px; }
}

/* 3D scene container */
.boot-scene {
    position: relative;
    width: 340px;
    height: 340px;
    perspective: 900px;
}
.boot-scene-inner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
}

/* Volumetric background glow */
.boot-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.boot-glow::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,180,234,0.08) 0%, rgba(237,26,119,0.04) 40%, transparent 70%);
    animation: glowPulse 3s ease-in-out infinite;
}
@keyframes glowPulse {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

/* Central core — spinning rings + hexagon outlines */
.boot-core {
    position: absolute;
    left: 0; top: 0;
    width: 100px;
    height: 100px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.boot-core-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(0,180,234,0.15);
}
.boot-core-ring:nth-child(1) {
    animation: spin 10s linear infinite;
    transform: rotateX(60deg);
}
.boot-core-ring:nth-child(2) {
    inset: 8px;
    animation: spin 15s linear infinite reverse;
    transform: rotateY(60deg);
    border-color: rgba(237,26,119,0.15);
}
.boot-core-ring:nth-child(3) {
    inset: 20px;
    animation: spin 8s linear infinite;
    border-style: dashed;
    border-color: rgba(255,255,255,0.06);
}
@keyframes spin { to { transform: rotate(360deg); } }

.boot-core-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 20px rgba(255,255,255,0.8), 0 0 40px rgba(0,180,234,0.4);
    animation: corePulse 2s ease-in-out infinite;
}
@keyframes corePulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255,255,255,0.8), 0 0 40px rgba(0,180,234,0.4); }
    50% { box-shadow: 0 0 30px rgba(255,255,255,1), 0 0 60px rgba(0,180,234,0.6); }
}

/* Orbiting electron dots around core */
.boot-electron {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100%;
    height: 100%;
    transform-origin: center;
}
.boot-electron:nth-child(5) { animation: spin 3s linear infinite; }
.boot-electron:nth-child(6) { animation: spin 5s linear infinite reverse; }
.boot-electron-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}
.boot-electron:nth-child(5) .boot-electron-dot {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--accent);
}
.boot-electron:nth-child(6) .boot-electron-dot {
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-magenta);
    color: var(--accent-magenta);
}

/* Satellite nucleus node */
.boot-node {
    position: absolute;
    left: 0;
    top: 0;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%) rotate(45deg);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(15,15,15,0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.5s, box-shadow 0.5s;
    pointer-events: none;
}
.boot-node.active {
    border-color: var(--accent);
    box-shadow: 0 0 24px rgba(0,180,234,0.3);
}
.boot-node.ready {
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(0,180,234,0.2);
}
.boot-node-icon {
    transform: rotate(-45deg);
    font-size: 16px;
    opacity: 0.5;
    transition: opacity 0.5s;
}
.boot-node.active .boot-node-icon,
.boot-node.ready .boot-node-icon { opacity: 1; }

/* Connection line from center to node */
.boot-line {
    position: absolute;
    left: 0;
    top: 0;
    height: 1px;
    transform-origin: left center;
    pointer-events: none;
    opacity: 0.15;
    transition: opacity 0.5s;
}
.boot-line.active { opacity: 0.6; }

/* Energy pulse traveling along a connection */
.boot-pulse {
    position: absolute;
    left: 0;
    top: 0;
    height: 1px;
    transform-origin: left center;
    pointer-events: none;
    opacity: 0;
}
.boot-pulse.active { opacity: 0.7; }
.boot-pulse-head {
    position: absolute;
    right: 0;
    top: 50%;
    width: 4px;
    height: 4px;
    transform: translate(50%, -50%);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px #fff;
}

/* Data dust particles */
.boot-dust {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    pointer-events: none;
}

/* Boot status text + progress */
.boot-status {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
}
.boot-phase-text {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 0.4s;
    font-family: 'SF Mono','Consolas','Monaco',monospace;
}
.boot-phase-text.active { color: var(--text-secondary); }

.loading-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
    transition: opacity 0.3s;
}

.progress-bar-container {
    width: 200px;
    height: 2px;
    background: rgba(46, 46, 46, 0.5);
    border-radius: 1px;
    margin-top: 8px;
    overflow: hidden;
    display: none;
    position: relative;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #fbbf24);
    border-radius: 1px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* Subsystem status indicators */
.boot-subsystems {
    display: flex;
    gap: 18px;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.6s;
}
.boot-subsystems.visible { opacity: 1; }
.boot-subsystem {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: 'SF Mono','Consolas','Monaco',monospace;
    color: var(--text-muted);
    transition: color 0.4s;
}
.boot-subsystem.active { color: var(--text-secondary); }
.boot-subsystem.ready { color: var(--accent); }
.boot-subsystem-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.4s, box-shadow 0.4s;
}
.boot-subsystem.active .boot-subsystem-dot {
    background: var(--text-secondary);
    animation: dotPulse 1s ease-in-out infinite;
}
.boot-subsystem.ready .boot-subsystem-dot {
    background: var(--accent);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
    animation: none;
}
@keyframes dotPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Hide the old spinner */
.loading-spinner { display: none !important; }
