/* ===================================
   CSS VARIABLES & THEMES
   =================================== */

:root {
    /* Light theme - warm paper aesthetic */
    --bg-primary: #f5f1e8;
    --bg-secondary: #ebe4d5;
    --text-primary: #2a1810;
    --text-secondary: #6b4e3d;
    --text-whisper: #9d8574;
    --accent: #8b2e2e;
    --accent-soft: #a85050;
    --accent-glow: rgba(139, 46, 46, 0.15);
    --border: rgba(42, 24, 16, 0.1);

    /* Gradients */
    --gradient-bg: radial-gradient(
        ellipse at top,
        rgba(235, 228, 213, 0.8),
        rgba(245, 241, 232, 0.4)
    );

    /* Fonts */
    --font-serif: 'Crimson Pro', serif;
    --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
    /* Dark theme - intimate listening room */
    --bg-primary: #0f1419;
    --bg-secondary: #1a2028;
    --text-primary: #e8dcc8;
    --text-secondary: #b8a890;
    --text-whisper: #7a6f5d;
    --accent: #d4a574;
    --accent-soft: #c4956a;
    --accent-glow: rgba(212, 165, 116, 0.2);
    --border: rgba(232, 220, 200, 0.1);

    --gradient-bg: radial-gradient(
        ellipse at top,
        rgba(42, 52, 65, 0.4),
        rgba(15, 20, 25, 0.2)
    );
}

/* ===================================
   RESET & BASE
   =================================== */

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

html {
    height: 100%;
}

body {
    min-height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-serif);
    line-height: 1.6;
    transition: background-color 0.4s ease, color 0.4s ease;
    position: relative;
    overflow-x: hidden;
}

/* Atmospheric background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-bg);
    pointer-events: none;
    z-index: 0;
}

/* ===================================
   THEME TOGGLE
   =================================== */

.theme-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(20deg);
}

.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
    position: absolute;
    transition: all 0.3s ease;
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="light"] .moon-icon,
:root:not([data-theme]) .moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .sun-icon,
:root:not([data-theme]) .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ===================================
   LAYOUT
   =================================== */

.container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.view {
    width: 100%;
    max-width: 700px;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.view.hidden {
    display: none;
    opacity: 0;
}

.content-wrapper {
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   TYPOGRAPHY
   =================================== */

.title {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 300;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    font-weight: 300;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    line-height: 1.8;
}

.whisper {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-whisper);
    margin-top: 2rem;
    font-weight: 300;
}

/* ===================================
   FORM
   =================================== */

.age-form {
    margin: 3rem 0;
}

.input-group {
    margin-bottom: 2rem;
}

.input-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-whisper);
    margin-bottom: 0.75rem;
}

.age-input {
    width: 100%;
    max-width: 200px;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 300;
    padding: 0.5rem 0;
    transition: all 0.3s ease;
    outline: none;
}

.age-input:focus {
    border-bottom-color: var(--accent);
}

.age-input::placeholder {
    color: var(--text-whisper);
    opacity: 0.5;
}

/* Remove spinner arrows */
.age-input::-webkit-outer-spin-button,
.age-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.age-input[type=number] {
    -moz-appearance: textfield;
}

.submit-btn {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 1rem 3rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 2px;
    font-weight: 400;
}

.submit-btn:hover {
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow);
}

.submit-btn:active {
    transform: translateY(0);
}

/* ===================================
   RESULTS
   =================================== */

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-whisper);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 3rem;
    padding: 0.5rem 0;
    transition: all 0.3s ease;
}

.back-btn:hover {
    color: var(--accent);
    transform: translateX(-4px);
}

.result-container {
    text-align: center;
}

.big-number {
    font-family: var(--font-mono);
    font-size: clamp(4rem, 15vw, 8rem);
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 1rem;
    animation: breathe 3s ease-in-out infinite;
    letter-spacing: -0.03em;
}

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

.result-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 300;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    letter-spacing: -0.01em;
}

.result-breakdown {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin: 3rem 0;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

@media (min-width: 600px) {
    .result-breakdown {
        grid-template-columns: 1fr 1fr;
    }
}

.breakdown-item {
    animation: fadeInUp 0.8s ease-out;
    animation-fill-mode: both;
}

.breakdown-item:nth-child(2) {
    animation-delay: 0.1s;
}

.breakdown-value {
    font-family: var(--font-mono);
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.breakdown-label {
    font-size: 0.9rem;
    color: var(--text-whisper);
    line-height: 1.5;
}

.reflection {
    margin-top: 3rem;
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.9;
}

.reflection p {
    margin-bottom: 1rem;
    animation: fadeInUp 1s ease-out;
    animation-fill-mode: both;
}

.reflection p:nth-child(1) {
    animation-delay: 0.2s;
}

.reflection p:nth-child(2) {
    animation-delay: 0.35s;
}

.reflection p:nth-child(3) {
    animation-delay: 0.5s;
}

.reflection .emphasis {
    color: var(--accent);
    font-weight: 400;
    font-size: clamp(1.2rem, 3.5vw, 1.5rem);
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 600px) {
    .theme-toggle {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .container {
        padding: 1.5rem;
    }

    .title {
        margin-bottom: 1rem;
    }

    .subtitle {
        margin-bottom: 2rem;
    }
}
