/* ==========================================
   Khutka — Mobile-first Design Foundation
   Duolingo-inspired, RTL, Persian-optimized
   ========================================== */

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

:root {
    --primary: #14B8A6;
    --primary-dark: #0F766E;
    --secondary: #FBBF24;
    --accent: #FB923C;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text: #0F172A;
    --muted: #64748B;
    --success: #22C55E;
    --error: #EF4444;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.12);
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Tahoma, Vazirmatn, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    text-align: right;
    direction: rtl;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary);
}

/* --- App Shell --- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.app-header {
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.brand:hover {
    color: var(--primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg);
}

.nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.nav-btn:hover {
    color: var(--error);
    background: #FEF2F2;
}

.inline-form {
    display: inline;
}

/* --- Page --- */
.page {
    flex: 1;
    padding: 24px 16px;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 20px 16px;
    color: var(--muted);
    font-size: 0.8rem;
    border-top: 1px solid #E2E8F0;
    background: var(--surface);
}

.footer-text {
    margin: 0;
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: 40px 0 32px;
}

.hero-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    display: block;
}

.hero h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.4;
}

.hero p {
    font-size: 1rem;
    color: var(--muted);
    max-width: 400px;
    margin: 0 auto 28px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

/* --- Cards Grid --- */
.cards-section {
    padding: 24px 0;
}

.cards-section h2 {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* --- Card --- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

.card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.card p {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.6;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    min-height: 48px;
    width: 100%;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(20, 184, 166, 0.4);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text);
}

.btn-secondary:hover {
    background: #F59E0B;
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--primary-dark);
    border: 2px solid var(--primary);
}

.btn-ghost:hover {
    background: var(--primary);
    color: #FFFFFF;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-height: 36px;
    width: auto;
    border-radius: 10px;
}

/* --- Form Card --- */
.form-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 20px;
    box-shadow: var(--shadow);
    max-width: 420px;
    margin: 0 auto;
}

.form-card h2 {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 24px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
    background: var(--surface);
}

.input::placeholder {
    color: #94A3B8;
}

/* --- Messages --- */
.message {
    text-align: center;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 16px;
    line-height: 1.5;
}

.message-success {
    background: #F0FDF4;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.message-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

/* Default message (green, backward-compatible) */
.message {
    background: #F0FDF4;
    color: #166534;
    border: 1px solid #BBF7D0;
}

/* --- Progress Bar --- */
.progress-bar {
    width: 100%;
    height: 12px;
    background: #E2E8F0;
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 6px;
    transition: width 0.4s ease;
}

/* --- XP Pill --- */
.xp-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #FEF9C3;
    color: #854D0E;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #FDE68A;
}

.xp-pill::before {
    content: "\2B50";
    font-size: 0.9rem;
}

/* --- Back Link (login/register) --- */
.form-links {
    text-align: center;
    margin-top: 20px;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

.back-link:hover {
    color: var(--primary-dark);
}

/* --- Section Divider --- */
.section-divider {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin: 24px 0;
    position: relative;
}

.section-divider::before,
.section-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: #E2E8F0;
}

.section-divider::before {
    right: 0;
}

.section-divider::after {
    left: 0;
}

/* --- Dashboard: Welcome Card --- */
.welcome-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #FFFFFF;
    text-align: center;
    padding: 28px 20px;
}

.welcome-card:hover {
    transform: none;
}

.welcome-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.welcome-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.welcome-card .btn-primary {
    background: #FFFFFF;
    color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.welcome-card .btn-primary:hover {
    background: #F0FDF4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* --- Dashboard: Stats --- */
.stats-card {
    padding: 16px 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
}

/* --- Dashboard: Section Title --- */
.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

/* --- Dashboard: Mission List --- */
.mission-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mission-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 2px solid #E2E8F0;
    background: var(--bg);
    transition: all var(--transition);
}

.mission-ready {
    border-color: var(--primary);
    background: #F0FDFA;
}

.mission-ready:hover {
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.15);
}

.mission-locked {
    opacity: 0.6;
}

.mission-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.mission-info {
    flex: 1;
    min-width: 0;
}

.mission-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.mission-desc {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}

.mission-status-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 16px;
    white-space: nowrap;
}

.badge-ready {
    background: var(--primary);
    color: #FFFFFF;
}

.badge-locked {
    background: #E2E8F0;
    color: var(--muted);
}

.badge-done {
    background: var(--success);
    color: #FFFFFF;
}

.badge-ready {
    text-decoration: none;
    cursor: pointer;
}

/* --- Dashboard: Mission Meta --- */
.mission-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

/* --- Dashboard: Progress Text --- */
.progress-text {
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
    margin-top: 10px;
}

/* --- Dashboard: Motivational Card --- */
.motivational-card {
    background: linear-gradient(135deg, #FEF9C3, #FDE68A);
    border: 1px solid #FBBF24;
    text-align: center;
    padding: 20px;
}

.motivational-card:hover {
    transform: none;
}

.motivational-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #92400E;
    line-height: 1.6;
    margin: 0;
}

/* --- Mobile Bottom Nav (prepared for future) --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    padding: 8px 0;
    z-index: 100;
    justify-content: space-around;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    color: var(--muted);
    padding: 4px 12px;
}

.bottom-nav a.active {
    color: var(--primary);
    font-weight: 700;
}

/* --- Responsive: Tablets and Up --- */
@media (min-width: 640px) {
    .page {
        padding: 32px 24px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-actions {
        flex-direction: row;
        justify-content: center;
    }

    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .btn {
        width: auto;
        min-width: 180px;
    }
}

/* --- Responsive: Desktop --- */
@media (min-width: 1024px) {
    .app-header {
        padding: 12px 32px;
    }

    .page {
        padding: 40px 32px;
    }
}

/* --- Mission Page: Header --- */
.mission-header-card {
    text-align: center;
    padding: 24px 20px;
}

.mission-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.mission-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #E2E8F0;
}

.mission-page-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.mission-page-summary {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

/* --- Mission Page: Meta Card --- */
.mission-meta-card {
    padding: 16px 20px;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    text-align: center;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.meta-icon {
    font-size: 1.2rem;
}

.meta-value {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

/* --- Mission Page: Step Cards --- */
.steps-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.step-card {
    display: flex;
    gap: 14px;
    padding: 16px;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: border-color var(--transition);
}

.step-card:hover {
    border-color: var(--primary);
}

.step-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 800;
    border-radius: 50%;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.step-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.step-type-label {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-dark);
    background: #F0FDFA;
    border: 1px solid #99F6E4;
    padding: 2px 8px;
    border-radius: 10px;
}

.step-body {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 12px;
}

.step-btn {
    width: auto !important;
    padding: 8px 20px !important;
    font-size: 0.82rem !important;
    min-height: 36px !important;
}

/* --- Dark mode hint (future) --- */
@media (prefers-color-scheme: dark) {
    /* Prepared for dark mode — not active yet */
}
