/* ==========================================================================
   NEXUS — thème cyberpunk lisible
   Base violet-nuit, deux néons (cyan = action, magenta = alerte/accent), ambre = focus.
   Titres : Chakra Petch. Texte : Figtree (forte lisibilité, 17px).
   ========================================================================== */
:root {
    --bg: #0d0b1a;
    --bg-2: #15122b;
    --bg-3: #1e1a3d;
    --input: #0a0817;
    --line: #342d66;
    --text: #ece9ff;
    --muted: #a8a3d4;
    --cyan: #19f3ff;
    --cyan-dim: #0fa9b3;
    --magenta: #ff2e88;
    --amber: #ffc93c;
    --font-title: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background:
        radial-gradient(900px 500px at 8% -10%, rgba(255, 46, 136, .16), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(25, 243, 255, .12), transparent 60%),
        linear-gradient(rgba(52, 45, 102, .22) 1px, transparent 1px) 0 0 / 100% 44px,
        linear-gradient(90deg, rgba(52, 45, 102, .22) 1px, transparent 1px) 0 0 / 44px 100%,
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 17px/1.65 var(--font-body);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; padding-top: 28px; padding-bottom: 56px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }

h1, h2, h3 { font-family: var(--font-title); line-height: 1.2; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 700; }
h2 { font-size: 1.45rem; font-weight: 600; margin-top: 2rem; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--cyan); text-decoration-color: rgba(25, 243, 255, .45); text-underline-offset: 3px; }
a:hover { color: #7ffaff; text-decoration-color: currentColor; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: #111; padding: 8px 14px; z-index: 100; font-weight: 700; }
.skip:focus { left: 8px; }

/* ---------- Barre du haut ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(13, 11, 26, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(25, 243, 255, .25), 0 8px 24px -12px rgba(25, 243, 255, .25);
}
.topbar-in { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--font-title); font-weight: 700; font-size: 1.35rem; letter-spacing: .12em;
    color: var(--cyan); text-decoration: none;
    text-shadow: 1.5px 0 rgba(255, 46, 136, .7);
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
    font-family: var(--font-title); font-weight: 500; font-size: 1rem;
    color: var(--text); text-decoration: none; padding: 8px 14px; border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--cyan); }
.nav a[aria-current="page"] { color: var(--cyan); border-bottom-color: var(--magenta); }
.who { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.who-name { color: var(--muted); font-size: .95rem; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: 600 1rem/1 var(--font-title); letter-spacing: .02em;
    padding: 13px 22px; min-height: 44px;
    background: var(--cyan); color: #04141a; border: 1px solid var(--cyan);
    border-radius: 2px; text-decoration: none; cursor: pointer;
    box-shadow: 0 0 18px -4px rgba(25, 243, 255, .65);
    transition: background .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: #7ffaff; color: #04141a; box-shadow: 0 0 26px -2px rgba(25, 243, 255, .85); }
.btn-ghost { background: transparent; color: var(--cyan); box-shadow: none; }
.btn-ghost:hover { background: rgba(25, 243, 255, .1); color: #7ffaff; box-shadow: none; }
.btn-danger { background: transparent; color: #ff7db4; border-color: var(--magenta); box-shadow: none; }
.btn-danger:hover { background: rgba(255, 46, 136, .16); color: #ffb1d2; box-shadow: none; }
.btn-sm { padding: 9px 14px; min-height: 38px; font-size: .92rem; }

/* ---------- Cadre "HUD" (coins) ---------- */
.panel, .login-card, .chat, .d20 { position: relative; }
.panel, .login-card {
    background: linear-gradient(180deg, var(--bg-2), rgba(21, 18, 43, .82));
    border: 1px solid var(--line);
    padding: 24px;
    margin-bottom: 18px;
}
.panel::before, .panel::after, .login-card::before, .login-card::after {
    content: ''; position: absolute; width: 16px; height: 16px; pointer-events: none;
}
.panel::before, .login-card::before { top: -1px; left: -1px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.panel::after, .login-card::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--magenta); border-right: 2px solid var(--magenta); }

