/*
 * Quantum Merlin Design System
 * Merlin/Arthur Mythology + 80s Tron Aesthetic
 * Version 2.0
 */

/* ===== CSS VARIABLES ===== */
:root {
    /* Colors - Warm off-whites for better readability (not pure white) */
    --text-primary: #E8E4D9;      /* Warm parchment - easier on eyes than white */
    --text-secondary: #C4B998;    /* Aged gold parchment */
    --text-muted: #9A8F7A;        /* Muted earth tone */
    --text-accent-gold: #FFD93D;  /* Bright mystical gold */
    --text-accent-cyan: #00F5FF;  /* Tron cyan */
    --text-accent-magenta: #FF00FF; /* Tron magenta */
    --text-accent-purple: #BF5AF2; /* Mystical purple */
    
    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-card: rgba(15, 15, 25, 0.9);
    --bg-card-inner: rgba(10, 10, 18, 0.8);
    
    /* Borders & Glows */
    --glow-cyan: rgba(0, 245, 255, 0.6);
    --glow-gold: rgba(255, 217, 61, 0.6);
    --glow-magenta: rgba(255, 0, 255, 0.4);
    --glow-purple: rgba(139, 92, 246, 0.5);
    
    /* Gradients */
    --gradient-gold: linear-gradient(135deg, #FFD93D 0%, #FF6B6B 50%, #BF5AF2 100%);
    --gradient-tron: linear-gradient(135deg, #00F5FF 0%, #BF5AF2 50%, #FF00FF 100%);
    --gradient-mystical: linear-gradient(135deg, #FFD93D 0%, #00F5FF 100%);
    
    /* Animation timings */
    --transition-fast: 0.2s;
    --transition-medium: 0.4s;
    --transition-slow: 0.8s;
}

/* ===== RESET & BASE ===== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: clamp(10px, 3vw, 30px);
    line-height: 1.8;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ===== ANIMATED BACKGROUND ===== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        /* Tron grid effect */
        linear-gradient(90deg, rgba(0, 245, 255, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(0, 245, 255, 0.03) 1px, transparent 1px),
        /* Mystical orbs */
        radial-gradient(ellipse at 15% 30%, rgba(191, 90, 242, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 70%, rgba(0, 245, 255, 0.12) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 90%, rgba(255, 217, 61, 0.08) 0%, transparent 40%);
    background-size: 60px 60px, 60px 60px, 100% 100%, 100% 100%, 100% 100%;
    pointer-events: none;
    z-index: -1;
    animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Floating particles effect (pure CSS) */
body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, rgba(255, 217, 61, 0.4), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(0, 245, 255, 0.3), transparent),
        radial-gradient(1px 1px at 60% 20%, rgba(191, 90, 242, 0.4), transparent),
        radial-gradient(2px 2px at 80% 50%, rgba(255, 217, 61, 0.3), transparent),
        radial-gradient(1px 1px at 30% 80%, rgba(0, 245, 255, 0.4), transparent),
        radial-gradient(2px 2px at 70% 90%, rgba(191, 90, 242, 0.3), transparent);
    background-size: 400px 400px;
    animation: floatParticles 60s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes floatParticles {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-50px, -50px) rotate(360deg); }
}

/* ===== CONTAINER ===== */
.container { 
    max-width: 900px; 
    margin: 0 auto;
    position: relative;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: clamp(25px, 5vw, 50px);
    padding: clamp(15px, 4vw, 40px);
    position: relative;
}

.header h1 {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
    font-size: clamp(1.3rem, 4.5vw, 2.8rem);
    margin-bottom: 15px;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: clamp(0px, 0.2vw, 2px);
    font-weight: 700;
    text-shadow: 0 0 40px rgba(255, 217, 61, 0.3);
    animation: titleGlow 3s ease-in-out infinite alternate;
    /* Prevent awkward line breaks */
    word-break: keep-all;
    overflow-wrap: normal;
    white-space: normal;
    padding: 0 5px;
    line-height: 1.3;
}

/* Keep emoji with title text */
.header h1 .emoji,
.header h1::first-letter {
    white-space: nowrap;
}

@keyframes titleGlow {
    0% { filter: drop-shadow(0 0 10px rgba(255, 217, 61, 0.3)); }
    100% { filter: drop-shadow(0 0 25px rgba(255, 217, 61, 0.6)); }
}

.header p {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(0.95rem, 2.5vw, 1.25rem);
    color: var(--text-accent-cyan);
    opacity: 0.9;
    font-style: italic;
    text-shadow: 0 0 20px rgba(0, 245, 255, 0.4);
    padding: 0 10px;
}

/* ===== TOOL CARD ===== */
.tool-card {
    background: var(--bg-card);
    border: 2px solid transparent;
    border-image: var(--gradient-tron) 1;
    border-radius: 20px;
    padding: clamp(20px, 5vw, 50px);
    box-shadow: 
        0 0 30px rgba(0, 245, 255, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    animation: cardFloat 6s ease-in-out infinite;
}

/* Tron corner accents */
.tool-card::before,
.tool-card::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    pointer-events: none;
}

.tool-card::before {
    top: -2px;
    left: -2px;
    border-top: 3px solid var(--text-accent-cyan);
    border-left: 3px solid var(--text-accent-cyan);
    border-radius: 20px 0 0 0;
    box-shadow: 
        -5px -5px 15px rgba(0, 245, 255, 0.3),
        inset 5px 5px 15px rgba(0, 245, 255, 0.1);
}

.tool-card::after {
    bottom: -2px;
    right: -2px;
    border-bottom: 3px solid var(--text-accent-gold);
    border-right: 3px solid var(--text-accent-gold);
    border-radius: 0 0 20px 0;
    box-shadow: 
        5px 5px 15px rgba(255, 217, 61, 0.3),
        inset -5px -5px 15px rgba(255, 217, 61, 0.1);
}

@keyframes cardFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ===== PROFILE SECTION ===== */
.profile-section {
    background: linear-gradient(135deg, rgba(191, 90, 242, 0.1) 0%, rgba(0, 245, 255, 0.05) 100%);
    border: 2px solid rgba(191, 90, 242, 0.4);
    border-radius: 15px;
    padding: clamp(15px, 3vw, 25px);
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
}

.profile-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(191, 90, 242, 0.1), transparent);
    animation: profileShine 4s ease-in-out infinite;
}

