/* ==========================================================================
   Liste de tâches — thème "pastel simple"
   Fond blanc, palette douce réservée aux boutons et aux badges.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
    --bg: #FFFFFF;
    --bg-tint: #FBFAFE;
    --surface: #FFFFFF;
    --ink: #3D3A52;
    --ink-soft: #A6A1B8;
    --line: #ECE8F5;

    --lavender: #DED2FC;
    --lavender-ink: #6C58C9;
    --mint: #C3F0DE;
    --mint-ink: #2E9E76;
    --peach: #FFDCC2;
    --peach-ink: #C17A3E;
    --sky: #C7E4FF;
    --sky-ink: #4A87C2;
    --pink: #FFD2E3;
    --pink-ink: #C6598A;
    --danger: #E8607F;
    --danger-soft: #FFE7ED;

    --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'Space Mono', 'Courier New', monospace;

    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-full: 999px;
    --shadow-soft: 0 6px 20px rgba(61, 58, 82, 0.07);
    --shadow-softer: 0 2px 10px rgba(61, 58, 82, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 64px 20px;
}

h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2.1rem;
    letter-spacing: -0.02em;
    margin: 0 0 40px;
    padding: 10px 28px;
    color: var(--ink);
    position: relative;
    z-index: 1;
}

h1::before {
    content: '';
    position: absolute;
    inset: -18px -30px;
    z-index: -1;
    border-radius: 999px;
    background:
        radial-gradient(circle at 20% 30%, var(--lavender) 0%, transparent 60%),
        radial-gradient(circle at 80% 70%, var(--sky) 0%, transparent 60%),
        radial-gradient(circle at 50% 100%, var(--mint) 0%, transparent 55%);
    filter: blur(14px);
    opacity: 0.7;
}

/* --- Formulaire d'ajout ------------------------------------------------ */

.task-div {
    width: 100%;
    max-width: 480px;
}

#task-form {
    display: flex;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 8px;
    box-shadow: var(--shadow-softer);
}

#task-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
    padding: 12px 14px;
}

#task-input:focus {
    outline: none;
}

#task-input::placeholder {
    color: var(--ink-soft);
    font-weight: 500;
}

#task-form button {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--lavender-ink);
    background: var(--lavender);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 24px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

#task-form button:hover {
    background: #D2C3FB;
    transform: translateY(-1px);
    box-shadow: var(--shadow-softer);
}

#task-form button:active {
    transform: translateY(0);
    box-shadow: none;
}

#task-form button:focus-visible,
#task-input:focus-visible {
    outline: 2px solid var(--lavender-ink);
    outline-offset: 2px;
}

#error-message {
    width: 100%;
    margin: 10px 0 0;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--danger);
    min-height: 1em;
    text-align: center;
}

#error-message:empty {
    display: none;
}

/* --- Sélecteur d'utilisateur -------------------------------------------- */

#task-user {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--sky-ink);
    background: var(--sky);
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 30px 8px 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A87C2' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    transition: background 0.15s ease;
}

#task-user:hover {
    background-color: #B6DBFF;
}

#task-user:focus-visible {
    outline: 2px solid var(--sky-ink);
    outline-offset: 2px;
}

#task-user option {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
}

/* --- Sélecteur de priorité ----------------------------------------------- */

#task-priority {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--peach-ink);
    background: var(--peach);
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 30px 8px 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C17A3E' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    transition: background 0.15s ease;
}

#task-priority:hover {
    background-color: #FFCBA0;
}

#task-priority:focus-visible {
    outline: 2px solid var(--peach-ink);
    outline-offset: 2px;
}

#task-priority option {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
}

/* --- Bascule Tâches du soir / Tâches accomplies ------------------------- */
.hidden {
    display: none !important;
}
.choice-btn {
    width: 100%;
    max-width: 480px;
    display: flex;
    gap: 8px;
    margin-top: 28px;
    background: var(--bg-tint);
    padding: 5px;
    border-radius: var(--radius-md);
}
.choice-btn button {
    flex: 1;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--ink-soft);
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 11px 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.choice-btn button:hover {
    color: var(--ink);
}

.choice-btn button.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-softer);
}

.choice-btn button:focus-visible {
    outline: 2px solid var(--lavender-ink);
    outline-offset: 2px;
}

/* --- Filtre par utilisateur ---------------------------------------------- */