/* ---------- Accueil ---------- */
.hero {
    display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: center;
    padding: 20px 0 36px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.hero h1 { text-shadow: 0 0 28px rgba(25, 243, 255, .35); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 18px; }
.hero-stats { color: var(--muted); font-size: .95rem; margin: 0; }

/* d20 : l'élément mémorable de la page */
.d20 { text-align: center; width: 200px; }
.d20-btn {
    position: relative; width: 170px; height: 170px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--cyan);
    filter: drop-shadow(0 0 14px rgba(25, 243, 255, .55));
    transition: filter .2s, color .2s;
}
.d20-btn:hover { filter: drop-shadow(0 0 22px rgba(25, 243, 255, .85)); }
.d20-btn svg { width: 100%; height: 100%; }
.d20-shape { fill: rgba(25, 243, 255, .08); stroke: currentColor; stroke-width: 2.5; stroke-linejoin: round; }
.d20-lines { fill: none; stroke: currentColor; stroke-width: 1.2; opacity: .5; }
.d20-value {
    position: absolute; inset: 0; display: grid; place-items: center;
    font: 700 2.4rem/1 var(--font-title); color: var(--text); padding-top: 6px;
}
.d20-btn.is-rolling svg { animation: roll .9s cubic-bezier(.2, .7, .3, 1); }
.d20-btn.is-crit { color: var(--cyan); filter: drop-shadow(0 0 30px rgba(25, 243, 255, 1)); }
.d20-btn.is-fumble { color: var(--magenta); filter: drop-shadow(0 0 30px rgba(255, 46, 136, 1)); }
.d20-btn.is-fumble .d20-shape { fill: rgba(255, 46, 136, .12); }
.d20-label { margin: 10px 0 0; color: var(--muted); font-size: .95rem; min-height: 3em; }
@keyframes roll { from { transform: rotate(-300deg) scale(.7); } to { transform: rotate(0) scale(1); } }

.sections h2, .latest h2 { margin-top: 28px; }
.panel .panel-head h3 a { color: var(--text); text-decoration: none; }
.panel .panel-head h3 a:hover { color: var(--cyan); }
.sections .panel { display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: start; }
.sections .panel-head p { margin: 0; font-size: .97rem; }
.sublist, .subgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.sublist a, .subgrid a {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 11px 14px; min-height: 46px;
    background: rgba(10, 8, 23, .55); border: 1px solid var(--line); border-left: 3px solid var(--cyan-dim);
    color: var(--text); text-decoration: none;
}
.sublist a:hover, .subgrid a:hover { border-color: var(--cyan); border-left-color: var(--magenta); background: rgba(25, 243, 255, .07); }
.subgrid { margin-bottom: 12px; }
.subgrid a { flex-direction: column; align-items: flex-start; gap: 2px; }
.count {
    display: inline-block; min-width: 28px; padding: 2px 8px; text-align: center;
    font: 600 .85rem/1.5 var(--font-title); color: var(--cyan);
    background: var(--bg-3); border: 1px solid var(--line); border-radius: 2px;
}

/* ---------- Listes de sujets ---------- */
.threadlist, .filelist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.threadlist li {
    display: grid; grid-template-columns: 1fr auto; column-gap: 16px; align-items: center;
    padding: 14px 6px; border-bottom: 1px solid var(--line);
}
.threadlist li:hover { background: rgba(25, 243, 255, .04); }
.t-title { font-family: var(--font-title); font-weight: 600; font-size: 1.12rem; color: var(--text); text-decoration: none; }
.t-title:hover { color: var(--cyan); }
.t-meta { grid-column: 1; color: var(--muted); font-size: .92rem; }
.threadlist .count { grid-column: 2; grid-row: 1 / span 2; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .92rem; margin-bottom: 14px; color: var(--muted); }
.crumbs .sep { color: var(--line); }
.empty { padding: 26px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }

/* ---------- Messages d'un sujet ---------- */
.posts { display: grid; gap: 14px; margin-bottom: 26px; }
.post { display: grid; grid-template-columns: 190px 1fr; background: var(--bg-2); border: 1px solid var(--line); }
.post-author { padding: 18px; border-right: 1px solid var(--line); background: rgba(10, 8, 23, .5); display: flex; flex-direction: column; gap: 2px; }
.post-author strong { font-family: var(--font-title); color: var(--magenta); font-size: 1.05rem; }
.post-author .muted { font-size: .88rem; }
.post-body { padding: 18px 22px; min-width: 0; }
.prose { overflow-wrap: anywhere; max-width: 75ch; }

.attach { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attach li { display: flex; flex-direction: column; gap: 6px; }
.file-link {
    display: flex; flex-direction: column; padding: 9px 14px; min-width: 200px; max-width: 320px;
    background: var(--bg-3); border: 1px solid var(--line); border-left: 3px solid var(--cyan); color: var(--text); text-decoration: none;
}
.file-link:hover { border-color: var(--cyan); }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: .85rem; }
.thumb img { display: block; max-width: 320px; max-height: 220px; border: 1px solid var(--line); background: var(--input); }

