/* Base Reset & Variables */
:root {
    --void: #0a0a0c;
    --deep: #12121a;
    --ripple: rgba(120, 140, 255, 0.15);
    --ripple-bright: rgba(150, 170, 255, 0.4);
    --entity-core: #a0b0ff;
    --entity-glow: rgba(140, 160, 255, 0.6);
    --text: #e8e8f0;
    --text-dim: rgba(200, 200, 220, 0.6);
    --accent: #8090ff;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--void);
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--text);
    cursor: none;
}

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

/* Custom cursor - a subtle point of light */
body::after {
    content: '';
    position: fixed;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 10000;
    left: var(--mouse-x, -100px);
    top: var(--mouse-y, -100px);
    transition: opacity 0.3s ease;
}

/* The Canvas - Full viewport */
#ripple-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* The Entity - Emerges from the void */
.entity {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.entity.visible {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

.entity.hidden {
    opacity: 0;
    pointer-events: none;
}

.entity-core {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, 
        var(--entity-core) 0%, 
        rgba(100, 120, 200, 0.8) 40%, 
        rgba(60, 80, 150, 0.4) 70%, 
        transparent 100%);
    border-radius: 50%;
    animation: breathe 4s ease-in-out infinite, float 6s ease-in-out infinite;
    box-shadow: 
        0 0 30px var(--entity-glow),
        0 0 60px rgba(140, 160, 255, 0.3),
        0 0 100px rgba(140, 160, 255, 0.1);
}

.entity-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(140, 160, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse-glow 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes float {
    0%, 100% { margin-top: 0; }
    50% { margin-top: -10px; }
}

@keyframes pulse-glow {
    0%, 100% { 
        opacity: 0.5; 
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 0.8; 
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Whispers - Subtle text that appears */
.whisper {
    position: fixed;
    z-index: 50;
    font-size: 1.8rem;
    font-style: italic;
    color: var(--text-dim);
    opacity: 0;
    transition: opacity 2s ease;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(140, 160, 255, 0.3);
}

.whisper.visible {
    opacity: 1;
}

.whisper.hidden {
    opacity: 0;
}

/* The Portal - Engagement Modal */
.portal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 12, 0.95);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    cursor: auto;
}

.portal.visible {
    opacity: 1;
    pointer-events: auto;
}

.portal.hidden {
    opacity: 0;
    pointer-events: none;
}

.portal-content {
    max-width: 500px;
    width: 90%;
    padding: 3rem;
    text-align: center;
}

.portal-title {
    font-size: 2.2rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: 0.02em;
}

.portal-subtitle {
    font-size: 1.3rem;
    font-style: italic;
    color: var(--text-dim);
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

/* Form Styling */
.engagement-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-field {
    position: relative;
    text-align: left;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: 1rem 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(200, 200, 220, 0.2);
    color: var(--text);
    font-family: inherit;
    font-size: 1.5rem;
    transition: border-color 0.3s ease;
    resize: none;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

.form-field label {
    position: absolute;
    left: 0;
    top: 1rem;
    font-size: 1.4rem;
    color: var(--text-dim);
    pointer-events: none;
    transition: all 0.3s ease;
}

.form-field input:focus + label,
.form-field input:not(:placeholder-shown) + label,
.form-field textarea:focus + label,
.form-field textarea:not(:placeholder-shown) + label {
    top: -0.8rem;
    font-size: 1.1rem;
    color: var(--accent);
}

.begin-button {
    margin-top: 1.5rem;
    padding: 1rem 2rem;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--text);
    font-family: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(128, 144, 255, 0);
    -webkit-tap-highlight-color: rgba(128, 144, 255, 0.3);
    touch-action: manipulation;
    -webkit-appearance: none;
    z-index: 1001;
}

.begin-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--accent);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
    z-index: -1;
}

.begin-button:hover {
    color: var(--void);
    border-color: var(--entity-core);
    box-shadow: 0 0 30px rgba(128, 144, 255, 0.4),
                0 0 60px rgba(128, 144, 255, 0.2);
    transform: translateY(-2px);
}

.begin-button:hover::before {
    width: 120%;
    height: 400%;
}

.begin-button:active {
    transform: translateY(0);
    box-shadow: 0 0 20px rgba(128, 144, 255, 0.3);
}

@keyframes button-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(128, 144, 255, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(128, 144, 255, 0.4);
    }
}

.begin-button:not(:disabled) {
    animation: button-pulse 3s ease-in-out infinite;
}

