/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-purple: #5b21b6;
    --primary-blue: #1e40af;
    --secondary-purple: #7c3aed;
    --secondary-blue: #3b82f6;
    --text-dark: #1f2937;
    --text-medium: #4b5563;
    --text-light: #6b7280;
    --background-light: rgba(255, 255, 255, 0.98);
    --background-card: rgba(255, 255, 255, 0.95);
    --border-light: rgba(229, 231, 235, 0.8);
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --focus-ring: 3px solid #3b82f6;
    --focus-ring-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-purple: #000000;
        --primary-blue: #000080;
        --text-dark: #000000;
        --text-medium: #000000;
        --background-card: #ffffff;
        --border-light: #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #a8c0ff 0%, #e4b5ff 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 16px;
}

.container {
    max-width: 500px;
    width: 100%;
    background: var(--background-card);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-light);
}

/* Skip to main content for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-purple);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 32px;
    background: var(--background-card);
    padding: 24px;
    border-radius: 16px;
    border: 2px solid var(--border-light);
}

h1 {
    color: var(--primary-purple);
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    margin-bottom: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.subtitle {
    color: var(--text-medium);
    font-size: clamp(1rem, 2vw, 1.125rem);
    font-style: italic;
}

/* Progress Section */
.progress-section {
    text-align: center;
    margin-bottom: 32px;
    background: var(--background-card);
    padding: 24px;
    border-radius: 16px;
    border: 2px solid var(--border-light);
}

.day-display {
    margin-bottom: 20px;
}

.day-number {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: bold;
    color: var(--primary-purple);
    display: block;
    line-height: 1.1;
}

.day-label {
    font-size: clamp(1.125rem, 3vw, 1.375rem);
    color: var(--text-medium);
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 16px;
    background-color: #e9d5ff;
    border-radius: 8px;
    margin: 24px 0;
    overflow: hidden;
    border: 1px solid var(--border-light);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-purple), var(--primary-blue));
    border-radius: 8px;
    width: 1%;
    transition: width 0.5s ease;
}

/* Screen reader only text for progress */
.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;
}

.streak-message {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    color: var(--text-dark);
    font-weight: 600;
    margin-top: 16px;
    padding: 16px;
    background: rgba(233, 213, 255, 0.3);
    border-radius: 12px;
    border: 2px solid rgba(138, 43, 226, 0.1);
    line-height: 1.4;
}

/* Action Section */
.action-section {
    text-align: center;
    margin-bottom: 32px;
    background: var(--background-card);
    padding: 24px;
    border-radius: 16px;
    border: 2px solid var(--border-light);
}

.checkin-button {
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-blue));
    color: white;
    border: 2px solid transparent;
    padding: 16px 32px;
    font-size: clamp(1.125rem, 2.5vw, 1.25rem);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 24px;
    width: 100%;
    max-width: 280px;
    font-weight: 700;
    position: relative;
}

.checkin-button:hover {
    background: linear-gradient(135deg, var(--secondary-purple), var(--secondary-blue));
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(138, 43, 226, 0.3);
}

.checkin-button:focus {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
    background: linear-gradient(135deg, var(--secondary-purple), var(--secondary-blue));
    border-color: #3b82f6;
}

.checkin-button:active {
    transform: translateY(0);
}

.checkin-button:disabled {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    color: #e5e7eb;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: transparent;
}

.quote-box {
    background: rgba(233, 213, 255, 0.3);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid rgba(138, 43, 226, 0.1);
    font-style: italic;
    color: var(--text-medium);
    margin: 0 auto;
    max-width: 400px;
    line-height: 1.5;
    font-size: clamp(0.875rem, 2vw, 1rem);
}

.quote-box:focus {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

/* Info Section */
.info-section {
    margin-bottom: 24px;
    background: var(--background-card);
    padding: 24px;
    border-radius: 16px;
    border: 2px solid var(--border-light);
}

.stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
    gap: 16px;
}

.stat {
    padding: 16px;
    background: rgba(233, 213, 255, 0.3);
    border-radius: 12px;
    border: 2px solid rgba(138, 43, 226, 0.1);
    min-width: 120px;
    flex: 1;
}

.stat:focus {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

.stat-number {
    display: block;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    color: var(--primary-purple);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-medium);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: 600;
}

/* Footer */
footer {
    text-align: center;
    padding-top: 20px;
    border-top: 2px solid var(--border-light);
}

.reset-link a {
    color: var(--primary-blue);
    text-decoration: underline;
    font-size: clamp(0.875rem, 2vw, 0.9375rem);
    transition: color 0.2s ease;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.reset-link a:hover {
    color: var(--primary-purple);
    background: rgba(59, 130, 246, 0.1);
}

.reset-link a:focus {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
    background: rgba(59, 130, 246, 0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-content {
    background: var(--background-card);
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
    border: 2px solid var(--border-light);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal h3 {
    color: var(--primary-purple);
    margin-bottom: 16px;
    font-size: 1.5rem;
    font-weight: 700;
}

.modal p {
    color: var(--text-medium);
    margin-bottom: 24px;
    line-height: 1.5;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-button {
    padding: 12px 24px;
    border: 2px solid transparent;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 120px;
    font-size: 0.95rem;
}

.modal-button:focus {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

.modal-button.cancel {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    color: var(--text-medium);
    border-color: #cbd5e1;
}

.modal-button.cancel:hover {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

.modal-button.confirm {
    background: linear-gradient(135deg, var(--error-color), #b91c1c);
    color: white;
    border-color: var(--error-color);
}

.modal-button.confirm:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
}

/* Focus management for modal */
.modal .modal-content:focus {
    outline: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }
    
    .container {
        padding: 24px 20px;
        border-radius: 12px;
    }
    
    .stats {
        flex-direction: column;
        gap: 12px;
    }
    
    .stat {
        min-width: auto;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-button {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
        font-size: 14px;
    }
    
    .container {
        padding: 20px 16px;
    }
    
    .checkin-button {
        padding: 14px 24px;
    }
    
    .progress-section,
    .action-section,
    .info-section {
        padding: 20px 16px;
    }
    
    header {
        padding: 20px 16px;
    }
}

/* Large text mode support */
@media (prefers-reduced-data: reduce) {
    .container {
        background: white;
        box-shadow: none;
    }
}

/* Print styles */
@media print {
    .container {
        box-shadow: none;
        background: white;
        border: 1px solid #000;
    }
    
    .checkin-button,
    .reset-link {
        display: none;
    }
}

/* Animation for check-in with reduced motion support */
@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.celebrate {
    animation: celebrate 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
    .celebrate {
        animation: none;
        outline: 2px solid var(--success-color);
    }
}

/* Status colors for better visual hierarchy */
.status-success {
    color: var(--success-color);
}

.status-warning {
    color: var(--warning-color);
}

.status-error {
    color: var(--error-color);
}

/* Ensure sufficient color contrast */
.contrast-check {
    /* These colors meet WCAG AA standards for contrast */
    color: #1f2937; /* on white background = 11.5:1 */
    color: #5b21b6; /* on white background = 7.5:1 */
    color: #1e40af; /* on white background = 6.5:1 */
}