/* ---------- Formulaires ---------- */
.form { max-width: 760px; }
.form.reply { margin-top: 12px; padding-top: 6px; }
label { display: block; font-weight: 600; margin: 18px 0 6px; }
input[type=text], input[type=password], input[type=search], textarea, select {
    width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
    background: var(--input); border: 1px solid var(--line); border-radius: 2px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #746fa3; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan); box-shadow: 0 0 16px -4px rgba(25, 243, 255, .6); }
select option, select optgroup { background: var(--bg-2); color: var(--text); }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { flex: 0 1 240px; width: auto; }

.dropzone {
    position: relative; padding: 26px 18px; text-align: center;
    border: 2px dashed var(--cyan-dim); background: rgba(25, 243, 255, .04);
}
.dropzone.is-over { border-color: var(--cyan); background: rgba(25, 243, 255, .12); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone p { margin: 0; }
.dropzone .picked { color: var(--text); font-weight: 600; }

.flash { padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--cyan); background: rgba(25, 243, 255, .09); }
.flash-err { border-color: var(--magenta); background: rgba(255, 46, 136, .12); }

/* ---------- Fichiers ---------- */
.filelist li { display: flex; gap: 16px; align-items: center; padding: 14px 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filelist .thumb img { width: 84px; height: 62px; object-fit: cover; }
.fl-main { flex: 1 1 320px; display: flex; flex-direction: column; min-width: 0; }
.fl-name { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.fl-desc { color: var(--text); }
.fl-meta { color: var(--muted); font-size: .9rem; }
.fl-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Connexion ---------- */
.login { min-height: 60vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 420px; padding: 32px; }
.login-card h1 { font-size: 2rem; letter-spacing: .14em; color: var(--cyan); text-shadow: 1.5px 0 rgba(255, 46, 136, .7); }
.login-card .btn { width: 100%; margin-top: 24px; }

/* ---------- Chat ---------- */
.chat { border: 1px solid var(--line); background: var(--bg-2); }
.chat-channels { display: flex; gap: 2px; border-bottom: 1px solid var(--line); background: rgba(10, 8, 23, .6); overflow-x: auto; }
.chat-channels a { padding: 12px 18px; font-family: var(--font-title); font-weight: 500; color: var(--text); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.chat-channels a:hover { color: var(--cyan); }
.chat-channels a[aria-current="page"] { color: var(--cyan); border-bottom-color: var(--magenta); background: rgba(25, 243, 255, .06); }
.chat-log { height: min(58vh, 560px); overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-log > :first-child { margin-top: auto; }
.msg { max-width: 78ch; padding: 8px 14px; border-left: 3px solid var(--magenta); background: rgba(10, 8, 23, .55); overflow-wrap: anywhere; }
.msg.me { border-left-color: var(--cyan); align-self: flex-end; background: rgba(25, 243, 255, .07); }
.msg-head { display: flex; gap: 10px; align-items: baseline; font-size: .88rem; color: var(--muted); }
.msg-head strong { font-family: var(--font-title); color: var(--magenta); font-size: .98rem; }
.msg.me .msg-head strong { color: var(--cyan); }
.msg-text { margin: 2px 0 0; }
.chat-form { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: rgba(10, 8, 23, .6); }
.chat-form input { flex: 1; }

.foot { padding-top: 22px; padding-bottom: 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; }
    .d20 { width: auto; text-align: left; display: flex; align-items: center; gap: 16px; }
    .d20-btn { width: 120px; height: 120px; flex: none; }
    .d20-value { font-size: 1.8rem; }
    .sections .panel { grid-template-columns: 1fr; gap: 16px; }
    .post { grid-template-columns: 1fr; }
    .post-author { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; gap: 12px; align-items: baseline; flex-wrap: wrap; }
    .topbar-in { gap: 6px 16px; padding-top: 8px; padding-bottom: 4px; }
    .who { order: 2; margin-left: auto; }
    .nav { order: 3; flex: 1 0 100%; overflow-x: auto; flex-wrap: nowrap; margin: 0 -8px; }
    .nav a { padding: 8px 12px; white-space: nowrap; }
}
@media (max-width: 520px) {
    body { font-size: 16px; }
    .wrap { padding-left: 14px; padding-right: 14px; }
    .panel, .login-card { padding: 18px; }
    .chat-form { flex-direction: column; }
    .sublist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sublist a { padding: 10px 10px; font-size: .95rem; }
    .who-name { display: none; }
}

/* ---------- Accessibilité : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