/* Glitch Effect */
@keyframes glitch {
    0% {
        transform: translate(0);
        opacity: 1;
    }
    10% {
        transform: translate(-5px, 5px);
        opacity: 0.8;
    }
    20% {
        transform: translate(5px, -5px);
        opacity: 0.9;
    }
    30% {
        transform: translate(-5px, -5px);
        opacity: 0.7;
    }
    40% {
        transform: translate(5px, 5px);
        opacity: 0.6;
    }
    50% {
        transform: translate(-10px, 2px);
        opacity: 0.5;
    }
    60% {
        transform: translate(10px, -2px);
        opacity: 0.4;
    }
    70% {
        transform: translate(-5px, 5px);
        opacity: 0.3;
    }
    80% {
        transform: translate(5px, -5px);
        opacity: 0.2;
    }
    90% {
        transform: translate(-5px, 5px);
        opacity: 0.1;
    }
    100% {
        transform: translate(0);
        opacity: 0;
    }
}

@keyframes glitch-text {
    0%, 5%, 10%, 15%, 20%, 25%, 30%, 35%, 40%, 45%, 50%, 55%, 60%, 65%, 70%, 75%, 80%, 85%, 90%, 95% {
        text-shadow:
            -2px 0 red,
            2px 0 blue;
    }
    2%, 7%, 12%, 17%, 22%, 27%, 32%, 37%, 42%, 47%, 52%, 57%, 62%, 67%, 72%, 77%, 82%, 87%, 92%, 97% {
        text-shadow:
            2px 0 red,
            -2px 0 blue;
    }
}

.glitching {
    animation: glitch 2s ease-in-out forwards, glitch-text 0.3s infinite;
}

.glitch-container {
    position: relative;
}

.glitch-container.glitching::before,
.glitch-container.glitching::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--void);
}

.glitch-container.glitching::before {
    animation: glitch 2s ease-in-out;
    color: rgba(255, 0, 0, 0.7);
    z-index: -1;
}

.glitch-container.glitching::after {
    animation: glitch 2s ease-in-out reverse;
    color: rgba(0, 255, 255, 0.7);
    z-index: -2;
}

/* Slide up animation for form labels */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-field {
    opacity: 0;
}

.form-field.animate-in {
    animation: slideUpFade 0.6s ease-out forwards;
}

.begin-button {
    opacity: 0;
}

.begin-button.animate-in {
    animation: slideUpFade 0.8s ease-out forwards;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    .portal-title {
        font-size: 2rem;
    }

    .portal-subtitle {
        font-size: 1.35rem;
        margin-bottom: 2rem;
        line-height: 1.6;
    }

    .form-field input,
    .form-field textarea {
        font-size: 1.6rem;
        padding: 1.1rem 0;
    }

    .form-field label {
        font-size: 1.5rem;
    }

    .whisper {
        font-size: 1.9rem;
    }

    .begin-button {
        font-size: 1.3rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 600px) {
    .portal-content {
        padding: 2rem 1.5rem;
    }

    .portal-title {
        font-size: 1.8rem;
        line-height: 1.3;
    }

    .portal-subtitle {
        font-size: 1.3rem;
        line-height: 1.6;
        margin-bottom: 1.75rem;
    }

    .form-field input,
    .form-field textarea {
        font-size: 1.6rem;
        padding: 1.3rem 0;
    }

    .form-field label {
        font-size: 1.5rem;
        top: 1.3rem;
    }

    .form-field input:focus + label,
    .form-field input:not(:placeholder-shown) + label,
    .form-field textarea:focus + label,
    .form-field textarea:not(:placeholder-shown) + label {
        top: -0.9rem;
        font-size: 1.2rem;
    }

    .begin-button {
        font-size: 1.3rem;
        padding: 1.1rem 2rem;
        width: 100%;
    }

    .entity-core {
        width: 55px;
        height: 55px;
    }

    .whisper {
        font-size: 2rem;
        padding: 0 1rem;
        line-height: 1.5;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 380px) {
    .portal-content {
        padding: 1.5rem 1.25rem;
    }

    .portal-title {
        font-size: 1.7rem;
    }

    .portal-subtitle {
        font-size: 1.25rem;
        line-height: 1.5;
    }

    .form-field input,
    .form-field textarea {
        font-size: 1.5rem;
    }

    .form-field label {
        font-size: 1.4rem;
    }

    .begin-button {
        font-size: 1.25rem;
        padding: 1rem 1.5rem;
    }

    .whisper {
        font-size: 1.8rem;
    }
}
