@font-face {
    font-family: "Figtree";
    src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2");
    font-weight: 300 900;
    font-display: swap;
}

:root {
    /* Charte Pluscom : anthracite et orange relevés sur le logo */
    --ink: #373736;
    --ink-soft: #5d5d5a;
    --orange: #e9610a;
    --orange-deep: #bf4a04;
    --orange-deeper: #9f3c02;
    --orange-tint: #fdeee3;

    --ground: #f4f4f2;
    --rail: #e9e9e7;
    --rail-hover: #dededc;
    --surface: #ffffff;
    --line: #dbdbd8;
    --line-strong: #b8b8b5;

    --success: #1c6e3d;
    --success-tint: #e4f3e9;
    --danger: #ad2319;
    --danger-tint: #fceae8;
    --info-tint: #eceff4;

    --radius: 10px;
    --radius-small: 6px;
    --shadow: 0 1px 2px rgba(55, 55, 54, .06), 0 8px 24px -12px rgba(55, 55, 54, .18);
    --ease: cubic-bezier(.16, 1, .3, 1);

    --text-xs: .8125rem;
    --text-sm: .875rem;
    --text-md: 1rem;
    --text-lg: 1.1875rem;
    --text-xl: 1.4375rem;
    --text-2xl: 1.75rem;
}

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

[hidden] { display: none !important; }

html { scrollbar-color: var(--line-strong) var(--ground); }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 400 var(--text-md)/1.55 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    caret-color: var(--orange-deep);
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--orange-tint); color: var(--ink); }

a { color: var(--orange-deep); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--orange-deeper); }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.012em; text-wrap: balance; }
h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-lg); font-weight: 650; }
p { margin: 0 0 1em; }