@keyframes profileShine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

/* ===== INPUT SECTIONS ===== */
.input-section {
    margin-bottom: clamp(25px, 4vw, 40px);
    padding-bottom: clamp(20px, 3vw, 30px);
    border-bottom: 1px solid rgba(0, 245, 255, 0.2);
}

.input-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    color: var(--text-accent-gold);
    margin-bottom: 20px;
    font-weight: 600;
    letter-spacing: 1px;
    text-shadow: 0 0 20px rgba(255, 217, 61, 0.3);
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-mystical);
    border-radius: 2px;
}

.input-group {
    margin-bottom: clamp(18px, 3vw, 25px);
}

/* ===== LABELS ===== */
label {
    display: block;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-accent-cyan);
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    text-shadow: 0 0 15px rgba(0, 245, 255, 0.3);
}

.helper-text {
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
    padding-left: 5px;
    border-left: 2px solid rgba(0, 245, 255, 0.3);
}

/* ===== INPUTS ===== */
input[type="text"],
input[type="date"],
input[type="time"],
select {
    width: 100%;
    padding: clamp(12px, 2vw, 16px);
    border: 2px solid rgba(0, 245, 255, 0.3);
    background: rgba(10, 10, 18, 0.8);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: clamp(14px, 2.5vw, 16px);
    transition: all var(--transition-medium);
    font-family: 'Cormorant Garamond', serif;
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 245, 255, 0.1);
}

input:focus, 
select:focus {
    outline: none;
    border-color: var(--text-accent-gold);
    box-shadow: 
        0 0 20px rgba(255, 217, 61, 0.3),
        0 0 40px rgba(255, 217, 61, 0.1),
        inset 0 2px 10px rgba(0, 0, 0, 0.3);
    background: rgba(15, 15, 25, 0.9);
}

input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* ===== RESPONSIVE GRID ===== */
.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: clamp(15px, 3vw, 25px);
}

/* ===== BUTTONS ===== */
button[type="submit"],
button.submit-btn {
    background: var(--gradient-tron);
    color: #0a0a0f;
    font-weight: 700;
    border: none;
    padding: clamp(14px, 3vw, 20px) clamp(30px, 5vw, 50px);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-family: 'Cinzel', serif;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-medium);
    width: 100%;
    margin-top: 25px;
    letter-spacing: 1px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 5px 25px rgba(0, 245, 255, 0.3),
        0 0 50px rgba(191, 90, 242, 0.2);
}

button[type="submit"]::before,
button.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

button[type="submit"]:hover::before,
button.submit-btn:hover::before {
    left: 100%;
}

button[type="submit"]:hover,
button.submit-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 15px 40px rgba(0, 245, 255, 0.4),
        0 0 60px rgba(191, 90, 242, 0.3);
}

button[type="submit"]:active,
button.submit-btn:active {
    transform: translateY(-2px) scale(1.01);
}

/* ===== PROFILE BUTTONS ===== */
.profile-btn {
    background: rgba(0, 245, 255, 0.1);
    border: 2px solid rgba(0, 245, 255, 0.4);
    color: var(--text-accent-cyan);
    padding: clamp(8px, 2vw, 12px) clamp(12px, 2vw, 18px);
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.profile-btn:hover {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--text-accent-cyan);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.3);
    transform: translateY(-2px);
}

