/* maljosim.com - Crystalline Contemplation Experience */
/* Colors: #2a0a14 #5c1a2a #8b2e42 #b8536f #f5ede0 #e8d5b7 #c9a34f #1a0610 #3d1020 */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a0610;
    font-family: 'DM Sans', sans-serif;
    color: #f5ede0;
    cursor: crosshair;
}

body {
    --mouse-x: 50%;
    --mouse-y: 50%;
    --bg-color: #2a0a14;
    --cream-color: #f5ede0;
    --gold-opacity: 0.15;
    transition: background-color 2s ease;
    background-color: var(--bg-color);
}

body.dwell-active {
    --bg-color: #3d1020;
    --cream-color: #e8d5b7;
    --gold-opacity: 1;
}

/* Layer 0: Background wireframe */
#background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#wireframe-svg {
    opacity: 0.08;
}

#wireframe-svg line {
    stroke: #f5ede0;
    stroke-width: 1;
}

/* Layer 1: Voronoi cells */
#voronoi-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#voronoi-svg polygon.voronoi-cell {
    fill: #5c1a2a;
    fill-opacity: 0.5;
    stroke: #f5ede0;
    stroke-opacity: 0.12;
    stroke-width: 1;
    transition: fill-opacity 400ms ease, stroke-opacity 400ms ease, fill 400ms ease;
    cursor: crosshair;
}

#voronoi-svg polygon.voronoi-cell:hover,
#voronoi-svg polygon.voronoi-cell.active {
    fill-opacity: 0.9;
    stroke-opacity: 0.3;
}

#voronoi-svg polygon.voronoi-cell.cell-alt-1 {
    fill: #3d1020;
}

#voronoi-svg polygon.voronoi-cell.cell-alt-2 {
    fill: #8b2e42;
    fill-opacity: 0.4;
}

#voronoi-svg polygon.voronoi-cell.cell-alt-3 {
    fill: #2a0a14;
    fill-opacity: 0.7;
}

/* Layer 2: Floating fragments */
#fragment-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

#fragment-svg polygon.fragment {
    fill: none;
    stroke: #f5ede0;
    stroke-width: 1;
    opacity: 0.06;
}

/* Cursor follow light */
#cursor-light {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    background: radial-gradient(
        circle 300px at var(--mouse-x) var(--mouse-y),
        rgba(201, 163, 79, var(--gold-opacity)),
        transparent
    );
    transition: background 0.1s ease;
}

/* Shard bloom container */
#shard-bloom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    pointer-events: none;
}

.shard {
    position: absolute;
    width: 12px;
    height: 20px;
    background: #c9a34f;
    opacity: 0;
    clip-path: polygon(20% 0%, 80% 0%, 100% 60%, 50% 100%, 0% 60%);
    will-change: transform, opacity;
    pointer-events: none;
    animation: shard-bloom 1.5s ease-out forwards;
}

@keyframes shard-bloom {
    0% {
        opacity: 0.4;
        transform: scale(0) rotate(0deg) translate(0, 0);
    }
    20% {
        opacity: 0.4;
        transform: scale(1) rotate(var(--shard-rotate)) translate(0, 0);
    }
    100% {
        opacity: 0;
        transform: scale(1) rotate(var(--shard-rotate)) translate(var(--shard-tx), var(--shard-ty));
    }
}

/* Sacred center */
#sacred-center {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.mandala-watermark {
    position: absolute;
    width: 400px;
    height: 400px;
    opacity: 0.03;
    pointer-events: none;
}

.mandala-watermark line,
.mandala-watermark polygon {
    stroke: #f5ede0;
    stroke-width: 0.5;
    fill: none;
}

#sacred-polygon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 3rem;
    clip-path: polygon(50% 0%, 90% 15%, 100% 55%, 80% 90%, 30% 100%, 5% 70%, 10% 25%);
    background: linear-gradient(135deg, #3d1020, #5c1a2a);
    animation: sacred-pulse 4s ease-in-out infinite;
}

@keyframes sacred-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(201, 163, 79, 0.1);
        filter: drop-shadow(0 0 20px rgba(201, 163, 79, 0.1));
    }
    50% {
        box-shadow: 0 0 40px rgba(201, 163, 79, 0.2);
        filter: drop-shadow(0 0 40px rgba(201, 163, 79, 0.2));
    }
}

#domain-name {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 8rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #f5ede0;
    white-space: nowrap;
    text-shadow: 0 0 30px rgba(201, 163, 79, 0.15);
}

/* Cell contents */
#cell-contents {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
}

.cell-content {
    position: absolute;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
    pointer-events: none;
    max-width: 280px;
    padding: 1rem;
}

.cell-content.visible {
    opacity: 1;
    transform: translateY(0);
}

.cell-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: #f5ede0;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.cell-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.2vw, 1.1rem);
    line-height: 1.65;
    color: #e8d5b7;
}

.cell-text .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.cell-content.visible .word {
    opacity: 1;
    transform: translateY(0);
}

/* Fracture lines */
.fracture-line {
    stroke: #f5ede0;
    stroke-width: 1;
    opacity: 0.15;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #domain-name {
        font-size: clamp(2rem, 8vw, 4rem);
    }
    
    #sacred-polygon {
        padding: 1.5rem 2rem;
    }
    
    .cell-content {
        max-width: 200px;
    }
    
    .mandala-watermark {
        width: 250px;
        height: 250px;
    }
}