.filter-div {
    width: 100%;
    max-width: 480px;
    display: flex;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.filter-div button {
    flex: 1;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--ink-soft);
    background: var(--bg-tint);
    border: none;
    border-radius: var(--radius-full);
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.filter-div button:hover {
    color: var(--ink);
}

.filter-div button.active {
    background: var(--lavender);
    color: var(--lavender-ink);
}

#loana.active {
    background: var(--pink);
    color: var(--pink-ink);
}

#romain.active {
    background: var(--sky);
    color: var(--sky-ink);
}

.filter-div button:focus-visible {
    outline: 2px solid var(--lavender-ink);
    outline-offset: 2px;
}

/* --- Liste des tâches --------------------------------------------------- */

#task-list, #history-list {
    width: 100%;
    max-width: 480px;
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-list:empty::before {
    content: '🎉 Rien à faire pour l’instant !';
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink-soft);
    padding: 28px 4px;
    text-align: center;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-softer);
    animation: appear 0.25s ease;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.task-item:hover {
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

@keyframes appear {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Case à cocher personnalisée : pastille colorée */
.task-checkbox {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.task-checkbox:hover {
    transform: scale(1.08);
    border-color: var(--mint-ink);
}

.task-checkbox:checked {
    background: var(--mint);
    border-color: var(--mint);
}

.task-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 11px;
    border: solid var(--mint-ink);
    border-width: 0 2px 2px 0;
    transform: rotate(40deg);
}

.task-checkbox:focus-visible {
    outline: 2px solid var(--mint-ink);
    outline-offset: 2px;
}

.task-item > p {
    flex-shrink: 0;
}

.task-description {
    flex: 1;
    min-width: 0;
    font-size: 0.96rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    overflow-wrap: break-word;
    word-break: break-word;
}

.task-item.completed .task-description {
    color: var(--ink-soft);
    text-decoration: line-through;
    text-decoration-color: var(--mint-ink);
    text-decoration-thickness: 2px;
}

.task-date {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--peach-ink);
    background: var(--peach);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

/* --- Priorité de la tâche ------------------------------------------------ */

.priority-high {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--danger);
    background: var(--danger-soft);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

.priority-medium {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--peach-ink);
    background: var(--peach);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

.priority-low {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--mint-ink);
    background: var(--mint);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

/* --- Bulles utilisateur (droite / gauche) ------------------------------- */

.user-r {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--sky-ink);
    background: var(--sky);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

.user-l {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--pink-ink);
    background: var(--pink);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

.task-delete {
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    padding: 5px 9px;
    border-radius: var(--radius-full);
    transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.task-delete:hover {
    color: var(--danger);
    background: var(--danger-soft);
    transform: scale(1.08);
}

.task-delete:focus-visible {
    outline: 2px solid var(--danger);
    outline-offset: 2px;
}

/* --- Feu d'artifice au moment de cocher une tâche ------------------------ */

.firework-particle {
    position: fixed;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 999;
    animation: firework-burst 0.55s ease-out forwards;
}

@keyframes firework-burst {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.3);
        opacity: 0;
    }
}

/* --- Accessibilité / mouvement réduit ----------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .task-item {
        animation: none;
    }
    #task-form button,
    #task-user,
    .choice-btn button,
    .task-item,
    .task-checkbox,
    .task-delete {
        transition: none;
    }
}

/* --- Mobile -------------------------------------------------------------- */

@media (max-width: 768px) {
    body {
        padding: 48px 20px;
    }
    .task-div,
    .choice-btn,
    .filter-div,
    #task-list,
    #history-list {
        max-width: 100%;
    }
}

@media (max-width: 520px) {
    body {
        padding: 32px 14px;
    }
    h1 {
        font-size: 1.6rem;
    }
    #task-form {
        flex-wrap: wrap;
    }
    #task-input {
        flex-basis: 100%;
        order: 1;
    }
    #task-user,
    #task-priority {
        flex: 1 1 auto;
        min-width: 0;
        order: 2;
    }
    #task-form button {
        flex: 0 0 auto;
        order: 3;
        padding: 0 18px;
    }
    .filter-div button {
        flex-basis: calc(50% - 4px);
    }
    .task-item {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .task-date {
        display: none;
    }
}

@media (max-width: 360px) {
    body {
        padding: 24px 10px;
    }
    h1 {
        font-size: 1.4rem;
    }
    h1::before {
        font-size: 0.6rem;
    }
    .task-item {
        padding: 12px 10px;
    }
    .task-description {
        font-size: 0.9rem;
    }
    .filter-div button,
    .choice-btn button {
        font-size: 0.72rem;
        padding: 9px 8px;
    }
}