/* XDK — feuille de style principale. Couleurs : #013861 + #ffffff. */
:root {
    --primary: #013861;
    --primary-dark: #012a49;
    --primary-soft: #e6eef4;
    --accent: #2f9bd6;
    --white: #ffffff;
    --bg: #f5f7fa;
    --text: #17242f;
    --muted: #5b6b79;
    --border: #d9e1e8;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --success: #0f6b3c;
    --success-soft: #e6f4ec;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 2px rgba(1, 56, 97, .06), 0 6px 20px rgba(1, 56, 97, .07);
    --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}
main { flex: 1; }
h1, h2, h3 { line-height: 1.2; color: var(--primary); margin: 0 0 .6em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--primary); }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 520px; }
.container-medium { max-width: 760px; }
.muted { color: var(--muted); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--white); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

/* En-tête */
.site-header { background: var(--primary); color: var(--white); position: sticky; top: 0; z-index: 50; }
.is-home .site-header { position: fixed; left: 0; right: 0; background: rgba(1, 56, 97, .72); backdrop-filter: blur(8px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; font-weight: 700; letter-spacing: .04em; }
.brand:hover { color: var(--white); }
.brand-mark {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    background: var(--white); color: var(--primary); border-radius: var(--radius); font-weight: 800;
}
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a:not(.btn) { color: var(--white); text-decoration: none; opacity: .9; }
.site-nav a:not(.btn):hover { opacity: 1; text-decoration: underline; }
.nav-form { margin: 0; }
.nav-toggle { display: none; background: none; border: 0; color: var(--white); font-size: 1.3rem; padding: 8px; cursor: pointer; }

/* Boutons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-light { background: var(--white); color: var(--primary); }
.btn-light:hover { background: var(--primary-soft); color: var(--primary); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--white); }
.btn-outline-light { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, .8); }
.btn-outline-light:hover { background: var(--white); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, .5); }
.btn-ghost:hover { background: rgba(255, 255, 255, .15); }
.btn-danger { background: var(--white); color: var(--danger); border-color: #f0b8b3; }
.btn-danger:hover { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Hero pleine page */
.hero {
    position: relative; min-height: 100vh; min-height: 100svh;
    display: flex; align-items: center; color: var(--white);
    background-color: var(--primary);
    /* hero.jpg (photo Unsplash téléchargée) recouvre hero.svg s'il est présent. */
    background-image:
        linear-gradient(120deg, rgba(1, 56, 97, .92) 0%, rgba(1, 56, 97, .70) 55%, rgba(1, 56, 97, .45) 100%),
        url("../img/hero.jpg"),
        url("../img/hero.svg");
    background-size: cover; background-position: center;
}
.hero-inner { padding-top: calc(var(--header-h) + 40px); padding-bottom: 80px; }
.hero h1 { color: var(--white); font-size: clamp(2rem, 1.2rem + 4vw, 3.6rem); max-width: 16ch; letter-spacing: -.01em; }
.hero-kicker { text-transform: uppercase; letter-spacing: .2em; font-size: .85rem; opacity: .85; margin-bottom: 14px; }
.hero-lead { font-size: clamp(1.05rem, 1rem + .5vw, 1.3rem); max-width: 52ch; opacity: .95; margin-bottom: 32px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.hero-scroll {
    position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
    color: var(--white); font-size: 1.3rem; opacity: .8; padding: 8px;
}
.hero-scroll:hover { color: var(--white); opacity: 1; }

/* Sections et cartes */
.section { padding: 48px 0; }
.section-alt { background: var(--white); }
.section-title { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); text-align: center; }
.section-lead { text-align: center; color: var(--muted); margin-bottom: 32px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.card-grid .card { margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.two-col .card { margin: 0; }
.tool-card { position: relative; }
.tool-card p { color: var(--muted); margin-bottom: 0; }
.tool-icon {
    display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 14px;
    background: var(--primary-soft); color: var(--primary); border-radius: var(--radius); font-size: 1.25rem;
}
.tool-icon-sm { width: 40px; height: 40px; margin: 0; font-size: 1.05rem; flex: none; }
.tool-link { display: block; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.tool-link:hover { transform: translateY(-2px); border-color: var(--primary); color: inherit; }
.tool-open { display: inline-block; margin-top: 14px; color: var(--primary); font-weight: 600; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .8rem; font-weight: 600; }
.tool-card > .badge { position: absolute; top: 18px; right: 18px; }
.badge-primary { background: var(--primary); color: var(--white); }
.empty { text-align: center; padding: 48px 24px; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--primary); margin: 0; line-height: 1; }

.step-list { list-style: none; padding: 0; margin: 32px auto 0; max-width: 640px; display: grid; gap: 16px; }
.step-list li { display: flex; align-items: center; gap: 16px; font-size: 1.05rem; }
.steps-note { text-align: center; color: var(--muted); margin: 28px 0 0; }
.step-num { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--white); font-weight: 700; }

/* Formulaires */
.form-card { margin-top: 24px; }
.form-foot { margin: 20px 0 0; text-align: center; color: var(--muted); }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field-help { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
    background: var(--white); border: 1px solid #b9c5cf; border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(47, 155, 214, .35); border-color: var(--primary); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; }
.input-code { text-align: center; font-size: 1.6rem; letter-spacing: .2em; text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.form-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; }
.form-row .field { min-width: 200px; }
.field-grow { flex: 1 1 320px; }
.check { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Interrupteurs d'outils */
.toggle-list { list-style: none; margin: 0 0 20px; padding: 0; }
.toggle-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.toggle-row.is-disabled { opacity: .65; }
.toggle-text { flex: 1; min-width: 0; }
.toggle-text .muted { display: block; font-size: .93rem; }
.switch { position: relative; flex: none; display: inline-block; width: 52px; height: 30px; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch input:disabled { cursor: not-allowed; }
.switch-track { position: absolute; inset: 0; background: #b9c5cf; border-radius: 999px; transition: background-color .15s; pointer-events: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: var(--white); border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Code temporaire */
.code-card { background: var(--primary); color: var(--white); text-align: center; border-color: var(--primary); }
.code-card p { margin-bottom: 8px; }
.code-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(2rem, 1.4rem + 3.5vw, 3.2rem); font-weight: 700; letter-spacing: .14em; margin: 4px 0 16px !important; user-select: all; }
.code-help { margin: 16px auto 0 !important; max-width: 60ch; font-size: .93rem; opacity: .9; overflow-wrap: anywhere; }

/* Texte partagé en direct */
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.split .card { margin: 0; }
.field-inline { max-width: 260px; }
.code-inline { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; color: var(--primary); }
.pad-code { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; text-align: left; padding: 18px 24px; }
.pad-code .code-value { margin: 0 !important; font-size: clamp(1.7rem, 1.2rem + 2.6vw, 2.6rem); }
.pad-code-side { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.pad-code .code-help { margin: 0 !important; text-align: left; }
.pad-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.pad-layout .card { margin-bottom: 24px; }
.pad-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pad-head label { font-weight: 600; color: var(--primary); font-size: 1.1rem; }
.pad-status { font-size: .88rem; color: var(--muted); padding: 2px 10px; border-radius: 999px; background: var(--bg); }
.pad-status.is-ok { color: var(--success); background: var(--success-soft); }
.pad-status.is-error { color: var(--danger); background: var(--danger-soft); }
#pad-text { min-height: 320px; }
.pad-actions { margin-top: 14px; align-items: center; }
.pad-actions form { margin: 0; }
.pad-note { font-size: .93rem; }
.version-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.version-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.version-item:last-child { border-bottom: 0; }
.version-info strong { display: block; }
.version-info .muted { font-size: .86rem; }
.version-item.is-current strong { color: var(--primary); }
.version-actions { display: flex; gap: 8px; margin-top: 8px; }
.version-preview { margin-top: 16px; padding-top: 16px; border-top: 2px solid var(--primary-soft); }
.version-preview-title { font-weight: 600; margin-bottom: 8px; }
.version-preview pre {
    margin: 0 0 12px; padding: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem;
}
@media (max-width: 900px) {
    .split, .pad-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Tableaux */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
.cell-url { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions form { display: inline-block; margin: 0 0 0 6px; }

/* Messages */
.flash-zone { padding-top: 20px; }
.is-home .flash-zone { position: absolute; top: var(--header-h); left: 0; right: 0; z-index: 10; }
.alert { padding: 12px 16px; border-radius: var(--radius); border: 1px solid transparent; margin-bottom: 10px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #b7dfc7; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f0b8b3; }
.alert-info { background: var(--primary-soft); color: var(--primary); border-color: #bcd0de; }

/* Pied de page */
.site-footer { background: var(--white); border-top: 1px solid var(--border); padding: 18px 0; font-size: .92rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Mobile */
@media (max-width: 760px) {
    .nav-toggle { display: inline-flex; }
    .site-nav {
        display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0; padding: 8px 20px 18px;
        background: var(--primary); box-shadow: 0 12px 24px rgba(0, 0, 0, .2);
    }
    .site-nav.is-open { display: flex; }
    .site-nav a:not(.btn) { padding: 13px 0; border-bottom: 1px solid rgba(255, 255, 255, .15); }
    .site-nav .btn, .nav-form .btn { width: 100%; margin-top: 14px; }
    .section { padding: 32px 0; }
    .card { padding: 18px; }
    .hero-actions .btn { width: 100%; }
    .table th, .table td { padding: 10px 8px; }
    .cell-actions { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
