/* Harry — Documentation · feuille de style unique, thèmes clair et sombre. */

:root {
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceef2;
  --border: #dfe3ea;
  --text: #1b2430;
  --text-muted: #667085;
  --accent: #1f6feb;
  --accent-contrast: #ffffff;
  --accent-soft: #e8f0fe;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --sidebar-w: 290px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --code-bg: #f4f6f8;
  --hl-keyword: #a626a4;
  --hl-string: #2f7d32;
  --hl-number: #b35c00;
  --hl-comment: #8a94a6;
  --hl-title: #1f6feb;
  --hl-attr: #986801;
  --hl-type: #0b7285;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --bg-elevated: #161b22;
    --bg-sunken: #0b0f14;
    --border: #262d36;
    --text: #e4e8ee;
    --text-muted: #8b97a8;
    --accent: #4a9eff;
    --accent-contrast: #06121f;
    --accent-soft: #14283f;
    --danger: #ff7b72;
    --danger-soft: #2c1615;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --code-bg: #0d1117;
    --hl-keyword: #ff7bd5;
    --hl-string: #7ee787;
    --hl-number: #ffa657;
    --hl-comment: #6e7a8a;
    --hl-title: #79c0ff;
    --hl-attr: #ffd479;
    --hl-type: #56d4dd;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1419;
  --bg-elevated: #161b22;
  --bg-sunken: #0b0f14;
  --border: #262d36;
  --text: #e4e8ee;
  --text-muted: #8b97a8;
  --accent: #4a9eff;
  --accent-contrast: #06121f;
  --accent-soft: #14283f;
  --danger: #ff7b72;
  --danger-soft: #2c1615;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --code-bg: #0d1117;
  --hl-keyword: #ff7bd5;
  --hl-string: #7ee787;
  --hl-number: #ffa657;
  --hl-comment: #6e7a8a;
  --hl-title: #79c0ff;
  --hl-attr: #ffd479;
  --hl-type: #56d4dd;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ── Boutons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-sunken); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn--ghost { background: transparent; }
.btn--ghost.is-active { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--block { width: 100%; }
.btn--sm { padding: .3rem .55rem; font-size: .8rem; }
.btn--icon { width: 2.3rem; padding: .5rem 0; }

/* ── Connexion ─────────────────────────────────────────────────────────── */

.login-body { display: grid; place-items: center; background: var(--bg-sunken); }
.login { width: min(100% - 2rem, 400px); text-align: center; }
.login__card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
}
.login__card h1 { font-size: 1.25rem; margin: 1rem 0 .25rem; }
.login__hint { color: var(--text-muted); font-size: .875rem; margin: 0 0 1.5rem; }
.login__form { display: grid; gap: .9rem; text-align: left; }
.login__form label { display: grid; gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.login__foot { color: var(--text-muted); font-size: .8rem; margin-top: 1.25rem; }

input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.alert { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .875rem; margin: 0 0 1rem; }
.alert--error { background: var(--danger-soft); color: var(--danger); }

/* ── Structure ─────────────────────────────────────────────────────────── */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  padding: 1.1rem;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: .65rem; color: inherit; }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 2.1rem; height: 2.1rem;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}
.brand__mark--lg { width: 3rem; height: 3rem; font-size: 1.4rem; margin: 0 auto; }
.brand__text { display: grid; line-height: 1.25; }
.brand__text small { color: var(--text-muted); font-size: .7rem; }

.sidebar__docs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -.35rem; padding: 0 .35rem; }
.doc-link { display: grid; gap: 1px; padding: .45rem .6rem; border-radius: var(--radius-sm); color: var(--text); }
.doc-link:hover { background: var(--bg-sunken); text-decoration: none; }
.doc-link.is-active { background: var(--accent-soft); color: var(--accent); }
.doc-link__title { font-size: .875rem; font-weight: 500; }
.doc-link__meta { font-size: .68rem; color: var(--text-muted); }
.doc-link.is-hidden, .is-hidden { display: none; }

