/* ============================================================
   FedTools — Design System
   Gris très clair + Bordeaux/Grenat + Blanc
   ============================================================ */

:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #ecebe8;
  --brand: #741f35;
  --brand-strong: #8c2946;
  --brand-dark: #4a1423;
  --brand-soft: #c9899b;
  --brand-tint: #f7eef1;
  --text: #1e1d1d;
  --text-2: #6b6768;
  --border: #ddd9d9;
  --danger: #a4262c;
  --ok: #1e6e3c;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(30, 29, 29, 0.06), 0 2px 8px rgba(30, 29, 29, 0.05);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}

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

/* ---------- Base elements ---------- */
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
code, pre, textarea.mono, input.mono, .mono { font-family: var(--mono); font-size: 0.92em; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--brand);
  padding: 0.6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 860px; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.site-header .container {
  display: flex; align-items: center; gap: 1rem;
  min-height: 60px;
}
.logo {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.15rem; text-decoration: none;
  color: var(--text); letter-spacing: -0.02em;
}
.logo .logo-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800;
}
.logo em { color: var(--brand); font-style: normal; }

.main-nav { margin-left: auto; display: flex; gap: 0.25rem; align-items: center; }
.main-nav a {
  text-decoration: none; color: var(--text-2);
  padding: 0.45rem 0.7rem; border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }

.kbd-hint {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text-2);
  font-size: 0.78rem; padding: 0.15rem 0.45rem; font-family: var(--mono);
}

main { padding: 2rem 0 3.5rem; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 2rem 0; color: var(--text-2); font-size: 0.92rem;
}
.site-footer .container { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }
.site-footer nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-footer a { color: var(--text-2); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.eyebrow {
  display: inline-block; font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--brand-strong);
  background: var(--brand-tint);
  border: 1px solid #ecd5dc;
  padding: 0.25rem 0.8rem; border-radius: 999px; margin-bottom: 1rem;
}
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.9rem); margin-bottom: 0.75rem; }
.hero .sub {
  color: var(--text-2); font-size: 1.1rem; max-width: 560px; margin: 0 auto 1.5rem;
}
.hero-ctas { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  cursor: pointer; text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  min-height: 42px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--brand-soft); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 0.35rem 0.75rem; min-height: 34px; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-danger { background: var(--surface); border-color: var(--border); color: var(--danger); }

/* ---------- Search ---------- */
.search-wrap { max-width: 620px; margin: 0 auto 2rem; position: relative; }
.search-input {
  width: 100%; font: inherit; font-size: 1.05rem;
  padding: 0.85rem 1.1rem 0.85rem 2.7rem;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b6768' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 0.95rem center;
  color: var(--text);
}
.search-input:focus { border-color: var(--brand-strong); outline: none; box-shadow: 0 0 0 3px rgba(140, 41, 70, 0.15); }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-cats { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.tool-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.3rem;
  transition: border-color 0.15s ease;
}
.tool-card:hover { border-color: var(--brand-soft); box-shadow: var(--shadow); }
.tool-card .tool-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--brand-tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.35rem;
}
.tool-card h3 { margin: 0; font-size: 1rem; }
.tool-card h3 a { color: var(--text); text-decoration: none; }
.tool-card h3 a::after { content: ""; position: absolute; inset: 0; }
.tool-card h3 a:hover { color: var(--brand); }
.tool-card p { margin: 0; color: var(--text-2); font-size: 0.88rem; }
.tool-card .fav-btn { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2; }

.fav-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-2); padding: 0.3rem; border-radius: 6px;
  display: inline-flex; min-width: 34px; min-height: 34px; align-items: center; justify-content: center;
}
.fav-btn:hover { background: var(--surface-2); color: var(--brand); }
.fav-btn[aria-pressed="true"] { color: var(--brand); }

.cat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  text-decoration: none; color: var(--text); display: block;
}
.cat-card:hover { border-color: var(--brand-soft); box-shadow: var(--shadow); color: var(--text); }
.cat-card h3 { color: var(--brand); margin-bottom: 0.25rem; }
.cat-card p { margin: 0; color: var(--text-2); font-size: 0.88rem; }
.cat-card .count { font-size: 0.8rem; color: var(--text-2); }

