/**
 * WithYou Parent Web - Main Styles
 * Optimized for older adults with large touch targets and high contrast
 */

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

html {
    font-size: 18px; /* Base font size for better readability */
    scroll-behavior: smooth;
}

body {
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #FFFCF1;
    color: #212121;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Container Layout */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 24px) env(safe-area-inset-right, 24px) env(safe-area-inset-bottom, 24px) env(safe-area-inset-left, 24px);
    max-width: 100%;
    margin: 0 auto;
}

/* App Logo */
.app-logo {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    color: #212121;
    text-align: center;
    margin-top: 12px;
    letter-spacing: -0.3px;
}

/* Index page logo */
.container .app-logo {
    font-size: 20px;
}

/* Record page logo */
body[data-page="record"] .app-logo {
    font-size: 16px;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 40px 24px 60px;
}

/* Headlines */
.headline h1 {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 2.2rem; /* 40px at 18px base */
    color: #212121;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 48px;
}

/* Question Cards */
.question-card {
    background: #FFFFFF;
    border: 2px solid #FFD555;
    border-radius: 24px;
    padding: 40px 48px;
    margin: 0 auto 48px;
    box-shadow: 0 4px 16px rgba(33, 33, 33, 0.08);
    max-width: 600px;
    width: 90%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.question-text {
    font-family: 'Sora', sans-serif;
    font-weight: 500;
    font-size: 1.33rem; /* 24px at 18px base */
    color: #212121;
    text-align: center;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    /* Custom scrollbar for better UX */
    scrollbar-width: thin;
    scrollbar-color: #FFD555 #FFFCF1;
}

/* Webkit scrollbar styling */
.question-text::-webkit-scrollbar {
    width: 6px;
}

.question-text::-webkit-scrollbar-track {
    background: #FFFCF1;
    border-radius: 3px;
}

.question-text::-webkit-scrollbar-thumb {
    background: #FFD555;
    border-radius: 3px;
}

.question-text::-webkit-scrollbar-thumb:hover {
    background: #FFCC50;
}

/* Index page question blur effect */
.main-content .question-text {
    filter: blur(2px);
    transition: filter 0.3s ease;
}

/* Instructions */
.instructions {
    text-align: center;
    margin-bottom: 48px;
}

.instructions p {
    font-family: 'Sora', sans-serif;
    font-weight: 400;
    font-size: 1.11rem; /* 20px at 18px base */
    color: #757575;
    line-height: 1.6;
}

/* Primary Actions */
.actions {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 48px;
    padding-bottom: 40px;
}

.continue-button {
    background: radial-gradient(circle at center, #FFD555 0%, #FFCC50 46%, #FFB445 100%);
    color: #212121;
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 1.11rem; /* 20px */
    border: 1px solid #000000;
    border-radius: 28px;
    padding: 16px 48px;
    min-height: 56px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    outline: none;
}

.continue-button:hover,
.continue-button:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(255, 213, 85, 0.3);
    filter: brightness(1.1);
}

.continue-button:active {
    transform: scale(0.96);
}

.arrow {
    font-size: 1.2em;
    margin-left: 4px;
}

/* Section Headers */
.section-header {
    text-align: left;
    margin: 20px 24px 24px;
    flex: 0 0 auto;
}

.section-header h2 {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 1.33rem; /* 24px */
    color: #212121;
    line-height: 1.6;
}

/* Recording States */
.recording-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    justify-content: flex-start;
    padding-top: 20px;
    padding-bottom: 120px; /* Extra padding to keep content above browser bar */
}

.recording-state .question-card {
    align-self: center;
    margin: 0 auto 20px;
    flex: 0 0 auto;
}

/* Recording Action Section */
.recording-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    flex: 0 0 auto;
    justify-content: center;
    position: relative;
}

.record-button,
.stop-button {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background-color: #FF4444;
    border: 2px solid #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
}

.record-button:hover,
.record-button:focus,
.stop-button:hover,
.stop-button:focus {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}