.sidebar__foot { display: grid; gap: .5rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.sidebar__row { display: flex; gap: .5rem; }
.sidebar__logout { flex: 1; }

.main { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1200px; width: 100%; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 1.1rem;
  margin-bottom: 1.6rem;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin: .15rem 0; font-size: 1.6rem; line-height: 1.25; }
.eyebrow { margin: 0; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.meta { margin: 0; color: var(--text-muted); font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.empty { color: var(--text-muted); font-size: .875rem; padding: .5rem; }

/* ── Cartes, tableaux, zone de dépôt ───────────────────────────────────── */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card {
  display: grid;
  gap: .4rem;
  align-content: start;
  padding: 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 1rem; }
.card__excerpt { margin: 0; color: var(--text-muted); font-size: .82rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { margin: 0; color: var(--text-muted); font-size: .72rem; }

.dropzone {
  display: grid;
  gap: .35rem;
  justify-items: center;
  padding: 1.4rem;
  margin-bottom: 1.6rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  text-align: center;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__title { margin: 0; font-weight: 600; }
.dropzone__hint { margin: 0 0 .5rem; color: var(--text-muted); font-size: .78rem; }

.panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.files { width: 100%; border-collapse: collapse; font-size: .875rem; }
.files th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.files td { padding: .6rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.files tr:last-child td { border-bottom: 0; }
.files__preview { width: 68px; }
.files__preview img { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.files__preview .ext { display: grid; place-items: center; width: 52px; height: 40px; border-radius: 6px; background: var(--bg-sunken); font-size: .65rem; text-transform: uppercase; color: var(--text-muted); }
.files__actions { text-align: right; white-space: nowrap; }

/* ── Document rendu ────────────────────────────────────────────────────── */

.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 2.5rem; align-items: start; }
.doc-layout > .markdown:only-child { grid-column: 1 / -1; }

.toc { position: sticky; top: 2rem; font-size: .8rem; border-left: 1px solid var(--border); padding-left: 1rem; }
.toc__title { margin: 0 0 .5rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.toc a { color: var(--text-muted); }
.toc a:hover { color: var(--accent); }
.toc__l3 { padding-left: .75rem; }
.toc__l4 { padding-left: 1.5rem; }

.markdown { min-width: 0; }
.markdown > *:first-child { margin-top: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { line-height: 1.3; margin: 2rem 0 .75rem; scroll-margin-top: 1.5rem; }
.markdown h1 { font-size: 1.6rem; }
.markdown h2 { font-size: 1.28rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.08rem; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote { margin: 0 0 1rem; }
.markdown ul, .markdown ol { padding-left: 1.4rem; }
.markdown li + li { margin-top: .25rem; }
.markdown blockquote { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: .6rem .9rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text); }
.markdown blockquote > *:last-child { margin-bottom: 0; }
.markdown img { max-width: 100%; border-radius: var(--radius-sm); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.markdown table { width: 100%; border-collapse: collapse; margin: 0 0 1.25rem; font-size: .9rem; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: .45rem .7rem; text-align: left; }
.markdown th { background: var(--bg-sunken); }
.markdown code { font-family: var(--mono); font-size: .855em; background: var(--code-bg); padding: .12em .35em; border-radius: 5px; border: 1px solid var(--border); }
.markdown pre { position: relative; margin: 0 0 1.25rem; padding: .9rem 1rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.markdown pre code { background: none; border: 0; padding: 0; font-size: .84rem; line-height: 1.55; }
.copy-code { position: absolute; top: .5rem; right: .5rem; opacity: 0; transition: opacity .15s; }
.markdown pre:hover .copy-code, .copy-code:focus-visible { opacity: 1; }

/* Coloration syntaxique (jetons highlight.js). */
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--hl-string); }
.hljs-number, .hljs-meta { color: var(--hl-number); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id { color: var(--hl-title); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: var(--hl-attr); }
.hljs-type, .hljs-class .hljs-title, .hljs-symbol, .hljs-bullet { color: var(--hl-type); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ── Éditeur ───────────────────────────────────────────────────────────── */

.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; height: calc(100vh - 220px); min-height: 420px; }
.editor__pane { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); overflow: hidden; }
.editor__bar { display: flex; justify-content: space-between; align-items: center; padding: .45rem .8rem; border-bottom: 1px solid var(--border); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.editor__bar .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.editor textarea { flex: 1; border: 0; border-radius: 0; resize: none; padding: 1rem; font-family: var(--mono); font-size: .85rem; line-height: 1.6; background: var(--bg-elevated); }
.editor textarea:focus-visible { outline: none; }
.editor__preview { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; }

/* ── Notifications et responsive ───────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 200%);
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: .85rem;
  box-shadow: var(--shadow);
  transition: transform .25s ease;
  z-index: 60;
  max-width: min(90vw, 480px);
}
.toast.is-visible { transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; }

.menu-toggle { display: none; position: fixed; top: .75rem; left: .75rem; z-index: 50; width: 2.4rem; height: 2.4rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.overlay { display: none; }

@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: block; }
  .main { padding-top: 3.75rem; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(85vw, var(--sidebar-w)); transform: translateX(-100%); transition: transform .2s ease; z-index: 55; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: none; }
  .overlay { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 50; }
  .overlay[hidden] { display: none; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor__pane { min-height: 320px; }
}