/* ===== RESULT SECTION ===== */
.result {
    background: var(--bg-card-inner);
    border: 2px solid rgba(255, 217, 61, 0.3);
    padding: clamp(25px, 4vw, 45px);
    border-radius: 15px;
    margin-top: 30px;
    display: none;
    box-shadow: 
        0 0 40px rgba(255, 217, 61, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 0 60px rgba(255, 217, 61, 0.02);
    position: relative;
    overflow: hidden;
}

.result::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-gold);
}

.result.show {
    display: block;
    animation: resultReveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resultReveal {
    0% { 
        opacity: 0; 
        transform: translateY(40px) scale(0.95);
        filter: blur(10px);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.result-header {
    text-align: center;
    margin-bottom: clamp(20px, 4vw, 35px);
}

.result-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(1.5rem, 5vw, 2.4rem);
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    font-weight: 700;
    animation: resultTitlePulse 2s ease-in-out infinite alternate;
}

@keyframes resultTitlePulse {
    0% { filter: drop-shadow(0 0 15px rgba(255, 217, 61, 0.4)); }
    100% { filter: drop-shadow(0 0 30px rgba(255, 217, 61, 0.7)); }
}

.result-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    color: var(--text-accent-cyan);
    font-style: italic;
    text-shadow: 0 0 15px rgba(0, 245, 255, 0.3);
}

.result-content {
    font-size: clamp(1rem, 2.5vw, 1.18rem);
    line-height: 2;
    color: var(--text-primary);
    text-align: justify;
}

.result-content p {
    margin-bottom: clamp(15px, 3vw, 22px);
}

.result-content strong {
    color: var(--text-accent-gold);
    font-weight: 600;
}

/* ===== SHARE SECTION ===== */
.share-section {
    margin-top: clamp(25px, 4vw, 40px);
    padding-top: clamp(20px, 3vw, 30px);
    border-top: 1px solid rgba(0, 245, 255, 0.2);
    text-align: center;
}

.share-buttons {
    display: flex;
    gap: clamp(10px, 2vw, 15px);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.share-btn {
    background: rgba(0, 245, 255, 0.1);
    border: 2px solid rgba(0, 245, 255, 0.3);
    color: var(--text-accent-cyan);
    padding: clamp(10px, 2vw, 14px) clamp(18px, 3vw, 28px);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-medium);
    text-decoration: none;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.85rem, 2vw, 1rem);
}

.share-btn:hover {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--text-accent-cyan);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 245, 255, 0.3);
}

/* ===== BACK BUTTON ===== */
.back-btn {
    background: rgba(191, 90, 242, 0.1);
    border: 2px solid rgba(191, 90, 242, 0.4);
    color: var(--text-accent-purple);
    margin-top: 25px;
    font-family: 'Cinzel', serif;
    padding: clamp(12px, 2vw, 16px) clamp(25px, 4vw, 40px);
    font-size: clamp(0.9rem, 2vw, 1rem);
    width: auto;
    display: inline-block;
    position: relative;
    z-index: 10;
    cursor: pointer;
}

.back-btn:hover {
    background: rgba(191, 90, 242, 0.2);
    border-color: var(--text-accent-purple);
    box-shadow: 0 0 25px rgba(191, 90, 242, 0.4);
    transform: translateY(-2px);
}

/* ===== BACK LINK ===== */
.back-link {
    display: inline-block;
    text-decoration: none;
    font-family: 'Cinzel', serif;
    position: relative;
    z-index: 10;
    cursor: pointer;
}

.back-link:hover {
    text-decoration: underline;
}

/* ===== HIGHLIGHT CLASS ===== */
.highlight {
    background: linear-gradient(120deg, rgba(255, 217, 61, 0.2) 0%, rgba(191, 90, 242, 0.2) 100%);
    border: 1px solid rgba(255, 217, 61, 0.4);
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 600;
    color: var(--text-accent-gold);
    text-shadow: 0 0 10px rgba(255, 217, 61, 0.4);
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .tool-card {
        padding: 20px !important;
    }
    
    .tool-card::before,
    .tool-card::after {
        width: 40px;
        height: 40px;
    }
    
    .profile-section > div {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .profile-section > div > div:first-child {
        width: 100%;
    }
    
    .profile-section > div > div:last-child {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .tool-card {
        border-radius: 15px;
        padding: 15px !important;
    }
    
    .tool-card::before,
    .tool-card::after {
        width: 30px;
        height: 30px;
    }
    
    .input-group input,
    .input-group select,
    .input-group textarea {
        padding: 12px !important;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
    
    .submit-btn {
        padding: 14px !important;
        font-size: 1.1em !important;
    }
    
    .share-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .share-btn {
        width: 100%;
        max-width: 250px;
        text-align: center;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--text-accent-cyan), var(--text-accent-purple));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--text-accent-gold), var(--text-accent-magenta));
}

/* ===== SELECTION STYLING ===== */
::selection {
    background: rgba(0, 245, 255, 0.3);
    color: var(--text-primary);
}
