/* Portfolio jouable — interface (le monde est dessiné dans jeu.js) */

:root {
    --bg: #0b1020;
    --panel: #111a33;
    --panel-2: #0c1429;
    --line: #26375e;
    --text: #e8eefb;
    --muted: #a3b3d1;
    --primary: #38bdf8;
    --green: #4ade80;
    --gold: #fbbf24;
    --accent: var(--primary);
    --px: 'Pixelify Sans', ui-monospace, monospace;
    --body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--primary); }

#world {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    touch-action: none;
    outline: none;
}

/* ---------- Boutons ---------- */
.px-btn {
    font-family: var(--px);
    font-size: 15px;
    line-height: 1;
    color: var(--text);
    background: #16213f;
    border: 2px solid var(--text);
    border-radius: 3px;
    padding: 7px 11px;
    cursor: pointer;
    box-shadow: 0 3px 0 #02050d;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.px-btn:hover { background: #1f2d55; }
.px-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #02050d; }
.px-btn:focus-visible, .swatch:focus-visible, summary:focus-visible, .prompt:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}
.px-btn:disabled { opacity: .6; cursor: wait; }
.px-btn.primary { background: var(--primary); color: #04101d; border-color: #e6f6ff; box-shadow: 0 3px 0 #075985; }
.px-btn.primary:hover { background: #7dd3fc; }
.px-btn.big { font-size: 22px; padding: 12px 24px; }
.px-btn.small { font-size: 13px; padding: 5px 9px; }

kbd {
    font-family: var(--px);
    font-size: .8em;
    background: #0b1020;
    border: 1px solid #50618a;
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--muted);
}
.px-btn.primary kbd { color: #04101d; background: rgba(255,255,255,.4); border-color: #075985; }

/* ---------- HUD ---------- */
.hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    pointer-events: none;
}
.hud > div { display: flex; flex-wrap: wrap; gap: 6px; pointer-events: auto; }
.hud-actions { justify-content: flex-end; }
.hud-chip {
    font-family: var(--px);
    font-size: 15px;
    line-height: 1;
    background: rgba(11, 16, 32, .88);
    border: 2px solid #33456f;
    border-radius: 3px;
    padding: 7px 10px;
    white-space: nowrap;
}
.hud-chip.done { border-color: var(--gold); color: var(--gold); }

/* ---------- Invite d'interaction ---------- */
.prompt {
    position: fixed;
    left: 50%;
    bottom: calc(26px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 11;
    font-family: var(--px);
    font-size: 17px;
    color: var(--text);
    background: rgba(11, 16, 32, .92);
    border: 2px solid var(--text);
    border-radius: 4px;
    padding: 9px 14px;
    box-shadow: 0 4px 0 #02050d;
    cursor: pointer;
    white-space: nowrap;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
}
.prompt kbd { color: #04101d; background: var(--primary); border-color: #e6f6ff; margin-right: 6px; }

/* ---------- Boîte de dialogue ---------- */
.dialog {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(760px, calc(100% - 24px));
    z-index: 20;
    background: #0d1530;
    border: 3px solid var(--text);
    border-radius: 6px;
    box-shadow: 0 0 0 3px #050914, 0 12px 30px rgba(0,0,0,.5);
    padding: 24px 22px 18px;
    cursor: pointer;
}
.dialog-name {
    position: absolute;
    top: -16px;
    left: 16px;
    font-family: var(--px);
    font-size: 15px;
    background: var(--primary);
    color: #04101d;
    padding: 4px 10px;
    border: 2px solid var(--text);
    border-radius: 3px;
}
.dialog-text {
    margin: 0;
    font-family: var(--px);
    font-size: 19px;
    line-height: 1.45;
    min-height: 2.9em;
}
.dialog-next {
    position: absolute;
    right: 14px;
    bottom: 8px;
    color: var(--primary);
    animation: bob .8s steps(2) infinite;
}
.dialog-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.dialog-choices:empty { display: none; }

/* ---------- Fenêtres (bâtiments, carte) ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(3, 6, 15, .72);
}
.panel {
    width: min(920px, 100%);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 3px solid var(--text);
    border-radius: 6px;
    box-shadow: 0 0 0 3px #050914, 0 20px 60px rgba(0,0,0,.6);
    animation: pop .18s ease-out;
}
.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--panel-2);
    border-bottom: 3px solid var(--accent);
    border-radius: 3px 3px 0 0;
}
.panel-icon { font-size: 32px; line-height: 1; }
.panel-kicker {
    margin: 0 0 2px;
    font-family: var(--px);
    font-size: 14px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--accent);
}
.panel-head h2 { margin: 0; font-family: var(--px); font-weight: 600; font-size: 27px; line-height: 1.1; }
.panel-head .px-btn { margin-left: auto; }
.panel-body {
    overflow: auto;
    padding: 20px 22px 26px;
    font-size: 16px;
    line-height: 1.6;
    overscroll-behavior: contain;
}
.panel-body > :first-child { margin-top: 0; }
.panel-body h3 {
    font-family: var(--px);
    font-weight: 600;
    font-size: 21px;
    margin: 26px 0 10px;
    color: var(--accent);
}
.panel-body h4 { margin: 0 0 6px; font-size: 18px; line-height: 1.3; }
.panel-body p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.lead { font-size: 18px; }
.callout {
    background: rgba(56, 189, 248, .1);
    border-left: 4px solid var(--accent);
    padding: 10px 14px;
    border-radius: 0 4px 4px 0;
}

.sheet {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
    margin: 0 0 18px;
}
.stat {
    background: var(--panel-2);
    border: 2px solid var(--line);
    border-radius: 4px;
    padding: 9px 12px;
}
.stat dt { font-family: var(--px); font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat dd { margin: 2px 0 0; font-weight: 700; line-height: 1.35; }

.quest-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.quest-log li {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    background: var(--panel-2);
    border: 2px solid var(--line);
    border-radius: 4px;
    padding: 9px 12px;
}
.quest-log span { color: var(--muted); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
    background: var(--panel-2);
    border: 2px solid var(--line);
    border-radius: 6px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card p { margin: 0; }
.card > .px-btn { align-self: flex-start; }

.module header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.module h4 { margin: 0; flex: 1; }
.module.found { border-color: var(--green); }
.led { width: 8px; height: 8px; background: #475569; box-shadow: 0 0 0 2px #0b1020; }
.module.found .led { background: var(--green); box-shadow: 0 0 8px var(--green); }

.pill {
    font-family: var(--px);
    font-size: 12px;
    padding: 3px 7px;
    border-radius: 3px;
    border: 1px solid #50618a;
    color: var(--muted);
    white-space: nowrap;
}
.pill.ok { color: #052e16; background: var(--green); border-color: var(--green); }

.tags, .tech, .chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tag {
    font-family: var(--px);
    font-size: 13px;
    color: var(--accent);
    border: 1px solid currentColor;
    border-radius: 3px;
    padding: 2px 7px;
}
.badge, .chips li {
    font-size: 13px;
    background: #1b2748;
    border-radius: 3px;
    padding: 3px 8px;
}
.points { margin: 0; padding-left: 20px; }
.points li { margin: 3px 0; }

details { border-top: 1px dashed var(--line); padding-top: 8px; }
summary {
    cursor: pointer;
    font-family: var(--px);
    font-size: 15px;
    color: var(--accent);
    list-style-position: inside;
}
details h5 { margin: 10px 0 2px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
details p { margin: 0; }

.veille-card h4 a { color: var(--text); text-decoration: none; }
.veille-card h4 a:hover { color: var(--accent); text-decoration: underline; }

/* Tableau des départs (expériences) */
.board { border: 3px solid #1f2937; border-radius: 6px; background: #05070d; overflow: hidden; }
.board-head, .board-row summary {
    display: grid;
    grid-template-columns: 70px 1fr minmax(120px, 30%);
    gap: 12px;
    padding: 10px 14px;
    align-items: baseline;
}
.board-head {
    font-family: var(--px);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #9ca3af;
    background: #111827;
}
.board-row { border-top: 1px solid #1f2937; padding: 0; }
.board-row summary { list-style: none; color: #fcd34d; font-family: var(--px); font-size: 17px; }
.board-row summary::-webkit-details-marker { display: none; }
.board-row summary:hover { background: #0f1422; }
.board-row[open] summary { background: #111827; }
.b-date { color: #fbbf24; }
.b-place { color: #fde68a; opacity: .8; font-size: 15px; }
.board-body { padding: 10px 16px 16px; color: var(--text); font-size: 15px; background: #0b1020; }
.env { margin-top: 10px !important; color: var(--muted); }

/* Contact */
.contact-list { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.contact-list li { background: var(--panel-2); border: 2px solid var(--line); border-radius: 4px; padding: 10px 12px; }
.c-label { display: block; font-family: var(--px); font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 700; font-size: 14px; }
.form input, .form textarea {
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: #0b1020;
    border: 2px solid var(--line);
    border-radius: 4px;
    padding: 10px 12px;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.form .px-btn { justify-self: start; }

/* Badges Credly */
.credly-grid { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 12px 0; }
.credly-card { background: #fff; border-radius: 6px; padding: 8px; min-width: 166px; min-height: 286px; }

/* Carte */
.map-layout { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 20px; align-items: start; }
.minimap { width: 100%; height: auto; image-rendering: pixelated; border: 3px solid var(--line); border-radius: 4px; background: #16301f; }
.map-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.map-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    background: var(--panel-2);
    border: 2px solid var(--line);
    border-radius: 4px;
    padding: 8px 10px;
}
.map-item.visited { border-color: #2f5f45; }
.map-ico { font-size: 22px; }
.map-name { display: block; font-weight: 700; line-height: 1.2; }
.map-sub { display: block; font-size: 13px; color: var(--muted); }
.map-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.progress { height: 12px; background: #0b1020; border: 2px solid var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 14px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); }

/* ---------- Écran titre ---------- */
.title {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 16px;
    overflow: auto;
    background: radial-gradient(ellipse at center, rgba(11,16,32,.35), rgba(5,8,18,.85));
}
.title-box {
    width: min(540px, 100%);
    text-align: center;
    background: rgba(13, 21, 48, .94);
    border: 3px solid var(--text);
    border-radius: 6px;
    box-shadow: 0 0 0 3px #050914, 0 20px 60px rgba(0,0,0,.6);
    padding: 26px 22px 22px;
}
.title-kicker { margin: 0; font-family: var(--px); font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--green); }
.title h1 {
    margin: 6px 0 8px;
    font-family: var(--px);
    font-weight: 700;
    font-size: clamp(40px, 10vw, 64px);
    line-height: 1;
    color: #fff;
    text-shadow: 4px 4px 0 #0369a1;
}
.title-sub { margin: 0 0 18px; color: var(--muted); }
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0 auto 20px;
    padding: 12px;
    background: var(--panel-2);
    border: 2px solid var(--line);
    border-radius: 6px;
    width: fit-content;
    max-width: 100%;
}
#avatarPreview { width: 64px; height: 64px; image-rendering: pixelated; background: #5b9e4c; border: 2px solid var(--line); border-radius: 4px; }
.avatar-rows { display: grid; gap: 8px; text-align: left; }
.avatar-label { margin: 0; font-family: var(--px); font-size: 14px; color: var(--muted); }
.avatar-row { display: flex; gap: 8px; }
.swatch {
    width: 30px;
    height: 30px;
    border: 2px solid var(--text);
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
}
.swatch[aria-pressed="true"] { outline: 3px solid var(--gold); outline-offset: 2px; }
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.title-help { margin: 16px 0 4px; font-size: 14px; color: var(--muted); }
.title-status { margin: 4px 0; font-size: 14px; color: #fca5a5; min-height: 1em; }
.title-status:empty { display: none; }
.title-alt { display: inline-block; margin-top: 8px; font-size: 14px; }

/* ---------- Notifications ---------- */
.toasts {
    position: fixed;
    top: 66px;
    right: 12px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(360px, calc(100vw - 24px));
    background: #0d1530;
    border: 2px solid var(--green);
    border-radius: 4px;
    padding: 9px 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,.45);
    animation: slidein .25s ease-out;
    transition: opacity .4s, transform .4s;
}
.toast.out { opacity: 0; transform: translateX(20px); }
.toast-ico { font-size: 22px; }
.toast strong { display: block; font-family: var(--px); font-weight: 600; }
.toast span { display: block; font-size: 13px; color: var(--muted); }

/* ---------- Commandes tactiles ---------- */
.stick {
    position: fixed;
    left: 22px;
    bottom: calc(26px + env(safe-area-inset-bottom));
    z-index: 12;
    width: 124px;
    height: 124px;
    border-radius: 50%;
    background: rgba(11, 16, 32, .45);
    border: 3px solid rgba(232, 238, 251, .6);
    touch-action: none;
}
.stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    background: rgba(232, 238, 251, .85);
}
.touch-a {
    position: fixed;
    right: 26px;
    bottom: calc(48px + env(safe-area-inset-bottom));
    z-index: 12;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    font-family: var(--px);
    font-size: 30px;
    color: #04101d;
    background: var(--primary);
    border: 3px solid var(--text);
    box-shadow: 0 4px 0 #075985;
    touch-action: manipulation;
}
body.is-touch .dialog,
body.is-touch .prompt { bottom: calc(172px + env(safe-area-inset-bottom)); }
body.is-touch .hide-touch { display: none; }

.noscript { position: fixed; inset: auto 0 0 0; margin: 0; padding: 16px; background: #fff; color: #000; text-align: center; }

@media (max-width: 640px) {
    .hide-sm { display: none; }
    .hud { padding: 8px; }
    .hud-chip, .px-btn { font-size: 13px; }
    .panel-head h2 { font-size: 21px; }
    .panel-body { padding: 16px; }
    .dialog-text { font-size: 17px; }
    .map-layout { grid-template-columns: 1fr; }
    .map-item { grid-template-columns: auto 1fr; }
    .map-btns { grid-column: 1 / -1; justify-content: flex-start; }
    .board-head, .board-row summary { grid-template-columns: 52px 1fr; }
    .b-place { grid-column: 2; }
    .board-head span:last-child { display: none; }
    .toasts { top: 56px; }
}

@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 50% { transform: translateY(3px); } }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