.icon { flex: none; }
.muted { color: var(--ink-soft); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Structure ---------- */

.skip {
    position: absolute; left: 12px; top: -48px; z-index: 10;
    padding: 8px 14px; border-radius: var(--radius-small);
    background: var(--ink); color: #fff;
}
.skip:focus { top: 12px; color: #fff; }

.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

.rail {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 28px;
    padding: 28px 16px 20px;
    background: var(--rail);
    border-right: 1px solid var(--line);
}
.product {
    display: block; padding: 0 12px;
    color: var(--ink); font-size: var(--text-lg); font-weight: 750; letter-spacing: -.015em;
    text-decoration: none;
}
.product:hover { color: var(--ink); }
.rail-client { margin: 2px 0 0; padding: 0 12px; color: var(--ink-soft); font-size: var(--text-sm); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 9px 12px; border: 0; border-radius: var(--radius-small);
    background: none; color: var(--ink); font: inherit; font-weight: 550; text-align: left;
    text-decoration: none; cursor: pointer;
    transition: background-color .16s var(--ease);
}
.nav-item .icon { color: var(--ink-soft); }
.nav-item:hover { background: var(--rail-hover); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.nav-item[aria-current="page"] .icon { color: var(--orange-deep); }

/* Sur le gris du rail, l'orange de la charte ne contraste pas assez pour un anneau de focus */
.rail :focus-visible { outline-color: var(--orange-deep); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.rail-foot form { margin: 0; }
.who {
    display: block; padding: 0 12px 6px; color: var(--ink-soft); font-size: var(--text-xs);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.service {
    display: flex; align-items: center; gap: 8px; margin: 0; padding: 14px 12px 0;
    border-top: 1px solid var(--line);
    color: var(--ink-soft); font-size: var(--text-xs);
}
.service img { display: block; height: 20px; width: auto; }
.service-inline { display: none; }

.main { min-width: 0; padding: 44px 48px 72px; }
.main-inner { max-width: 1040px; margin: 0 auto; }

.gate { display: grid; place-items: center; min-height: 100vh; padding: 32px 16px; }
.gate-main { width: 100%; max-width: 420px; }
.gate-main.wide { max-width: 520px; }
.gate .product { padding: 0; margin-bottom: 28px; font-size: var(--text-xl); }
.gate .service { margin-top: 32px; padding-left: 0; padding-right: 0; }
.gate h1 { margin-bottom: 8px; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap;
    margin-bottom: 28px;
}
.page-head .lede { margin: 6px 0 0; color: var(--ink-soft); }
.back {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px;
    color: var(--ink-soft); font-size: var(--text-sm); font-weight: 550; text-decoration: none;
}
.back:hover { color: var(--ink); }

.section { padding-top: 32px; margin-top: 36px; border-top: 1px solid var(--line); }
.section > h2 { margin-bottom: 6px; }
.section > h2 + p { color: var(--ink-soft); max-width: 68ch; }
.section > h2 + :not(p) { margin-top: 18px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* ---------- Formulaires ---------- */

.form { max-width: 640px; }
.field { display: block; margin-bottom: 20px; }
.field > .label, .field > span:first-child, fieldset > legend {
    display: block; margin-bottom: 6px; padding: 0;
    font-size: var(--text-sm); font-weight: 650;
}
.optional { color: var(--ink-soft); font-weight: 400; }
.hint { display: block; margin: 6px 0 0; color: var(--ink-soft); font-size: var(--text-sm); font-weight: 400; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
fieldset { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    display: block; width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-small);
    background: var(--surface); color: var(--ink);
    font: inherit;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
textarea { resize: vertical; line-height: 1.5; min-height: 6em; }
select {
    appearance: none; -webkit-appearance: none; padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%235d5d5a%27 stroke-width=%271.75%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M6 9l6 6 6-6%27/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input::placeholder, textarea::placeholder { color: #6f6f6b; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-soft); }
input:not([type="checkbox"]):not([type="radio"]):focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none; border-color: var(--orange-deep);
    box-shadow: 0 0 0 3px rgba(233, 97, 10, .28);
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--orange-deep); }

.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 20px; }
.check input { margin-top: 3px; flex: none; }

.counter { float: right; color: var(--ink-soft); font-size: var(--text-xs); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 9px 18px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-small);
    background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 650; line-height: 1.2; text-decoration: none; cursor: pointer;
    transition: background-color .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease);
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange-deep); border-color: var(--orange-deep); color: #fff; }
.btn-primary:hover { background: var(--orange-deeper); border-color: var(--orange-deeper); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.btn-small { min-height: 34px; padding: 5px 12px; font-size: var(--text-sm); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.is-done { background: var(--success-tint); border-color: var(--success); color: var(--success); }

.link-btn {
    padding: 0; border: 0; background: none; color: var(--orange-deep);
    font: inherit; text-decoration: underline; text-underline-offset: .18em; cursor: pointer;
}
.link-btn:hover { color: var(--orange-deeper); }

.danger-zone { margin-top: 40px; }

/* ---------- Messages ---------- */

.flash {
    padding: 12px 16px; margin-bottom: 20px; border-radius: var(--radius-small);
    font-weight: 500;
}
.flash-success { background: var(--success-tint); color: var(--success); }
.flash-error { background: var(--danger-tint); color: var(--danger); }
.flash-info { background: var(--info-tint); color: var(--ink); }
.flash a { color: inherit; font-weight: 650; }

.badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: var(--text-xs); font-weight: 650;
}
.badge-on { background: var(--success-tint); color: var(--success); }
.badge-off { background: var(--rail); color: var(--ink-soft); }

/* ---------- Jauge de quota ---------- */

.quota { display: grid; gap: 6px; min-width: 200px; font-size: var(--text-sm); color: var(--ink-soft); }
.quota strong { color: var(--ink); font-variant-numeric: tabular-nums; }
progress {
    appearance: none; -webkit-appearance: none;
    display: block; width: 100%; height: 6px; border: 0; border-radius: 999px;
    background: var(--line); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--orange); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--orange); border-radius: 999px; }
progress.is-full::-webkit-progress-value { background: var(--danger); }
progress.is-full::-moz-progress-bar { background: var(--danger); }

/* ---------- Tableaux ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 14px 20px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th {
    padding-top: 12px; padding-bottom: 12px;
    color: var(--ink-soft); font-size: var(--text-xs); font-weight: 650; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .16s var(--ease); }
tbody tr:hover { background: #fafaf9; }
td.right, th.right { text-align: right; }
.row-title { color: var(--ink); font-weight: 650; text-decoration: none; }
.row-title:hover { color: var(--orange-deep); text-decoration: underline; }
td .quota { min-width: 150px; }
td:first-child:has(.row-title) { min-width: 190px; }

.empty { padding: 56px 24px; text-align: center; }
.empty h2 { margin-bottom: 8px; }
.empty p { max-width: 46ch; margin: 0 auto 20px; color: var(--ink-soft); }

.inline-form { display: flex; gap: 8px; align-items: flex-end; margin: 0; }
.inline-form input { min-width: 0; }
.mini-field { display: block; flex: 1; min-width: 0; }
.mini-field span { display: block; margin-bottom: 4px; color: var(--ink-soft); font-size: var(--text-xs); font-weight: 650; }
.row-actions { display: flex; gap: 8px; align-items: flex-end; justify-content: flex-end; }
.row-actions .inline-form:first-child { flex: 1; max-width: 420px; }
.row-actions .btn, .add-row .btn { min-height: 44px; }
.add-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; padding: 16px 20px; border-top: 1px solid var(--line); margin: 0; }
.page-head > .badge { align-self: flex-start; margin-top: 8px; }

/* ---------- Nouvel article ---------- */

.composer { display: grid; grid-template-columns: minmax(0, 1fr) 320px; position: relative; overflow: hidden; }
.composer-source { padding: 28px; }
.composer-options {
    display: flex; flex-direction: column;
    padding: 28px; border-left: 1px solid var(--line); background: #fafaf9;
}
.composer-options .btn { margin-top: auto; min-height: 50px; }
.composer textarea { min-height: 220px; }

.dropzone {
    padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-small);
    color: var(--ink-soft); text-align: center;
    transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.dropzone.over { border-color: var(--orange-deep); background: var(--orange-tint); color: var(--ink); }
.dropzone p { display: flex; align-items: center; justify-content: center; gap: 4px 8px; flex-wrap: wrap; margin: 0; }
.dropzone strong { color: var(--ink); }
.previews { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.previews:not(:empty) { margin-top: 18px; }
.preview-item { position: relative; }
.preview-item img { display: block; height: 108px; border-radius: var(--radius-small); border: 1px solid var(--line); }
.preview-item button {
    position: absolute; top: -9px; right: -9px;
    display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
    border: 1px solid var(--line-strong); border-radius: 50%;
    background: var(--surface); color: var(--ink); cursor: pointer;
}
.preview-item button:hover { border-color: var(--danger); color: var(--danger); }
.preview-item button .icon { width: 14px; height: 14px; }

.choices { display: grid; gap: 8px; }
.choice {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-small);
    background: var(--surface); cursor: pointer;
    transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.choice:hover { border-color: var(--ink-soft); }
.choice:has(input:checked) { border-color: var(--orange-deep); background: var(--orange-tint); }
.choice span { font-weight: 650; }
.choice small { margin-left: auto; color: var(--ink-soft); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }

/* La feuille qui s'écrit : l'attente de la rédaction */
.writing { display: none; grid-column: 1 / -1; }
.composer.is-writing > :not(.writing) { display: none; }
.composer.is-writing > .writing { display: block; }
.composer.is-writing { display: block; overflow: visible; border: 0; background: none; }
/* Mêmes largeur, marges et ombre que la feuille de l'article livré */
.writing-sheet { max-width: 668px; padding: 44px 52px 52px; box-shadow: var(--shadow); }
.writing-status { margin: 0 0 20px; font-size: var(--text-lg); font-weight: 650; }
.writing-status small { display: block; margin-top: 4px; color: var(--ink-soft); font-size: var(--text-sm); font-weight: 400; }
.writing-line {
    height: 10px; margin-bottom: 19px; border-radius: 2px; background: var(--line);
    transform-origin: left center;
    animation: write-line 7s var(--ease) infinite both;
    animation-delay: calc(var(--i) * .38s);
}
.writing-line.is-title { height: 24px; width: 86%; margin-bottom: 14px; background: var(--orange); }
.writing-line.is-title + .is-title { width: 58%; margin-bottom: 36px; }
.writing-line.is-heading { height: 15px; width: 46%; margin-top: 38px; margin-bottom: 22px; background: var(--line-strong); }
.writing-line.is-short { width: 58%; }
@keyframes write-line {
    0% { transform: scaleX(0); opacity: 1; }
    14%, 90% { transform: scaleX(1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 0; }
}

/* ---------- Article ---------- */

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.sheet { padding: 44px 52px 52px; box-shadow: var(--shadow); }
.sheet-title { margin-bottom: 24px; font-size: 2rem; line-height: 1.15; }
.prose { max-width: 68ch; font-size: 1.0625rem; line-height: 1.7; }
.prose h2 { margin: 1.9em 0 .5em; font-size: var(--text-xl); }
.prose h3, .prose h4 { margin: 1.6em 0 .4em; font-size: var(--text-lg); font-weight: 650; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose blockquote { margin: 1.4em 0; padding: 0 1.5em; color: var(--ink-soft); font-style: italic; }

.publish { position: sticky; top: 28px; display: grid; gap: 20px; }
.publish-block { padding: 20px; }
.publish-block h2 { margin-bottom: 4px; font-size: var(--text-md); }
.publish-block > p { color: var(--ink-soft); font-size: var(--text-sm); }
.publish-block .btn + .btn { margin-top: 8px; }
.meta { padding: 14px 0; border-top: 1px solid var(--line); }
.meta:first-of-type { border-top: 0; padding-top: 4px; }
.meta:last-child { padding-bottom: 0; }
.meta-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.meta-head .label { font-size: var(--text-xs); font-weight: 650; color: var(--ink-soft); }
.meta-count { font-size: var(--text-xs); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.meta-count.is-over { color: var(--danger); font-weight: 650; }
.meta p { margin: 0 0 10px; overflow-wrap: anywhere; }

details.source { margin-top: 24px; }
details.source summary {
    display: inline-flex; align-items: center; gap: 10px; list-style: none;
    cursor: pointer; color: var(--ink-soft); font-weight: 550;
}
details.source summary::-webkit-details-marker { display: none; }
details.source summary::before {
    content: ""; width: 7px; height: 7px; margin-left: 3px;
    border-right: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor;
    transform: rotate(-45deg); transition: transform .16s var(--ease);
}
details.source[open] summary::before { transform: rotate(45deg); }
details.source summary:hover { color: var(--ink); }
details.source .source-body { margin-top: 12px; padding: 20px; color: var(--ink-soft); max-width: 72ch; }

/* ---------- Mon entreprise ---------- */

.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.guide h2 { margin-bottom: 10px; font-size: var(--text-md); }
.guide ul { margin: 0; padding: 0; list-style: none; }
.guide li { padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: var(--text-sm); }
.guide li strong { display: block; color: var(--ink); font-size: var(--text-md); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.after-panel { margin-top: 20px; }
/* Choix de la période, à droite de l'en-tête de page */
.period { display: flex; align-items: flex-end; gap: 8px; margin: 0; min-width: 220px; }

/* Pages connues du site : titre, puis adresse en retrait */
.page-list { margin: 12px 0 0; padding: 0; list-style: none; max-width: 640px; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.page-list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 550; overflow-wrap: anywhere; }
.page-list li span { display: block; color: var(--ink-soft); font-size: var(--text-sm); font-weight: 400; }

/* ---------- Petits écrans ---------- */

@media (max-width: 1100px) {
    .article-layout, .split { grid-template-columns: minmax(0, 1fr); }
    /* En une colonne : copier l'article d'abord, l'article, puis les champs de référencement */
    .article-layout { gap: 20px; }
    .publish { display: contents; }
    .publish-block:first-child { order: -1; }
    .main { padding: 36px 28px 64px; }
}

@media (max-width: 900px) {
    .app { display: block; }
    .rail {
        position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px;
        padding: 14px 16px 10px; border-right: 0; border-bottom: 1px solid var(--line);
    }
    .rail-brand { flex: 1; min-width: 0; }
    .rail-client { display: none; }
    .nav { order: 3; flex: 0 0 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; padding-bottom: 4px; }
    .nav .nav-item { width: auto; flex: 1 1 0; justify-content: center; white-space: nowrap; }
    .rail-foot { margin: 0; flex-direction: row; }
    .rail-foot .who, .rail-foot .service { display: none; }
    .rail-foot .nav-item { width: auto; padding: 8px; }
    .rail-foot .nav-item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .service-inline { display: flex; margin-top: 48px; padding-left: 0; }
    .main { padding: 28px 16px 48px; }
    .composer { grid-template-columns: minmax(0, 1fr); }
    .composer-source, .composer-options { padding: 20px; }
    .composer-options { border-left: 0; border-top: 1px solid var(--line); }
    .composer-options .btn { margin-top: 4px; }
    .sheet { padding: 28px 22px 32px; }
    .sheet-title { font-size: 1.625rem; }
    th, td { padding: 12px 14px; }
}

@media (max-width: 640px) {
    h1 { font-size: var(--text-xl); }
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .add-row { grid-template-columns: minmax(0, 1fr); }
    .inline-form { flex-wrap: wrap; }
    .nav .nav-item { flex: 1 1 calc(50% - 4px); justify-content: flex-start; }

    /* Tableaux en fiches : chaque ligne se lit sans défilement horizontal */
    .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; }
    .table-stack tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td { padding: 3px 0; border: 0; text-align: left; white-space: normal; min-width: 0; }
    .table-stack td[data-label] { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
    .table-stack td[data-label]::before { content: attr(data-label); color: var(--ink-soft); font-size: var(--text-sm); }
    .table-stack td .quota { width: 100%; margin: 4px 0 6px; }
    .row-actions { flex-direction: column; align-items: stretch; }
    .row-actions .inline-form:first-child { max-width: none; }
    .writing-sheet { padding: 28px 22px 32px; }
    .quota { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; }
    .writing-line { animation: none; }
}
