/* ==================== */
/* CSS Variables & Reset */
/* ==================== */

:root {
    /* Colors - Casual but professional palette */
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-paper: #fffef7;
    --color-paper-line: #d4e5f7;
    --color-paper-margin: #f8d7da;
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-border: #e5e7eb;
    --color-success: #10b981;
    --color-checkbox-bg: #f3f4f6;

    /* Paper line spacing */
    --line-height-paper: 3rem;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Typography */
    --font-family: 'Covered By Your Grace', cursive, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-family-title: 'Caveat', cursive, 'Covered By Your Grace', cursive;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2.5rem;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

/* ==================== */
/* Layout */
/* ==================== */

.container {
    width: 100%;
    max-width: 600px;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== */
/* Header */
/* ==================== */

.header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.title {
    font-family: var(--font-family-title);
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
    letter-spacing: 0.02em;
    transition: transform var(--transition-base);
}

.title:hover {
    transform: translateY(-2px);
}

.subtitle {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    font-weight: 400;
}

/* ==================== */
/* Todo Card */
/* ==================== */

.todo-card {
    background: var(--color-paper);
    background-image:
        /* Red margin line */
        linear-gradient(to right,
            transparent 0,
            transparent 3.5rem,
            var(--color-paper-margin) 3.5rem,
            var(--color-paper-margin) 3.75rem,
            transparent 3.75rem),
        /* Horizontal ruled lines */
        repeating-linear-gradient(transparent,
            transparent calc(var(--line-height-paper) - 1px),
            var(--color-paper-line) calc(var(--line-height-paper) - 1px),
            var(--color-paper-line) var(--line-height-paper));
    border-radius: var(--radius-md);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.08),
        inset 0 0 60px rgba(255, 255, 255, 0.5);
    padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-xl) 4.5rem;
    margin-bottom: var(--spacing-xl);
    border: 1px solid #e8e4d8;
    position: relative;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.todo-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(0, 0, 0, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 0, 0, 0.015) 0%, transparent 50%);
    pointer-events: none;
    border-radius: var(--radius-md);
}

.todo-card:hover {
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.06),
        inset 0 0 60px rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: none;
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
}

.task-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    background: var(--color-checkbox-bg);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-lg);
    font-weight: 500;
}

/* ==================== */
/* Todo List */
/* ==================== */

.todo-list {
    list-style: none;
}

.todo-item {
    min-height: var(--line-height-paper);
    display: flex;
    align-items: center;
    transition: background-color var(--transition-fast);
    position: relative;
}

.todo-item:hover {
    background-color: rgba(99, 102, 241, 0.02);
}

.todo-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 0;
    gap: var(--spacing-md);
    width: 100%;
}

/* Hide default checkbox */
.todo-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Custom checkbox */
.checkbox-custom {
    position: relative;
    height: 24px;
    width: 24px;
    background-color: var(--color-checkbox-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.checkbox-custom::after {
    content: '';
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

/* Hover state */
.todo-label:hover .checkbox-custom {
    border-color: var(--color-primary);
    background-color: rgba(99, 102, 241, 0.1);
}

/* Checked state */
.todo-checkbox:checked~.checkbox-custom {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    animation: checkboxPop 0.3s ease-out;
}

.todo-checkbox:checked~.checkbox-custom::after {
    display: block;
    animation: checkmarkSlide 0.3s ease-out;
}

@keyframes checkboxPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes checkmarkSlide {
    0% {
        opacity: 0;
        transform: rotate(45deg) translateY(5px);
    }

    100% {
        opacity: 1;
        transform: rotate(45deg) translateY(0);
    }
}

/* Todo text */
.todo-text {
    font-size: 1.35rem;
    color: var(--color-text-primary);
    transition: all var(--transition-base);
    font-weight: 400;
    line-height: var(--line-height-paper);
}

.todo-checkbox:checked~.todo-text {
    color: var(--color-text-muted);
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

/* ==================== */
/* Footer */
/* ==================== */

.footer-text {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    animation: fadeIn 1s ease-out 0.3s both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.footer-text p {
    font-weight: 500;
}

/* ==================== */
/* Responsive Design */
/* ==================== */

@media (max-width: 640px) {
    :root {
        --font-size-2xl: 2rem;
        --font-size-xl: 1.25rem;
        --font-size-lg: 1rem;
    }

    body {
        padding: var(--spacing-md);
    }

    .todo-card {
        padding: var(--spacing-lg);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
}

/* ==================== */
/* Accessibility */
/* ==================== */

.todo-label:focus-within .checkbox-custom {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}