/* ============================================
   RSVP Affirmations - Premium Mobile-First CSS
   ============================================ */

/* CSS Custom Properties (Design Tokens) */
:root {
    /* Colors - Dark Theme (Default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-glass: rgba(18, 18, 26, 0.85);
    --bg-glass-strong: rgba(18, 18, 26, 0.95);
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    
    --accent-primary: #ff3b3b; /* ORP Red */
    --accent-secondary: #7c3aed; /* Purple */
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(124, 58, 237, 0.3);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.3);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    /* Safe Areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8ed;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-glass-strong: rgba(255, 255, 255, 0.95);
    
    --text-primary: #1a1a1f;
    --text-secondary: rgba(26, 26, 31, 0.7);
    --text-muted: rgba(26, 26, 31, 0.4);
    
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
}

/* AMOLED Theme */
[data-theme="amoled"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #121212;
    --bg-glass: rgba(0, 0, 0, 0.9);
    --bg-glass-strong: rgba(0, 0, 0, 0.95);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ambient Background */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: var(--accent-secondary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 200px;
    height: 200px;
    background: #ec4899;
    bottom: 20%;
    left: -50px;
    animation-delay: -7s;
}

.orb-3 {
    width: 150px;
    height: 150px;
    background: #06b6d4;
    bottom: -50px;
    right: 20%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(20px, -30px) scale(1.05); }
    50% { transform: translate(-10px, 20px) scale(0.95); }
    75% { transform: translate(15px, 10px) scale(1.02); }
}

/* Header */
.header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--space-md) + var(--safe-top)) var(--space-lg) var(--space-md);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: 1.25rem;
}

.logo-icon {
    color: var(--accent-primary);
    font-size: 1.5rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

.logo-highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px var(--accent-primary); }
    50% { opacity: 0.7; text-shadow: 0 0 20px var(--accent-primary); }
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Main Display */
.main-display {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    padding: var(--space-lg);
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

/* Start Screen */
.start-content {
    text-align: center;
    max-width: 400px;
}

.start-icon {
    font-size: 4rem;
    color: var(--accent-primary);
    margin-bottom: var(--space-lg);
    display: inline-block;
}

.start-icon.pulse {
    animation: pulse-glow 2s ease-in-out infinite;
}

.start-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    line-height: 1.2;
}

.start-title .highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.start-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.start-description {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    line-height: 1.7;
}

.red-letter {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Buttons */
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 52px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.primary-btn:active {
    transform: translateY(0) scale(0.98);
}

.glow-effect {
    box-shadow: var(--shadow-glow);
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 48px;
}

.secondary-btn:hover {
    background: var(--bg-glass);
    border-color: var(--border-glow);
}

.secondary-btn:active {
    transform: scale(0.98);
}

/* RSVP Screen */
.rsvp-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.center-line {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 80px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--accent-primary) 30%,
        var(--accent-primary) 70%,
        transparent 100%
    );
    opacity: 0.5;
    pointer-events: none;
}

.word-display {
    font-family: var(--font-mono);
    font-size: clamp(2rem, 10vw, 4rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    position: relative;
}

.word-part {
    display: inline;
}

.word-left {
    text-align: right;
    color: var(--text-primary);
}

.word-orp {
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-primary);
    position: relative;
}

.word-right {
    text-align: left;
    color: var(--text-primary);
}

.progress-container {
    width: 100%;
    max-width: 300px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin-top: var(--space-xl);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 100ms linear;
}

.affirmation-counter {
    margin-top: var(--space-md);
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Complete Screen */
.complete-content {
    text-align: center;
}

.complete-icon {
    font-size: 4rem;
    color: var(--accent-secondary);
    margin-bottom: var(--space-lg);
    animation: float 3s ease-in-out infinite;
}

.complete-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.complete-stats {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.complete-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* Control Deck */
.control-deck {
    position: relative;
    z-index: 10;
    padding: var(--space-md) var(--space-lg) calc(var(--space-lg) + var(--safe-bottom));
    background: var(--bg-glass-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.control-deck.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.control-main {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-glow);
}

.control-main:hover {
    transform: scale(1.05);
}

.control-main:active {
    transform: scale(0.95);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.speed-row {
    gap: var(--space-xs);
}

.speed-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.speed-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-glow);
}

.speed-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 100;
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.settings-panel.open {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.settings-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.settings-content {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
    padding-bottom: calc(var(--space-xl) + var(--safe-bottom));
}

.setting-group {
    margin-bottom: var(--space-xl);
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.set-btn {
    padding: var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.set-btn:hover {
    border-color: var(--border-glow);
    color: var(--text-primary);
}

.set-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

/* Custom Affirmations */
.custom-textarea {
    width: 100%;
    min-height: 150px;
    padding: var(--space-md);
    font-family: var(--font-sans);
    font-size: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.custom-textarea::placeholder {
    color: var(--text-muted);
}

.custom-textarea:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.save-custom-btn {
    width: 100%;
    margin-top: var(--space-md);
}

/* Toggle */
.toggle-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.toggle-btn {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.toggle-btn[aria-pressed="true"] {
    background: var(--accent-secondary);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle-btn[aria-pressed="true"] .toggle-slider {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Theme Options */
.theme-options {
    display: flex;
    gap: var(--space-md);
}

.theme-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.75rem;
    font-weight: 500;
}

.theme-btn:hover {
    border-color: var(--border-glow);
}

.theme-btn.active {
    border-color: var(--accent-secondary);
    color: var(--text-primary);
}

.theme-preview {
    width: 48px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.dark-preview {
    background: linear-gradient(to bottom, #12121a, #0a0a0f);
}

.light-preview {
    background: linear-gradient(to bottom, #ffffff, #f5f5f7);
}

.amoled-preview {
    background: #000000;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

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

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
    .start-title {
        font-size: 3rem;
    }
    
    .word-display {
        font-size: 5rem;
    }
    
    .setting-options {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .settings-panel {
        max-width: 500px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .settings-panel.open {
        transform: translateX(-50%) translateY(0);
    }
}

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