@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ───────────── Variables ─────────────
   Les anciens noms sont conservés pour ne pas casser tes autres pages
   (huffman.html, portscan.html, tipe.html). */
:root {
    --bg-color: #0b0912;                      /* noir teinté violet */
    --text-main: #e8e4f4;
    --text-muted: #9189ad;
    --accent: #a56cff;                        /* violet électrique */
    --accent-bright: #c9adff;                 /* lavande lumineuse (curseur, tags) */
    --accent-glow: rgba(165, 108, 255, 0.16);
    --card-bg: rgba(20, 15, 36, 0.55);
    --card-border: rgba(165, 108, 255, 0.16);
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    color-scheme: dark;
}

/* Défilement fluide vers les ancres (#projets, #contact…) */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

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

::selection {
    background: var(--accent);
    color: #0b0912;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    line-height: 1.7;
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, .logo, .tag {
    font-family: var(--font-mono);
}

a:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ───────────── Fond : grille + halo ───────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(165, 108, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(165, 108, 255, 0.06) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 25%, #000 20%, transparent 75%);
            mask-image: radial-gradient(ellipse 70% 60% at 50% 25%, #000 20%, transparent 75%);
}

.bg-glow {
    position: fixed;
    top: 18%;
    left: 50%;
    width: 70vw;
    max-width: 900px;
    height: 70vw;
    max-height: 900px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 62%);
    transform: translate(-50%, -50%);
    z-index: -1;
    pointer-events: none;
}

/* ───────────── Navbar ───────────── */
body > nav {
    position: sticky;
    top: 0;
    width: 100%;
    background: rgba(11, 9, 18, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    z-index: 100;
}

.nav-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.logo .us {
    color: var(--accent);
    animation: blink 1.06s steps(1) infinite;
}

.links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 24px;
    font-size: 0.9rem;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.links a:hover,
.links a:focus-visible {
    color: var(--accent-bright);
    border-bottom-color: var(--accent);
}

/* ───────────── Layout ───────────── */
main {
    max-width: 750px;
    margin: 0 auto;
    padding: 56px 20px 100px;
    display: flex;
    flex-direction: column;
    gap: 64px;
}

/* ───────────── Hero : la fenêtre de terminal ───────────── */
.terminal {
    background: rgba(12, 9, 22, 0.82);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.6),
        0 0 70px var(--accent-glow);
}

.term-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--card-border);
    background: rgba(165, 108, 255, 0.05);
}

.term-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(165, 108, 255, 0.3);
}

