/* ═══════════════════════════════════════════════════════════════════
   Organisateur cognitif — styles
   Sections: tokens · top bar · card/header · stage · N1 · N3 · N5 ·
             picker · responsive · print
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Tokens ─────────────────────────────────────────────────────── */
:root {
    --bg:       #0b0f19;
    --surface:  #111827;
    --surface2: #1e293b;
    --border:   #334155;
    --text:     #f1f5f9;
    --muted:    #94a3b8;
    --blue:     #60a5fa;
    --blue-dk:  #2563eb;
    --purple:   #a78bfa;
    --orange:   #fb8500;
    --green:    #34d399;
    --yellow:   #fbbf24;
    --pink:     #f472b6;
    --teal:     #2dd4bf;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Nunito', 'Segoe UI', sans-serif;
}

/* ─── Fixed top bar ──────────────────────────────────────────────── */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: rgba(11,15,25,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.7rem;
    z-index: 300;
}
.home-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    text-decoration: none;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
.home-btn:hover { background: var(--border); transform: scale(1.08); }

.bar-title {
    font-weight: 900;
    font-size: 0.95rem;
    background: linear-gradient(90deg, var(--purple), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Level switch (N1 · N3 · N5) ── */
.level-switch {
    display: flex;
    gap: 2px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 2px;
    flex-shrink: 0;
}
.level-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-weight: 900;
    font-size: 0.8rem;
    padding: 0.3rem 0.55rem;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    transition: background 0.18s, color 0.18s;
}
.level-btn:hover { color: var(--text); }
.level-btn.active { color: #fff; }
.level-btn[data-level="N1"].active { background: var(--green); color: #06281c; }
.level-btn[data-level="N3"].active { background: var(--yellow); color: #1a1205; }
.level-btn[data-level="N5"].active { background: var(--pink); }

.artwork-select {
    flex: 0 1 230px;
    padding: 0.38rem 0.65rem;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
.artwork-select:focus { border-color: var(--purple); }

.print-btn {
    display: flex; align-items: center; gap: 0.3rem;
    padding: 0.38rem 0.8rem;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}
.print-btn:hover { background: var(--border); border-color: var(--purple); }

/* ─── Page wrapper ───────────────────────────────────────────────── */
.page {
    padding-top: 62px;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.organizer-card {
    width: 100%;
    max-width: 880px;
    background: #090d16;
    border: 2px solid #3f4f68;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
    margin: 1rem;
}

/* ── Header band (compact) ── */
.org-header {
    background: linear-gradient(135deg, var(--blue-dk), var(--purple));
    padding: 0.45rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.org-header-text { flex: 1; min-width: 0; }
.org-header-text h1 {
    font-size: 1.05rem;
    font-weight: 900;
    color: white;
    line-height: 1.1;
}
.org-header-text .sub {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.75);
    font-weight: 600;
    margin-top: 0.1rem;
}

/* Inter-context link (→ appreciation for the same artwork) */
.context-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
    padding: 0.34rem 0.75rem;
    border-radius: 99px;
    background: rgba(255,255,255,0.18);
    border: 1.5px solid rgba(255,255,255,0.35);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}
.context-link:hover { background: rgba(255,255,255,0.32); border-color: #fff; }
/* ─── Big artwork stage (shared by levels) ───────────────────────── */
.stage {
    position: relative;
    width: 100%;
    background: #05080f;
    border-bottom: 2px solid #3f4f68;
}

/* Prev / next artwork arrows, in the dark bands beside the image */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 2.1rem;
    font-weight: 900;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.nav-arrow:hover { background: rgba(0,0,0,0.72); border-color: #fff; }
.nav-arrow:active { transform: translateY(-50%) scale(0.9); }
.nav-arrow.prev { left: 12px; }
.nav-arrow.next { right: 12px; }
.stage img {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: #05080f;
}

/* ── Instruction banner (picto + short text) ── */
.instruct {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1.1rem;
    background: #0f1520;
    border-bottom: 1px solid #3f4f68;
    font-weight: 900;
    font-size: 0.98rem;
    color: var(--text);
}
.instruct .ico { font-size: 1.3rem; flex-shrink: 0; }
.instruct .count {
    margin-left: auto;
    font-size: 0.9rem;
    font-weight: 900;
    color: var(--green);
    background: rgba(52,211,153,0.15);
    border: 1.5px solid var(--green);
    border-radius: 99px;
    padding: 0.15rem 0.7rem;
    white-space: nowrap;
}

/* ═══ N1 — Reconnaissance ════════════════════════════════════════ */
.n1-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.9rem;
    padding: 1.1rem 1.2rem 1.4rem;
}
.pcard {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 0.8rem 0.5rem;
    border-radius: 16px;
    border: 3px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.pcard:hover { transform: translateY(-3px); border-color: var(--purple); }
.pcard:active { transform: scale(0.96); }
.pcard img {
    width: 90px; height: 90px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 6px;
    pointer-events: none;
}
.pcard span { font-size: 0.9rem; font-weight: 900; color: var(--text); text-align: center; line-height: 1.1; }
.pcard .mark {
    position: absolute;
    top: -10px; right: -10px;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 900;
    opacity: 0; transform: scale(0.3);
    transition: opacity 0.2s, transform 0.2s;
}
.pcard.found { border-color: var(--green); background: rgba(52,211,153,0.16); cursor: default; }
.pcard.found .mark { background: var(--green); color: #06281c; opacity: 1; transform: scale(1); }
.pcard.wrong { animation: shake 0.45s; border-color: var(--pink); background: rgba(244,114,182,0.16); }
.pcard.wrong .mark { background: var(--pink); color: #fff; opacity: 1; transform: scale(1); }
@keyframes shake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}
.n1-done {
    margin: 0 1.2rem 1.4rem;
    padding: 1rem;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(52,211,153,0.2), rgba(96,165,250,0.18));
    border: 2px solid var(--green);
    text-align: center;
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--green);
    display: none;
}
.n1-done.show { display: block; animation: pop 0.4s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ═══ N3 — Évaluation ════════════════════════════════════════════ */
.eval-head, .eval-row {
    display: grid;
    grid-template-columns: 1fr 78px 78px 78px;
    align-items: center;
}
.eval-head { background: #0c1018; border-bottom: 2px solid #3f4f68; }
.eval-head .hcell {
    padding: 0.55rem 0.4rem;
    border-right: 1px solid #3f4f68;
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    font-size: 0.66rem; font-weight: 900;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--muted); text-align: center;
}
.eval-head .hcell:last-child { border-right: none; }
.eval-head .hcell.left { align-items: flex-start; color: var(--text); font-size: 0.78rem; justify-content: center; }
.eval-head .hcell img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }

.eval-row { border-bottom: 1px solid #3f4f68; min-height: 92px; }
.eval-row:nth-child(odd)  { background: #0e1320; }
.eval-row:nth-child(even) { background: #111827; }
.eval-subject {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.5rem 0.8rem;
    border-right: 1px solid #3f4f68;
    height: 100%;
}
.eval-subject img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 12px; padding: 5px; flex-shrink: 0; }
.eval-subject span { font-size: 1rem; font-weight: 900; color: var(--text); line-height: 1.15; }
.eval-cell { border-right: 1px solid #3f4f68; display: flex; align-items: center; justify-content: center; height: 100%; }
.eval-cell:last-child { border-right: none; }

/* Shared round check buttons (N3 + N5) */
.check-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 2.5px solid var(--border);
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
    color: var(--muted);
    -webkit-tap-highlight-color: transparent;
}
.check-btn:hover { transform: scale(1.12); }
.check-btn.selected-yes { background: rgba(52,211,153,0.2);  border-color: var(--green);  color: var(--green); }
.check-btn.selected-no  { background: rgba(244,114,182,0.2); border-color: var(--pink);   color: var(--pink); }
.check-btn.selected-idk { background: rgba(251,191,36,0.2);  border-color: var(--yellow); color: var(--yellow); }

/* ═══ N5 — Questionnement ouvert ═════════════════════════════════ */
.q5-row {
    display: grid;
    grid-template-columns: 96px 1fr 60px;
    border-bottom: 1px solid #3f4f68;
    min-height: 96px;
    align-items: center;
}
.q5-row:nth-child(odd)  { background: #0e1320; }
.q5-row:nth-child(even) { background: #111827; }
.q5-word {
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    padding: 0.6rem 0.3rem;
    border-right: 1px solid #3f4f68;
    height: 100%; justify-content: center;
}
.q5-word img { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.q5-word span { font-size: 0.78rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }
.q5-answer {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    border-right: 1px solid #3f4f68;
    height: 100%;
}
.ans-slot {
    flex-shrink: 0;
    width: 70px; height: 70px;
    background: var(--surface2);
    border: 3px dashed #4a5f7a;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #4a5f7a; font-weight: 300;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.ans-slot:hover { border-color: var(--purple); transform: scale(1.05); background: #263347; }
.ans-slot.filled { border-style: solid; border-color: var(--green); background: #0c1018; }
.ans-slot img { width: 100%; height: 100%; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.q5-answer .hint { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.q5-eval { display: flex; align-items: center; justify-content: center; height: 100%; }
.q5-eval .check-btn { width: 40px; height: 40px; font-size: 1.2rem; }

/* ─── Picto picker (bottom sheet, used by N5) ────────────────────── */
.picker-backdrop {
    position: fixed; inset: 0;
    background: rgba(11,15,25,0.8);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.picker-backdrop.open { display: flex; }
.picker-sheet {
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    width: 100%;
    max-width: 880px;
    max-height: 72vh;
    display: flex;
    flex-direction: column;
    animation: slide-up 0.28s cubic-bezier(.34,1.28,.64,1);
}
@keyframes slide-up {
    from { transform: translateY(100%); opacity: 0.4; }
    to   { transform: translateY(0);    opacity: 1; }
}
.picker-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.9rem 1.2rem 0.6rem;
    border-bottom: 1px solid var(--border);
}
.picker-title { font-size: 0.95rem; font-weight: 900; }
.picker-close {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.picker-close:hover { background: var(--border); }
.picker-body { overflow-y: auto; flex: 1; padding: 0.8rem 1rem 1rem; }
.picker-section-label {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted);
    margin: 0.8rem 0 0.4rem;
}
.picker-section-label:first-child { margin-top: 0; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 0.5rem; }
.picker-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
    padding: 0.45rem 0.25rem;
    border-radius: 10px;
    border: 2px solid transparent;
    background: #151c2c;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, transform 0.15s;
}
.picker-item:hover { border-color: var(--purple); transform: scale(1.06); }
.picker-item img { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 7px; padding: 3px; }
.picker-item span { font-size: 0.68rem; font-weight: 700; color: var(--text); line-height: 1.1; }

/* ─── Desktop: full-viewport app shell (flex, no page scrollbar) ──── */
@media (min-width: 769px) {
    html, body { height: 100vh; overflow: hidden; }
    .page {
        height: 100vh; min-height: 0;
        padding: 56px 0 0;
        justify-content: flex-start;
    }
    .organizer-card {
        flex: 1 1 auto; min-height: 0;
        margin: 0.7rem auto;
        display: flex; flex-direction: column;
    }
    /* the activity fills the remaining height; scrolls internally only if
       a level's content is genuinely taller than the viewport */
    #level-body {
        flex: 1 1 auto; min-height: 0;
        display: flex; flex-direction: column;
        overflow-y: auto;
    }
    #level-body .stage { flex: 0 0 auto; }
    #level-body .stage img { max-height: 40vh; }
    .n1-grid { align-content: start; }
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .bar-title { display: none; }
    .level-btn { padding: 0.3rem 0.42rem; font-size: 0.72rem; }
    .artwork-select { max-width: 130px; font-size: 0.75rem; }
    .print-btn span { display: none; }
    .print-btn { padding: 0.38rem 0.55rem; }
    .stage img { max-height: 320px; }
    .nav-arrow { width: 44px; height: 44px; font-size: 1.6rem; }
    .nav-arrow.prev { left: 6px; }
    .nav-arrow.next { right: 6px; }
    .n1-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.6rem; }
    .pcard img { width: 70px; height: 70px; }
    .eval-head, .eval-row { grid-template-columns: 1fr 58px 58px 58px; }
    .eval-subject img { width: 50px; height: 50px; }
    .check-btn { width: 40px; height: 40px; font-size: 1.2rem; }
    .q5-row { grid-template-columns: 78px 1fr 48px; }
}

/* ─── Print ──────────────────────────────────────────────────────── */
@media print {
    .top-bar, .picker-backdrop, .instruct .count, .nav-arrow { display: none !important; }
    html, body { background: white; color: black; }
    .page { padding-top: 0; }
    .organizer-card { border: 2px solid #334155; max-width: 100%; }
    .org-header { background: #2563eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .stage img { max-height: 320px; }
    .eval-row, .q5-row, .instruct, .eval-head { background: white; }
    .eval-subject span, .q5-word span, .pcard span { color: black; }
    .check-btn { border-color: #ccc; }
    .check-btn.selected-yes { background: #d1fae5; border-color: #059669; color: #059669; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .check-btn.selected-no  { background: #fce7f3; border-color: #db2777; color: #db2777; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .check-btn.selected-idk { background: #fef3c7; border-color: #d97706; color: #d97706; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