.section { margin: 2.5rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-head a { font-size: 0.92rem; }

/* ---------- Tool page ---------- */
.breadcrumb { font-size: 0.88rem; color: var(--text-2); margin-bottom: 1rem; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { margin: 0 0.4rem; }

.tool-header { display: flex; align-items: flex-start; gap: 0.75rem; justify-content: space-between; margin-bottom: 1.25rem; }
.tool-header p { color: var(--text-2); margin: 0.25rem 0 0; max-width: 640px; }

.tool-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}

.tool-aside { margin-top: 2rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.info-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; font-size: 0.92rem; color: var(--text-2);
}
.info-box h2 { font-size: 0.95rem; color: var(--text); margin-bottom: 0.4rem; }
.info-box ul { margin: 0; padding-left: 1.1rem; }

.privacy-note {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.82rem; color: var(--ok);
  background: #eef6f0; border: 1px solid #d3e6d9;
  border-radius: 999px; padding: 0.2rem 0.7rem; margin-top: 0.5rem;
}

/* ---------- Form widgets ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field > label, fieldset legend { font-weight: 600; font-size: 0.92rem; }
.field .help { font-size: 0.82rem; color: var(--text-2); }

input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"],
input[type="search"], input[type="url"], input[type="password"], select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem; width: 100%;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-strong); outline: none;
  box-shadow: 0 0 0 3px rgba(140, 41, 70, 0.12);
}
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }

input[type="color"] {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  width: 60px; height: 42px; padding: 3px; background: var(--surface); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 17px; height: 17px; }

fieldset {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.75rem 1rem; margin: 0 0 1rem;
}
.check-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; }
.check-row label { font-weight: 400; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0.75rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.75rem 0; }

.output-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.7rem 0.8rem;
  font-family: var(--mono); font-size: 0.92rem;
  white-space: pre-wrap; word-break: break-word;
  min-height: 2.6rem; margin: 0.5rem 0;
}
.output-box:empty::before { content: "—"; color: var(--text-2); }

.stat-grid { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 1rem 0; }
.stat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.75rem;
}
.stat .stat-value { font-size: 1.35rem; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat .stat-label { font-size: 0.8rem; color: var(--text-2); }

.error-msg {
  color: var(--danger); background: #fbeeee; border: 1px solid #efd4d5;
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-size: 0.92rem; margin: 0.5rem 0;
}
.ok-msg {
  color: var(--ok); background: #eef6f0; border: 1px solid #d3e6d9;
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-size: 0.92rem; margin: 0.5rem 0;
}

.result-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 0.5rem 0; }
.result-table th, .result-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.result-table th { color: var(--text-2); font-weight: 600; white-space: nowrap; }
.result-table td.mono { word-break: break-all; }

.swatch { display: inline-block; width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--border); vertical-align: middle; }
.palette-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.palette-cell { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-family: var(--mono); }
.palette-cell button { width: 52px; height: 52px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--bg); padding: 2rem 1rem; text-align: center;
  color: var(--text-2); cursor: pointer; transition: border-color 0.15s ease;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--brand-strong); color: var(--brand); }
.drop-zone strong { color: var(--text); display: block; margin-bottom: 0.25rem; }
.drop-zone .limits { font-size: 0.82rem; margin-top: 0.4rem; }

.file-list { list-style: none; margin: 0.75rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.file-list li {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; font-size: 0.9rem;
}
.file-list .file-name { flex: 1; word-break: break-all; }
.file-list .file-size { color: var(--text-2); white-space: nowrap; font-size: 0.82rem; }

.preview-img { max-width: 100%; max-height: 320px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 0 0/16px 16px; }

.progress-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 0.75rem 0; }
.progress-bar > div { height: 100%; background: var(--brand); width: 0%; transition: width 0.2s ease; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--brand-dark); color: #fff;
  border-radius: 999px; padding: 0.5rem 1.2rem; font-size: 0.92rem;
  box-shadow: var(--shadow); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

/* ---------- Command palette ---------- */
.palette-overlay {
  position: fixed; inset: 0; background: rgba(30, 29, 29, 0.4);
  z-index: 80; display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 1rem 1rem;
}
.palette-box {
  width: 100%; max-width: 560px; background: var(--surface);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  overflow: hidden; border: 1px solid var(--border);
}
.palette-box input {
  border: none; border-bottom: 1px solid var(--border); border-radius: 0;
  padding: 0.9rem 1.1rem; font-size: 1.05rem;
}
.palette-box input:focus { box-shadow: none; }
.palette-results { list-style: none; margin: 0; padding: 0.4rem; max-height: 50vh; overflow-y: auto; }
.palette-results li { border-radius: var(--radius-sm); }
.palette-results a {
  display: flex; flex-direction: column; gap: 0.1rem; padding: 0.55rem 0.75rem;
  text-decoration: none; color: var(--text); border-radius: var(--radius-sm);
}
.palette-results li[aria-selected="true"] a, .palette-results a:hover { background: var(--brand-tint); }
.palette-results .r-name { font-weight: 600; font-size: 0.95rem; }
.palette-results .r-desc { font-size: 0.82rem; color: var(--text-2); }
.palette-empty { padding: 1rem; color: var(--text-2); text-align: center; font-size: 0.92rem; }

/* ---------- Prose pages ---------- */
.prose { max-width: 760px; }
.prose h1 { margin-bottom: 1rem; }
.prose h2 { margin-top: 2rem; }
.prose ul { padding-left: 1.2rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-2); }
.empty-state h2 { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .main-nav a.nav-secondary { display: none; }
  .kbd-hint { display: none; }
  #open-palette .palette-label { display: none; }
  .main-nav { gap: 0; }
  .main-nav a { padding: 0.45rem 0.5rem; }
  .site-header .container { gap: 0.5rem; }
  .tool-panel { padding: 1rem; }
  main { padding: 1.25rem 0 2.5rem; }
  .hero { padding: 1.5rem 0 1rem; }
  .actions .btn { flex: 1 1 auto; }
}
