/* ============================================================================
   MANAGOV Kids — Design system partagé (élèves de 6 à 11 ans)
   Palette chaude, typo ronde, cartes épaisses, effets tactiles.
   Toutes les classes sont préfixées « k- » pour ne rien casser ailleurs.
   ========================================================================== */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
    --k-bg:        #FFF7EC;
    --k-ink:       #2B2350;
    --k-ink-soft:  #5B5478;
    --k-ink-mute:  #6B6489;
    --k-ink-light: #9B9AB0;
    --k-border:    #FFE0B8;
    --k-white:     #ffffff;

    /* couleur active de la carte courante (surchargée par .k-p1 … .k-p6) */
    --c:    #FF6B6B;
    --sh:   #E24E4E;
    --soft: #FFE9E9;
}

/* Rotation de palette — appliquée par index depuis Jinja */
.k-p1 { --c: #FF6B6B; --sh: #E24E4E; --soft: #FFE9E9; }
.k-p2 { --c: #4D96FF; --sh: #2F6BD6; --soft: #E4EEFF; }
.k-p3 { --c: #2EC4B6; --sh: #1F9E92; --soft: #DCF6F3; }
.k-p4 { --c: #FFB020; --sh: #E09112; --soft: #FFF1D6; }
.k-p5 { --c: #9B5DE5; --sh: #7B41C4; --soft: #F1E6FF; }
.k-p6 { --c: #FF8A3D; --sh: #E06E22; --soft: #FFEAD9; }

/* ── Reset & base ────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--k-bg);
    color: var(--k-ink);
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: #4D96FF; text-decoration: none; }
a:hover { color: #2F6BD6; }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes k-bob      { 0%,100% { transform: translateY(0); }                  50% { transform: translateY(-10px); } }
@keyframes k-bobSlow  { 0%,100% { transform: translateY(0) rotate(-2deg); }    50% { transform: translateY(-14px) rotate(2deg); } }
@keyframes k-pop      { 0%      { transform: scale(.85); opacity: 0; }        100% { transform: scale(1); opacity: 1; } }
@keyframes k-floaty   { 0%,100% { transform: translateY(0) rotate(0); }        50% { transform: translateY(-24px) rotate(8deg); } }
@keyframes k-twinkle  { 0%,100% { opacity: .5; transform: scale(.8); }         50% { opacity: 1; transform: scale(1.15); } }
@keyframes k-pulseRing{ 0%      { transform: scale(1); opacity: .7; }         100% { transform: scale(2.1); opacity: 0; } }

/* ── Page & décor ────────────────────────────────────────────────────────── */
.k-page {
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 60px;
    background:
        radial-gradient(circle at 12% 8%,  #FFE6C7 0, transparent 34%),
        radial-gradient(circle at 88% 4%,  #D9ECFF 0, transparent 32%),
        radial-gradient(circle at 92% 96%, #E6F7F2 0, transparent 40%),
        var(--k-bg);
    transition: opacity .25s ease;
}

.k-page.fade-out { opacity: 0; }

.k-blob {
    position: absolute;
    pointer-events: none;
    border-radius: 42% 58% 60% 40% / 45% 45% 55% 55%;
    animation: k-floaty 9s ease-in-out infinite;
    z-index: 0;
}
.k-blob--1 { top: 120px; left: 4%;  width: 70px; height: 70px; background: #FFC93C; opacity: .35; }
.k-blob--2 { top: 340px; right: 5%; width: 54px; height: 54px; background: #FF6B6B; opacity: .30; border-radius: 50%; animation-duration: 11s; }
.k-blob--3 { bottom: 120px; left: 8%; width: 46px; height: 46px; background: #2EC4B6; opacity: .32; border-radius: 50%; animation-duration: 8s; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.k-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 34px;
    background: rgba(255, 247, 236, .86);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid var(--k-border);
}

.k-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.k-brand img {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    object-fit: contain;
    background: #fff;
    box-shadow: 0 5px 0 #E9A93A;
}

.k-brand-name {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: var(--k-ink);
    line-height: 1;
    text-align: left;
}

.k-brand-sub {
    font-family: 'Fredoka', sans-serif;
    font-weight: 500;
    font-size: 13px;
    color: #FF6B6B;
    letter-spacing: .5px;
    text-align: left;
}

.k-header-actions { display: flex; align-items: center; gap: 12px; }

.k-nav-links {
    display: flex;
    gap: 26px;
    list-style: none;
}

.k-nav-links a {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: var(--k-ink-mute);
    transition: color .2s ease, transform .2s ease;
    display: inline-block;
}

.k-nav-links a:hover { color: #FF6B6B; transform: translateY(-2px); }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.k-btn {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    background: #4D96FF;
    border: none;
    border-radius: 999px;
    padding: 11px 24px;
    cursor: pointer;
    box-shadow: 0 5px 0 #2F6BD6;
    transition: transform .15s ease, box-shadow .15s ease;
    display: inline-block;
    text-align: center;
}

.k-btn:hover  { transform: translateY(-2px); }
.k-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #2F6BD6; }

.k-btn--ghost {
    color: var(--k-ink);
    background: #fff;
    border: 3px solid #FFD79A;
    box-shadow: 0 4px 0 #FFD79A;
    padding: 9px 22px;
}
.k-btn--ghost:active { box-shadow: 0 2px 0 #FFD79A; }

.k-btn--accent {
    background: #FF6B6B;
    box-shadow: 0 6px 0 #E24E4E;
    font-size: 20px;
    padding: 16px 36px;
}
.k-btn--accent:active { transform: translateY(4px); box-shadow: 0 2px 0 #E24E4E; }

/* Accès à un espace d'administration : présent mais volontairement sobre,
   pour ne pas concurrencer les actions destinées aux élèves. */
.k-btn--admin {
    color: #2F4A75;
    background: #EDF3FD;
    border: 3px solid #C6D9F5;
    box-shadow: 0 4px 0 #C6D9F5;
    padding: 9px 20px;
    font-size: 15px;
    text-decoration: none;
}
.k-btn--admin:hover  { background: #E1ECFB; }
.k-btn--admin:active { box-shadow: 0 2px 0 #C6D9F5; }

.k-btn--block { width: 100%; }

.k-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(.4);
}

/* ── Fil d'étapes (Accueil › Niveau › Année › …) ─────────────────────────── */
.k-steps {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 22px 20px 4px;
}

.k-step {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 15px;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 999px;
    background: #fff;
    color: var(--k-ink-mute);
    box-shadow: 0 3px 0 var(--k-border);
    transition: transform .15s ease;
}

.k-step:hover { transform: translateY(-2px); }
.k-step span  { font-size: 18px; }

.k-step.is-done   { background: #FFE9E9; }
.k-step.is-active {
    background: #FF6B6B;
    color: #fff;
    box-shadow: 0 4px 0 #E24E4E;
}

/* étape future : non cliquable */
.k-step.is-locked {
    cursor: default;
    opacity: .55;
}
.k-step.is-locked:hover { transform: none; }

/* ── En-tête de section ──────────────────────────────────────────────────── */
.k-main {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px 30px;
}

.k-main--narrow { max-width: 1000px; }
.k-main--wide   { max-width: 1180px; }

.k-head {
    text-align: center;
    margin: 14px 0 24px;
    animation: k-pop .4s ease-out;
}

.k-crumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: var(--k-ink-mute);
    background: #fff;
    border: 3px solid var(--k-border);
    padding: 7px 18px;
    border-radius: 999px;
    margin-bottom: 14px;
}

.k-crumb a       { color: var(--k-ink-mute); }
.k-crumb a:hover { color: #FF6B6B; }
.k-crumb .k-crumb-current { color: #FF6B6B; }

.k-title {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3.6vw, 2.8rem);
    color: var(--k-ink);
    margin-bottom: 8px;
    line-height: 1.1;
}

.k-sub {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--k-ink-mute);
    max-width: 620px;      /* lignes courtes : plus lisible pour un jeune lecteur */
    margin-inline: auto;
    line-height: 1.5;
}

.k-section-title {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: var(--k-ink);
    text-align: center;
    margin: 34px 0 22px;
}

/* ── Grilles ─────────────────────────────────────────────────────────────── */
.k-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.k-grid--sm { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px; }
.k-grid--xs { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; }

/* ── Carte ───────────────────────────────────────────────────────────────── */
.k-card {
    position: relative;
    background: #fff;
    border: 4px solid var(--c);
    border-radius: 32px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 12px 0 var(--sh);
    display: flex;
    flex-direction: column;
    animation: k-pop .5s ease-out;
    transition: transform .18s ease;
    text-align: left;
    font: inherit;
    color: inherit;
}

.k-card:hover      { transform: translateY(-6px) rotate(-1deg); }
.k-card:nth-child(even):hover { transform: translateY(-6px) rotate(1deg); }
.k-card:focus-visible { outline: 4px solid var(--sh); outline-offset: 4px; }

.k-card.is-disabled {
    cursor: not-allowed;
    filter: grayscale(.55);
    opacity: .75;
}
.k-card.is-disabled:hover { transform: none; }

.k-card.is-selected { transform: translateY(-6px) scale(1.02); }

/* média de carte */
.k-card__media {
    position: relative;
    height: 170px;
    overflow: hidden;
    background: var(--soft);
}

.k-card__media--sm { height: 130px; }
.k-card__media--lg { height: 180px; }

.k-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* média « emoji géant » quand il n'y a pas de photo */
.k-card__media--emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
}

.k-card__scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, var(--c));
}

/* pastille emoji */
.k-card__emoji {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 0 var(--sh);
}

.k-card__emoji--sm { width: 46px; height: 46px; border-radius: 15px; font-size: 24px; top: 10px; left: 10px; }
.k-card__emoji--white { background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); }

/* titre posé sur le média */
.k-card__overtitle {
    position: absolute;
    bottom: 12px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.k-card__overtitle h2 {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1.7rem;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

/* badge « bientôt » */
.k-card__soon {
    position: absolute;
    top: 14px;
    right: 14px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 12px;
    background: #fff;
    color: #9B5DE5;
    padding: 5px 12px;
    border-radius: 999px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, .08);
}

/* corps de carte */
.k-card__body {
    padding: 20px 22px 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.k-card__body--center { text-align: center; align-items: center; }

.k-card__tag {
    align-self: flex-start;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    background: var(--c);
    padding: 5px 14px;
    border-radius: 999px;
    margin-bottom: 12px;
}

.k-card__title {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--k-ink);
    margin-bottom: 8px;
}

.k-card__title--sm { font-size: 1.25rem; margin-bottom: 4px; }

.k-card__kicker {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--c);
    margin-bottom: 4px;
}

.k-card__desc {
    font-weight: 600;
    color: var(--k-ink-mute);
    font-size: 1rem;
    line-height: 1.45;
    flex: 1;
    margin-bottom: 16px;
}

.k-card__desc--sm { font-size: .92rem; }

.k-card__cta {
    align-self: flex-start;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    background: var(--c);
    padding: 11px 26px;
    border-radius: 999px;
    box-shadow: 0 5px 0 var(--sh);
}

.k-card__body--center .k-card__cta { align-self: center; font-size: 15px; padding: 9px 22px; box-shadow: 0 4px 0 var(--sh); }

/* carte « pastille » pleine couleur douce (choix d'année) */
.k-card--soft {
    background: var(--soft);
    border-radius: 28px;
    padding: 26px 20px;
    text-align: center;
    box-shadow: 0 9px 0 var(--sh);
    align-items: center;
}

.k-card--soft:hover { transform: translateY(-5px) rotate(-1.5deg); }

.k-card__num {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    border-radius: 20px;
    background: var(--c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 26px;
    color: #fff;
    box-shadow: 0 5px 0 var(--sh);
}

/* ── Chips (liste de matières dans un groupe) ────────────────────────────── */
.k-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.k-chip {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--c);
    background: var(--soft);
    padding: 6px 14px;
    border-radius: 999px;
}

/* ── Étoiles ludiques ────────────────────────────────────────────────────── */
.k-stars { display: flex; align-items: center; gap: 6px; }
.k-stars span:not(.k-stars-label) { font-size: 18px; animation: k-twinkle 2s ease-in-out infinite; }
.k-stars span:nth-child(2) { animation-delay: .3s; }
.k-stars span:nth-child(3) { animation-delay: .6s; }
.k-stars-label {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    color: var(--k-ink-light);
    font-size: .9rem;
    margin-left: 6px;
    animation: none;
}

/* ── Note « bientôt disponible » ─────────────────────────────────────────── */
.k-note {
    display: inline-block;
    margin-top: 12px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: .9rem;
    color: #9B5DE5;
    background: #F1E6FF;
    padding: 6px 14px;
    border-radius: 999px;
}

/* ── État vide ───────────────────────────────────────────────────────────── */
.k-empty {
    max-width: 560px;
    margin: 30px auto;
    background: #fff;
    border: 4px solid #FFB020;
    border-radius: 32px;
    padding: 34px 30px;
    text-align: center;
    box-shadow: 0 12px 0 #E09112;
    animation: k-pop .4s ease-out;
}

.k-empty-icon { font-size: 56px; margin-bottom: 12px; }

.k-empty h2 {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--k-ink);
    margin-bottom: 10px;
}

.k-empty p {
    font-weight: 600;
    color: var(--k-ink-mute);
    line-height: 1.5;
    margin-bottom: 20px;
}

/* ── Carte formulaire (connexion) ────────────────────────────────────────── */
.k-authcard {
    position: relative;
    background: #fff;
    border: 4px solid #4D96FF;
    border-radius: 36px;
    padding: 38px 32px 30px;
    box-shadow: 0 14px 0 #2F6BD6;
    animation: k-pop .4s ease-out;
}

.k-authface {
    position: absolute;
    top: -48px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 90px;
    border-radius: 28px;
    background: linear-gradient(135deg, #5FD0C4, #2EC4B6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 46px;
    box-shadow: 0 6px 0 #1F9E92;
    animation: k-bob 3s ease-in-out infinite;
}

.k-label {
    display: block;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    color: var(--k-ink);
    margin-bottom: 8px;
}

.k-input {
    width: 100%;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--k-ink);
    background: #F7FAFF;
    border: 3px solid #D6E4FF;
    border-radius: 16px;
    padding: 14px 16px;
    outline: none;
    transition: border-color .2s ease;
}

.k-input:focus { border-color: #4D96FF; }
.k-input::placeholder { color: #A9B4CC; }

/* ── Mascotte robot (accueil) ────────────────────────────────────────────── */
.k-mascot {
    position: relative;
    width: 130px;
    height: 143px;
    animation: k-bobSlow 5s ease-in-out infinite;
    transform-origin: bottom center;
    pointer-events: none;
}

.k-mascot__antenna {
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 16px;
    background: #8AD0C8;
}

.k-mascot__bulb {
    position: absolute;
    top: -19px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #FFC93C;
    box-shadow: 0 0 0 3px #FFE9A8;
    animation: k-twinkle 2s ease-in-out infinite;
}

.k-mascot__head {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 112px;
    height: 99px;
    border-radius: 25px;
    background: linear-gradient(150deg, #5FD0C4, #2EC4B6);
    box-shadow: 0 6px 0 #1F9E92;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.k-mascot__eyes {
    display: flex;
    gap: 14px;
    margin-top: 4px;
}

.k-mascot__eye {
    width: 16px;
    height: 21px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: k-blink 5.5s ease-in-out infinite;
}

.k-mascot__eye:last-child { animation-delay: .2s; }

.k-mascot__eye i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--k-ink);
}

.k-mascot__cheeks {
    position: absolute;
    top: 57px;
    display: flex;
    gap: 60px;
}

.k-mascot__cheeks i {
    width: 12px;
    height: 7px;
    border-radius: 50%;
    background: #FF8FA3;
    opacity: .75;
}

.k-mascot__smile {
    width: 33px;
    height: 17px;
    border-bottom: 4px solid var(--k-ink);
    border-radius: 0 0 25px 25px;
    margin-top: 12px;
}

.k-mascot__arm {
    position: absolute;
    top: 43px;
    right: 4px;
    width: 10px;
    height: 35px;
    border-radius: 999px;
    background: #2EC4B6;
    transform-origin: top center;
    transform: rotate(28deg);
    box-shadow: 0 3px 0 #1F9E92;
}

@keyframes k-blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.k-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-top: 46px;
    padding: 26px 20px;
}

.k-footer-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 3px solid var(--k-border);
    border-radius: 999px;
    padding: 12px 26px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    color: var(--k-ink-mute);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
    .k-header      { padding: 12px 18px; }
    .k-nav-links   { display: none; }
    .k-brand img   { width: 44px; height: 44px; }
    .k-brand-name  { font-size: 19px; }
    .k-main        { padding: 12px 18px; }
    .k-card__media { height: 150px; }
}

@media (max-width: 480px) {
    .k-header-actions .k-btn { font-size: 14px; padding: 9px 16px; }
    .k-btn--accent { font-size: 18px; padding: 14px 28px; }
    .k-steps { gap: 8px; padding: 16px 12px 4px; }
    .k-step  { font-size: 13px; padding: 7px 12px; }
}

/* ── Accessibilité : respect de « réduire les animations » ───────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