.record-button:active,
.stop-button:active {
    transform: scale(0.95);
}

.mic-icon {
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.stop-icon {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.instruction-text {
    font-family: 'Sora', sans-serif;
    font-weight: 400;
    font-size: 1.11rem; /* 20px */
    color: #212121;
    text-align: center;
    margin-top: 24px;
    line-height: 1.6;
}

/* Countdown Display */
.countdown-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.countdown-display {
    text-align: center;
}

.countdown-number {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 6.67rem; /* 120px */
    color: #212121;
    line-height: 1;
}

/* Recording Feedback */
.recording-feedback {
    display: flex;
    justify-content: center;
    margin: 24px 0;
}

.feedback-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.waveform-container {
    width: 120px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
}

#waveform {
    display: block;
    width: 100%;
    height: 100%;
}

.recording-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
}

.red-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #FF4444;
    animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.timer-display {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 1.78rem; /* 32px */
    color: #212121;
    min-width: 80px;
    text-align: center;
}

/* Review Instructions */
.review-instructions {
    text-align: center;
    margin: 16px 0 24px;
}

.review-instructions p {
    font-family: 'Sora', sans-serif;
    font-weight: 400;
    font-size: 0.89rem; /* 16px */
    color: #212121;
    line-height: 1.6;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.time-display {
    display: flex;
    justify-content: space-between;
    width: 80%;
    max-width: 300px;
    font-family: 'Sora', sans-serif;
    font-weight: 500;
    font-size: 0.67rem; /* 12px */
    color: #212121;
}

.progress-container {
    width: 80%;
    max-width: 300px;
    height: 4px;
    position: relative;
    cursor: pointer;
}

.progress-track {
    width: 100%;
    height: 4px;
    background-color: #E0E0E0;
    border-radius: 2px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background-color: #000000;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.scrubber-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 20px;
    height: 20px;
    background-color: #000000;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    transition: left 0.1s linear;
}

.scrubber-handle:active {
    cursor: grabbing;
}

.play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #000000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
}

.play-button:hover,
.play-button:focus {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.play-button:active {
    transform: scale(0.95);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 32px;
    padding: 16px 0;
}

.secondary-button,
.primary-button {
    font-family: 'Sora', sans-serif;
    font-weight: 500;
    font-size: 0.89rem; /* 16px */
    border-radius: 28px;
    min-height: 56px;
    padding: 16px 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    flex: 1;
    max-width: 160px;
}

.secondary-button {
    background: transparent;
    color: #212121;
    border: 2px solid #FFD555;
}

.secondary-button:hover,
.secondary-button:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(255, 213, 85, 0.3);
    border-color: #FFCC50;
}

.primary-button {
    background: radial-gradient(circle at center, #FFD555 0%, #FFCC50 46%, #FFB445 100%);
    color: #212121;
    border: 1px solid #000000;
    font-weight: 700;
    font-size: 1.11rem; /* 20px */
}

.primary-button:hover,
.primary-button:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(255, 213, 85, 0.3);
    filter: brightness(1.1);
}

.secondary-button:active,
.primary-button:active {
    transform: scale(0.96);
}

/* Upload State */
.upload-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.upload-header h1 {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 2.67rem; /* 48px */
    color: #212121;
    margin-bottom: 80px;
    line-height: 1.4;
}

