/* ==========================================================================
   HM Connect / HM Community — feuille de style
   Direction : portail institutionnel — encre marine, filet or "sceau",
   display serif pour les titres, Inter pour l'interface.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #eef1f8;
  --bg-deep: #e4e9f4;
  --surface: #ffffff;
  --surface-soft: #f6f8fc;
  --ink: #10162a;
  --ink-soft: #2b3350;
  --muted: #5b6478;
  --line: #e1e6f0;
  --line-soft: #ecf0f7;

  --primary: #1d3a8a;
  --primary-dark: #142a66;
  --primary-tint: #eaeffc;

  --gold: #a9821f;
  --gold-soft: #f3ead0;

  --success-bg: #eaf7ee;
  --success-text: #1f6d3d;
  --danger-bg: #fdecec;
  --danger-text: #a3282f;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow: 0 20px 48px rgba(16, 22, 42, .08), 0 2px 6px rgba(16, 22, 42, .04);
  --shadow-sm: 0 8px 20px rgba(16, 22, 42, .06);

  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Source Serif 4", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  font-family: var(--font-body);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-soft);
  background:
    radial-gradient(1100px 420px at 12% -8%, rgba(29, 58, 138, .06), transparent 60%),
    var(--bg);
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--primary); color: #fff; }

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

/* ---------- Barre supérieure (en-tête façon "sceau" institutionnel) ---------- */

.topbar {
  min-height: 76px;
  padding: 14px clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 18%, var(--gold) 82%, transparent);
  opacity: .55;
}

.brand { display: flex; align-items: center; gap: 12px; position: relative; }
.brand-mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  color: #f4f6ff;
  background: linear-gradient(160deg, var(--primary), var(--primary-dark));
  font-family: var(--font-display);
  font-weight: 600; font-size: 16px; letter-spacing: .01em;
  box-shadow: 0 8px 20px rgba(20, 42, 102, .32), inset 0 0 0 1.5px rgba(255, 255, 255, .18);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 13px;
  border: 1px solid rgba(169, 130, 31, .55);
  pointer-events: none;
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.brand small { margin-top: 2px; font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.brand-text { display: inline-flex; align-items: center; }
.brand-text.solo { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); }

nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav a {
  padding: 9px 14px; border-radius: 10px;
  color: var(--muted); font-size: 13.5px; font-weight: 600;
  transition: color .15s ease, background-color .15s ease;
}
nav a:hover { color: var(--primary); background: var(--primary-tint); }
nav a.active { color: var(--primary); background: var(--primary-tint); }

/* ---------- Structure des pages ---------- */

.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 48px auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 24px;
  align-items: start;
}
.single-layout, .preview-shell, .article {
  width: min(760px, calc(100% - 40px));
  margin: 48px auto 64px;
}

.panel, .preview-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel { padding: clamp(24px, 4vw, 40px); }
.history-panel { position: sticky; top: 104px; }

.panel-heading { margin-bottom: 28px; }
.panel-heading.compact { margin-bottom: 20px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.eyebrow::before {
  content: ""; width: 14px; height: 1.5px; background: var(--gold); display: inline-block;
}

h1, h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
  line-height: 1.15;
}
h1 { font-size: clamp(26px, 3.6vw, 38px); }
h2 { font-size: 23px; }
.panel-heading p { margin: 12px 0 0; color: var(--muted); line-height: 1.65; font-size: 14.5px; }

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

form { display: grid; gap: 20px; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
input, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: #99a2b6; }
textarea { resize: vertical; min-height: 170px; line-height: 1.6; font-family: var(--font-body); }
input:focus, textarea:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-tint);
}

button, .button-link {
  border: 0; border-radius: 12px; padding: 13px 20px;
  color: #fff; background: var(--primary);
  font: inherit; font-size: 14.5px; font-weight: 700;
  cursor: pointer; text-align: center;
  transition: background-color .15s ease, transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 10px 22px rgba(29, 58, 138, .22);
}
button:hover, .button-link:hover { background: var(--primary-dark); transform: translateY(-1px); }
button:active, .button-link:active { transform: translateY(0); }

.button-secondary { color: var(--primary); background: var(--primary-tint); box-shadow: none; }
.button-secondary:hover { color: #fff; background: var(--primary); }
.text-link { padding: 10px 3px; color: var(--primary); font-weight: 700; }
.text-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- Notices / retours ---------- */

.notice {
  margin-top: 22px; padding: 16px 18px; border-radius: var(--radius-sm);
  color: var(--success-text); background: var(--success-bg);
  line-height: 1.55; font-size: 14px;
}
.notice.error { color: var(--danger-text); background: var(--danger-bg); }
.hidden { display: none; }
.result-actions { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- Liens récents ---------- */

.recent-list { display: grid; gap: 10px; max-height: 520px; overflow-y: auto; padding-right: 3px; }
.recent-list::-webkit-scrollbar { width: 6px; }
.recent-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.recent-item {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center;
  padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-soft);
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.recent-item:hover { border-color: #b9c6ec; background: var(--primary-tint); transform: translateX(2px); }
.recent-icon {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 10px; color: var(--primary); background: #e3e9fb; font-weight: 800;
}
.recent-copy { min-width: 0; }
.recent-copy strong, .recent-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-copy strong { font-size: 13.5px; color: var(--ink); }
.recent-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.recent-arrow { color: #9aa5c0; font-size: 22px; }

.empty-state {
  min-height: 190px; display: grid; place-content: center; gap: 6px; text-align: center;
  color: var(--muted); border: 1.5px dashed #ccd5ea; border-radius: var(--radius-md);
  background: var(--surface-soft); padding: 24px;
}
.empty-state span { font-size: 26px; color: #aab6d6; }
.empty-state p { margin: 4px 0 0; font-size: 13.5px; }

/* ---------- Aperçu (preview.html) ---------- */

.preview-page {
  background:
    radial-gradient(900px 360px at 85% -10%, rgba(169, 130, 31, .07), transparent 60%),
    var(--bg-deep);
}
.preview-card { padding: clamp(28px, 6vw, 60px); min-height: 420px; }
.preview-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  color: var(--primary); background: var(--primary-tint);
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
}
.preview-card h1 { margin-top: 20px; }
.preview-content { margin-top: 22px; color: var(--ink-soft); line-height: 1.75; overflow-wrap: anywhere; font-size: 15.5px; }

/* ---------- Boîte de suivi / collecte (inbox.html, loot.html) ---------- */

.inbox-list, .loot-list { display: grid; gap: 12px; }
.inbox-item, .loot-list pre {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 15px 16px; background: var(--surface-soft);
}
.inbox-item time { color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.inbox-item pre, .loot-list pre {
  margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 12.5px/1.6 var(--font-mono); color: var(--ink-soft);
}
.loot-list pre { margin-top: 0; }
.loot-list p { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Publication communautaire (xss.html) ---------- */

.post-content { margin-top: 20px; color: var(--ink-soft); line-height: 1.75; overflow-wrap: anywhere; font-size: 15.5px; }

/* ---------- Réactivité ---------- */

@media (max-width: 850px) {
  .topbar { padding: 14px 20px; }
  .workspace { grid-template-columns: 1fr; margin-top: 28px; }
  .history-panel { position: static; }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  nav { width: 100%; justify-content: flex-start; }
  .workspace, .single-layout, .preview-shell, .article { width: min(calc(100% - 24px), 760px); margin: 22px auto 40px; }
  .panel { padding: 22px; border-radius: 16px; }
  .result-actions { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