.term-title {
    margin-left: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.term-body {
    padding: 28px 26px 32px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.line {
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.prompt {
    color: var(--accent);
    font-weight: 700;
}

.prompt .sep {
    color: var(--text-muted);
    font-weight: 400;
}

.cmd {
    color: #fff;
}

.hero h1 {
    font-size: clamp(2.2rem, 7vw, 3.4rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: #fff;
}

.hero .out {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Animation de frappe (activée par le JS, sinon le texte est simplement affiché) */
.pending {
    visibility: hidden;
}

.ch {
    opacity: 0;
}

.ch.on {
    opacity: 1;
}

.cursor {
    position: relative;
    display: inline-block;
    width: 0;
    height: 1em;
    vertical-align: text-bottom;
}

.cursor::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0.05em;
    width: 0.6em;
    height: 1.15em;
    background: var(--accent-bright);
    animation: blink 1.06s steps(1) infinite;
}

.cursor.busy::after {
    animation: none;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* ───────────── Projets ───────────── */
.projects-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-margin-top: 76px; /* évite que la navbar collante recouvre le titre à l'arrivée */
}

.projects-stack h2 {
    margin-bottom: 10px;
    font-size: 1.4rem;
    font-weight: 700;
}

.projects-stack h2::before {
    content: '# ';
    color: var(--accent);
}

.bubble {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 28px;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    position: relative;
    overflow: hidden;
}

.bubble:hover,
.bubble:focus-visible {
    transform: translateY(-3px);
    border-color: rgba(165, 108, 255, 0.55);
    background: rgba(28, 21, 50, 0.7);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.7), 0 0 26px var(--accent-glow);
}

/* Filet lumineux en haut de la carte */
.bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.bubble:hover::before,
.bubble:focus-visible::before {
    opacity: 1;
}

.bubble h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #fff;
}

/* Le "$" du prompt s'allume au survol */
.bubble h3::before {
    content: '$ ';
    color: var(--text-muted);
    transition: color 0.25s ease;
}

.bubble:hover h3::before,
.bubble:focus-visible h3::before {
    color: var(--accent);
}

.bubble p {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 20px;
}

/* Badges techno */
.tag {
    display: inline-block;
    background: rgba(165, 108, 255, 0.08);
    border: 1px solid rgba(165, 108, 255, 0.25);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-bright);
    margin-right: 8px;
    margin-bottom: 8px;
}

/* ───────────── Mobile ───────────── */
@media (max-width: 520px) {
    main { padding-top: 36px; gap: 48px; }
    .term-body { padding: 22px 18px 26px; }
    .bubble { padding: 22px 20px; }
    .links a { margin-left: 16px; }
}

/* ───────────── Accessibilité : moins de mouvement ───────────── */
@media (prefers-reduced-motion: reduce) {
    .cursor::after,
    .logo .us {
        animation: none;
    }
    .bubble,
    .bubble:hover,
    .bubble:focus-visible {
        transform: none;
        transition: none;
    }
}

/* ═════════════ Pages projet (huffman.html, etc.) ═════════════ */
a.logo {
    text-decoration: none;
}

a.logo:hover .us,
a.logo:focus-visible .us {
    color: var(--accent-bright);
}

main.project-page {
    gap: 52px;
}

/* En-tête de page */
.page-head {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-head .line {
    margin-bottom: 4px;
}

.page-head h1 {
    font-size: clamp(1.7rem, 5.5vw, 2.5rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #fff;
    text-wrap: balance;
}

.page-head .lead {
    color: var(--text-muted);
    font-size: 1rem;
}

.page-head .tags {
    margin-top: 4px;
}

/* Sections de contenu */
.doc-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.doc-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.doc-section h2::before {
    content: '# ';
    color: var(--accent);
}

.doc-section p,
.doc-section li {
    font-size: 0.95rem;
    color: #d3cde6;
}

.doc-section strong {
    color: #fff;
    font-weight: 700;
}

.steps {
    padding-left: 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.steps li {
    padding-left: 0.3rem;
}

.steps li::marker {
    color: var(--accent);
    font-weight: 700;
}

code.inline {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--accent-bright);
    background: rgba(165, 108, 255, 0.1);
    border: 1px solid rgba(165, 108, 255, 0.2);
    border-radius: 4px;
    padding: 1px 6px;
}

.caption {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Petits blocs (format de fichier, commandes) */
.snippet {
    background: rgba(12, 9, 22, 0.82);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 16px 18px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.75;
    color: #fff;
}

.snippet .sn-p { color: var(--accent); font-weight: 700; }
.snippet .sn-c { color: var(--text-muted); }

/* Fenêtre de code */
.code-window {
    background: rgba(12, 9, 22, 0.82);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 60px var(--accent-glow);
}

.code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 14px;
    border-bottom: 1px solid var(--card-border);
    background: rgba(165, 108, 255, 0.05);
}

.code-file {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.copy-btn {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-bright);
    background: transparent;
    border: 1px solid rgba(165, 108, 255, 0.3);
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.copy-btn:hover {
    background: rgba(165, 108, 255, 0.12);
    border-color: var(--accent);
}

.copy-btn:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
}

.code-window pre {
    padding: 16px 0;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.65;
    tab-size: 4;
}

.code-window code {
    display: block;
    min-width: max-content;
    font-family: var(--font-mono);
    color: #e8e4f4;
    counter-reset: ln;
}

.ln {
    display: block;
    padding-right: 18px;
    white-space: pre;
    counter-increment: ln;
}

.ln::before {
    content: counter(ln);
    display: inline-block;
    width: 2.6ch;
    margin: 0 1.8ch 0 14px;
    text-align: right;
    color: rgba(145, 137, 173, 0.45);
    user-select: none;
}

/* Coloration syntaxique */
.tk-kw   { color: #c193ff; }
.tk-str  { color: #f5a9d0; }
.tk-num  { color: #f6c890; }
.tk-fn   { color: #86d4ff; }
.tk-self { color: #e2d6ff; font-style: italic; }
.tk-com  { color: #7a7396; font-style: italic; }

@media (max-width: 520px) {
    main.project-page { gap: 40px; }
    .code-window pre { font-size: 0.75rem; }
}

/* ═════════════ Séries de versions (scanneur de port) ═════════════ */
.tk-type { color: #9fb4ff; }

/* Sélecteur de versions, sous l'en-tête */
.versions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.versions-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 4px;
}

.versions a {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    padding: 4px 12px;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.versions a:hover,
.versions a:focus-visible {
    color: var(--accent-bright);
    border-color: var(--accent);
}

.versions a[aria-current="page"] {
    color: #fff;
    background: rgba(165, 108, 255, 0.16);
    border-color: var(--accent);
}

/* Version précédente / suivante, en bas de page */
.pager {
    display: flex;
    gap: 16px;
}

.pager a {
    flex: 1 1 0;
    max-width: calc(50% - 8px);
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-decoration: none;
    color: #fff;
    font-size: 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 14px 18px;
    transition: border-color 0.25s ease, background 0.25s ease;
}

.pager a.next {
    text-align: right;
    margin-left: auto;
}

.pager a:hover,
.pager a:focus-visible {
    border-color: rgba(165, 108, 255, 0.55);
    background: rgba(28, 21, 50, 0.7);
}

.pager-dir {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 520px) {
    .pager { flex-direction: column; }
    .pager a { max-width: none; }
    .pager a.next { text-align: left; }
}

/* Liens dans le texte */
.text-link {
    color: var(--accent-bright);
    text-decoration: underline;
    text-decoration-color: rgba(201, 173, 255, 0.35);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s ease;
}

.text-link:hover,
.text-link:focus-visible {
    text-decoration-color: var(--accent-bright);
}

.text-link:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
}

/* ═════════════ Carte dépliable (projet à plusieurs versions) ═════════════ */
.bubble-group {
    cursor: default;
}

/* Pas de "soulèvement" : le contenu de la carte doit rester stable sous la souris */
.bubble-group:hover {
    transform: none;
}

.bubble-group[open] {
    border-color: rgba(165, 108, 255, 0.45);
    background: rgba(28, 21, 50, 0.7);
}

.bubble-group[open]::before {
    opacity: 1;
}

.bubble-group summary {
    display: block;
    list-style: none;
    cursor: pointer;
    border-radius: 4px;
}

.bubble-group summary::-webkit-details-marker {
    display: none;
}

.bubble-group summary:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 6px;
}

.bubble-group summary:hover h3::before {
    color: var(--accent);
}

.group-desc {
    display: block;
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 20px;
}

.group-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 4px 16px;
}

.group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--accent-bright);
    white-space: nowrap;
}

.group-toggle::after {
    content: '';
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.25s ease;
}

.bubble-group[open] .group-toggle::after {
    transform: translateY(2px) rotate(-135deg);
}

.toggle-open { display: none; }
.bubble-group[open] .toggle-open { display: inline; }
.bubble-group[open] .toggle-closed { display: none; }

/* Liste des versions */
.versions-list {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: reveal 0.28s ease;
}

@keyframes reveal {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.version-item {
    display: grid;
    grid-template-columns: 9.5rem 1fr;
    gap: 4px 16px;
    align-items: baseline;
    padding: 12px 14px;
    border-radius: 4px;
    border-left: 2px solid transparent;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.version-item:hover,
.version-item:focus-visible {
    background: rgba(165, 108, 255, 0.09);
    border-left-color: var(--accent);
}

.version-item:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 1px;
}

.version-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}

.version-item:hover .version-name,
.version-item:focus-visible .version-name {
    color: var(--accent-bright);
}

.version-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 520px) {
    .version-item { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .versions-list { animation: none; }
    .group-toggle::after { transition: none; }
}

/* ═════════════ Contact (bas de l'accueil) ═════════════ */
.contact {
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-margin-top: 76px; /* évite que la navbar collante recouvre le titre à l'arrivée */
}

.contact h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.contact h2::before {
    content: '# ';
    color: var(--accent);
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 6px;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.contact-item .prompt {
    color: var(--accent);
}

.contact-item:hover,
.contact-item:focus-visible {
    background: var(--card-bg);
    border-color: var(--card-border);
    color: #fff;
}

.contact-item:hover .prompt,
.contact-item:focus-visible .prompt {
    color: var(--accent-bright);
}

.contact-item:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
}