.progress-section {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.progress-bar-container {
    width: 70%;
    height: 16px;
}

.progress-track-upload {
    width: 100%;
    height: 16px;
    background-color: #E0E0E0;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.progress-fill-upload {
    height: 100%;
    background: radial-gradient(circle at center, #FFD555 0%, #FFCC50 46%, #FFB445 100%);
    border-radius: 8px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.percentage-display {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 2rem; /* 36px */
    color: #212121;
}

.upload-status {
    font-family: 'Sora', sans-serif;
    font-weight: 400;
    font-size: 1rem; /* 18px */
    color: #757575;
}

/* Success State */
.success-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.celebration-card {
    background: #FFFFFF;
    border: 2px solid #FFD555;
    border-radius: 24px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(33, 33, 33, 0.12);
    max-width: 400px;
    width: 85%;
    position: relative;
}

/* Lottie Confetti Container */
.lottie-confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.success-message {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 2rem; /* 36px */
    color: #212121;
    margin-bottom: 32px;
    line-height: 1.4;
}

.appreciation-message {
    font-family: 'Sora', sans-serif;
    font-weight: 400;
    font-size: 1.11rem; /* 20px */
    color: #212121;
    line-height: 1.6;
}


/* Error States */
.error-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-card {
    background: #FFFFFF;
    border: 2px solid #FFD555;
    border-radius: 24px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(33, 33, 33, 0.08);
    max-width: 400px;
    width: 85%;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 24px;
}

.error-title {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 1.56rem; /* 28px */
    color: #212121;
    margin-bottom: 16px;
    line-height: 1.4;
}

.error-message {
    font-family: 'Sora', sans-serif;
    font-weight: 400;
    font-size: 1rem; /* 18px */
    color: #757575;
    margin-bottom: 32px;
    line-height: 1.6;
}

.retry-button {
    background: radial-gradient(circle at center, #FFD555 0%, #FFCC50 46%, #FFB445 100%);
    color: #212121;
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 1rem; /* 18px */
    border: 1px solid #000000;
    border-radius: 28px;
    padding: 16px 32px;
    min-height: 56px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.retry-button:hover,
.retry-button:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(255, 213, 85, 0.3);
    filter: brightness(1.1);
}

.retry-button:active {
    transform: scale(0.96);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

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

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
    }
    
    .headline h1 {
        font-size: 1.89rem; /* 34px */
    }
    
    .question-card {
        margin: 0 auto 32px;
        padding: 32px 24px;
        max-height: 300px;
    }
    
    .question-text {
        font-size: 1.11rem; /* 20px */
        max-height: 180px;
        line-height: 1.5;
    }
    
    .section-header {
        margin: 48px 16px 24px;
    }
    
    /* Recording state adjustments for mobile */
    .recording-state {
        padding-bottom: 140px; /* More padding for mobile browser bars */
    }
    
    .recording-state .section-header {
        margin: 16px 16px 16px;
    }
    
    .recording-feedback {
        margin: 16px 0;
    }
    
    .recording-action {
        margin-top: 16px;
    }
    
    /* Review state specific adjustments */
    .review-instructions {
        margin: 12px 0 16px;
    }
    
    .playback-controls {
        gap: 16px;
        margin-bottom: 16px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 12px;
        align-items: center;
        margin-top: 16px;
        padding: 12px 0;
    }
    
    .secondary-button,
    .primary-button {
        width: 100%;
        max-width: 280px;
    }
}

@media (max-width: 360px) {
    html {
        font-size: 16px; /* Smaller base for very small screens */
    }
    
    .question-card {
        padding: 24px 20px;
        max-height: 250px;
    }
    
    .question-text {
        font-size: 1rem; /* 16px */
        max-height: 150px;
        line-height: 1.4;
    }
    
    .record-button,
    .stop-button {
        width: 120px;
        height: 120px;
    }
    
    .mic-icon {
        width: 48px;
        height: 48px;
    }
    
    .stop-icon {
        width: 36px;
        height: 36px;
    }
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background-color: #FFFFFF;
    }
    
    .question-card {
        border-width: 3px;
        box-shadow: 0 0 0 2px #000000;
    }
    
    .continue-button,
    .primary-button,
    .retry-button {
        border-width: 2px;
        box-shadow: 0 0 0 1px #000000;
    }
}

/* Focus indicators for keyboard navigation */
*:focus {
    outline: 3px solid #FFE941;
    outline-offset: 2px;
}

button:focus,
.continue-button:focus {
    outline: 3px solid #FFE941;
    outline-offset: 3px;
}

/* Print styles */
@media print {
    .container {
        background: white;
        color: black;
    }
    
    .lottie-confetti-container {
        display: none;
    }
}