/* Base styles with improved typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2C3E50;
    --secondary: #FFFFFF;
    --accent: #E67E22;
    --accent-light: #F39C12;
    --text: #2C3E50;
    --text-light: #5D6D7E;
    --light-bg: #FDF6E3;
    --card-bg: #FFFFFF;
    --border: #EAEDED;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-hover: 0 5px 15px rgba(0,0,0,0.12);
    --shadow-strong: 0 8px 25px rgba(0,0,0,0.15);
    --success: #27AE60;
    --warning: #F39C12;
    --error: #E74C3C;
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Playfair Display', Georgia, serif;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
}

body {
    font-family: var(--font-primary);
    background-color: var(--light-bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    font-weight: 400;
}

/* Improved Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-sm);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

p {
    margin-bottom: var(--space-sm);
    color: var(--text-light);
}

/* Header styles */
header {
    background: var(--card-bg);
    color: var(--text);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
    border-bottom: 1px solid var(--border);
    transform: translateY(0);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

header.hidden {
    transform: translateY(-100%);
}

header.scrolled {
    padding: 0.7rem 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    color: var(--primary);
    font-family: var(--font-heading);
}

.logo span {
    color: var(--accent);
}

/* Navigation */
nav ul {
    display: flex;
    list-style: none;
    gap: var(--space-lg);
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

nav a:hover {
    color: var(--accent);
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

nav a:hover::after {
    width: 100%;
}

/* Buttons */
.auth-btn, .btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.auth-btn {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.auth-btn:hover {
    background: var(--primary);
    color: var(--secondary);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--accent);
    color: var(--secondary);
}

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    transform: translateY(-2px);
}

.cta-button {
    background: var(--accent);
    color: var(--secondary);
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
}

.cta-button:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #34495E 100%);
    color: var(--secondary);
    padding: var(--space-xl) 0;
    text-align: center;
}

.hero h1 {
    color: var(--secondary);
    margin-bottom: var(--space-md);
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
}

.hero p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto var(--space-lg);
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease 0.2s forwards;
}

/* Discovery Section */
.discovery-section {
    padding: var(--space-lg) 0;
    background: var(--card-bg);
}

.discovery-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    overflow-x: auto;
    padding-bottom: var(--space-xs);
}

.discovery-tab {
    background: var(--light-bg);
    border: 1px solid var(--border);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-weight: 500;
}

.discovery-tab.active, .discovery-tab:hover {
    background: var(--accent);
    color: var(--secondary);
    border-color: var(--accent);
}

/* Stories Grid */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.story-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.story-content {
    padding: var(--space-md);
}

.story-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--primary);
    line-height: 1.4;
}

.story-excerpt {
    color: var(--text-light);
    margin-bottom: var(--space-md);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-meta {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: var(--space-sm);
    font-size: 0.9rem;
    color: var(--text-light);
}

.story-category, .emotion-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.story-category {
    background: var(--light-bg);
    color: var(--primary);
}

.emotion-tag {
    background: var(--accent);
    color: var(--secondary);
    margin-left: var(--space-xs);
}

.story-actions {
    display: flex;
    gap: var(--space-sm);
}

.story-action {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.story-action:hover {
    background: var(--light-bg);
    color: var(--accent);
}

.story-action.active {
    color: var(--accent);
}

/* Progress Form */
.form-progress {
    margin-bottom: var(--space-lg);
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--border);
    z-index: 1;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    transition: all 0.3s ease;
}

.progress-step.active .step-number {
    background: var(--accent);
    color: var(--secondary);
}

.step-label {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.progress-step.active .step-label {
    color: var(--accent);
}

/* Form Steps */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 600;
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--card-bg);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.1);
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.form-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.word-counter, .draft-status {
    font-size: 0.85rem;
    color: var(--text-light);
}

.draft-status.saving {
    color: var(--warning);
}

.draft-status.saved {
    color: var(--success);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: space-between;
    margin-top: var(--space-lg);
}

/* Review Section */
.review-section {
    background: var(--light-bg);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.review-card {
    background: var(--card-bg);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.review-excerpt {
    color: var(--text-light);
    line-height: 1.6;
}

.review-image-preview {
    margin-top: var(--space-md);
}

.review-image-preview img {
    max-width: 100%;
    border-radius: var(--radius-md);
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.text-link {
    color: var(--accent);
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

/* Privacy Section */
.privacy-section {
    background: var(--light-bg);
    padding: var(--space-xl) 0;
}

.privacy-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-lg);
    margin: var(--space-lg) 0;
}

.privacy-feature-card {
    background: var(--card-bg);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.privacy-feature-card h3 {
    color: var(--primary);
    margin-bottom: var(--space-md);
}

.privacy-feature-card ul {
    list-style: none;
}

.privacy-feature-card li {
    padding: var(--space-xs) 0;
    position: relative;
    padding-left: var(--space-md);
}

.privacy-feature-card li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

.privacy-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
}

/* Sidebar Widgets */
.sidebar-widget {
    background: var(--card-bg);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow);
}

.user-progress-widget {
    background: linear-gradient(135deg, var(--primary) 0%, #34495E 100%);
    color: var(--secondary);
}

.user-progress-widget h3 {
    color: var(--secondary);
}

.progress-bar {
    background: rgba(255, 255, 255, 0.2);
    height: 8px;
    border-radius: 4px;
    margin: var(--space-sm) 0;
    overflow: hidden;
}

.progress-fill {
    background: var(--accent);
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin-bottom: var(--space-sm);
}

.badges-container {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--secondary);
}

.badge.earned {
    background: var(--accent);
}

.anonymity-info .privacy-features {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin: var(--space-md) 0;
}

.privacy-feature {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9rem;
}

.privacy-feature i {
    color: var(--accent);
    width: 20px;
}

.privacy-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.privacy-link:hover {
    text-decoration: underline;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    margin: 5% auto;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    position: relative;
    box-shadow: var(--shadow-strong);
    animation: slideUp 0.3s ease;
}

.close-modal {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--accent);
}

/* Success Modal */
.success-modal .modal-content {
    text-align: center;
    max-width: 500px;
}

.success-animation {
    font-size: 4rem;
    color: var(--success);
    margin-bottom: var(--space-md);
    animation: bounce 1s ease;
}

/* AI Summary */
.ai-summary {
    background: var(--light-bg);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin: var(--space-md) 0;
    border-left: 4px solid var(--accent);
}

.ai-summary h4 {
    color: var(--primary);
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Read Next */
.read-next {
    margin: var(--space-lg) 0;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
}

.read-next-stories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.read-next-story {
    background: var(--light-bg);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    cursor: pointer;
}

.read-next-story:hover {
    background: var(--border);
    transform: translateX(5px);
}

.read-next-story h5 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.read-next-story p {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: var(--secondary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-strong);
    z-index: 1001;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    max-width: 300px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        width: 95%;
    }
    
    .nav-container {
        flex-direction: row;
    }
    
    .desktop-nav {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .stories-grid {
        grid-template-columns: 1fr;
    }
    
    .discovery-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: var(--space-md);
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    :root {
        --space-lg: 1.5rem;
        --space-xl: 2rem;
    }
    
    .hero {
        padding: var(--space-lg) 0;
    }
    
    .privacy-features-grid {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .story-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}