/*
 * FONGI Platform — Design System
 * Reset, variables CSS, base typography, utilitaires globaux
 * Mobile-first · WCAG 2.1 AA · RTL-ready
 */

/* ── 1. Variables CSS ────────────────────────────────────────────────── */
:root {
  /* === Charte V2 — Palette FONGI méditerranéenne artisanale === */
  --color-olive:             #4A6632;
  --color-ocre:              #8B5E2A;
  --color-parchemin:         #F5F0E8;
  --color-terre-nuit:        #2D2419;

  /* V2 — nouvelles teintes */
  --color-sienne:            #C97B4F;
  --color-olive-clair:       #7A9555;
  --color-bleu-mediterranee: #2A6B8A;
  --color-terracotta:        #D08B5A;
  --color-sable:             #EFE5D3;
  --color-ivoire:            #FAF6EE;

  /* Gradients */
  --gradient-hero:           linear-gradient(135deg, #F5F0E8 0%, #EFE5D3 100%);
  --gradient-card:           linear-gradient(180deg, #FAF6EE 0%, #F5F0E8 100%);
  --gradient-accent-ocre:    linear-gradient(120deg, #8B5E2A 0%, #C97B4F 100%);
  --gradient-accent-olive:   linear-gradient(120deg, #4A6632 0%, #7A9555 100%);
  --gradient-accent-bleu:    linear-gradient(120deg, #2A6B8A 0%, #4A9AB5 100%);

  /* Ombres organiques */
  --shadow-soft:    0 2px 12px rgba(139, 94, 42, 0.08);
  --shadow-medium:  0 4px 20px rgba(139, 94, 42, 0.12);
  --shadow-hover:   0 8px 28px rgba(139, 94, 42, 0.18);

  /* Border-radius organiques */
  --radius-organic-1: 8px 6px 10px 4px;
  --radius-organic-2: 12px 8px 6px 14px;
  --radius-card:      12px;
  --radius-pill:      24px;

  /* Typographie V2 */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;

  /* Texture papier */
  --paper-texture-url: url("/assets/paper_texture-41b999fe.svg");

  /* ============================================= */

  /* Couleurs primaires */
  --color-primary:       #1D9E75;
  --color-primary-dark:  #0F6E56;
  --color-primary-light: #E1F5EE;
  --color-primary-muted: #A8D9C6;

  /* Neutres chauds */
  --color-text:          #2C2C2A;
  --color-text-secondary:#555550;
  --color-muted:         #888780;
  --color-border:        #D8D5CC;
  --color-bg:            #FFFFFF;
  --color-bg-subtle:     #F7F6F2;
  --color-bg-warm:       #F1EFE8;

  /* Sémantiques */
  --color-success:       #1D9E75;
  --color-success-bg:    #E1F5EE;
  --color-warning:       #B45309;
  --color-warning-bg:    #FEF3C7;
  --color-danger:        #B91C1C;
  --color-danger-bg:     #FEE2E2;
  --color-info:          #1D4ED8;
  --color-info-bg:       #DBEAFE;

  /* Typographie */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Fira Code", monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  --font-normal:   400;
  --font-medium:   500;
  --font-semibold: 600;
  --font-bold:     700;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  /* Espacement */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --container-sm:  640px;
  --container-md:  768px;
  --container-lg:  1024px;
  --container-xl:  1280px;

  /* Bordures & ombres */
  --radius-sm:  0.25rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-full:9999px;

  --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;

  /* Z-index */
  --z-nav:     100;
  --z-dropdown:200;
  --z-modal:   300;
  --z-toast:   400;
}

/* ── 2. Reset moderne ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* RTL global */
[dir="rtl"] {
  font-family: var(--font-sans);
}

/* ── 3. Éléments de base ──────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

@media (min-width: 1024px) {
  h1 { font-size: var(--text-4xl); }
}

p {
  line-height: var(--leading-relaxed);
  max-width: 72ch;
}

a {
  color: var(--color-primary-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary);
}

a:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

img, video, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

input, button, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ── 4. Skip link (WCAG 2.4.1) ───────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-modal);
  padding: var(--space-3) var(--space-6);
  background: var(--color-primary-dark);
  color: #fff;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ── 5. Notifications (toast discret) ─────────────────────────────────── */
/* Pilule sombre de la charte, en bas de l'écran, qui s'efface d'elle-même
   (voir controllers/flash_controller.js). Plus de bandeau coloré plein écran. */
.flash-container {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 30rem);
  pointer-events: none;
}

.flash {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 12px 10px 14px;
  border-radius: 999px;
  background: rgba(45, 36, 25, 0.94);
  color: #FAF6EE;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 8px 28px rgba(45, 36, 25, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: flashIn 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.flash__dot {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #C4A47A;
}
.flash--notice .flash__dot, .flash--success .flash__dot { background: #7FB77E; }
.flash--alert  .flash__dot, .flash--error   .flash__dot { background: #E8836B; }
.flash--warning .flash__dot                              { background: #E0B85C; }

.flash__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.flash__close {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.55;
  width: 32px; height: 32px; margin: -6px -4px -6px 0;
  border-radius: 50%;
  font-size: 1rem; line-height: 1;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.flash__close:hover, .flash__close:focus-visible { opacity: 1; background: rgba(250, 246, 238, 0.12); }

@media (min-width: 900px) {
  .flash-container { left: auto; right: 24px; bottom: 24px; transform: none; align-items: flex-end; width: min(28rem, 40vw); }
}

@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
}

/* ── 6. Utilitaires ───────────────────────────────────────────────────── */
.text-muted    { color: var(--color-muted); font-size: var(--text-sm); }
.lead          { font-size: var(--text-lg); color: var(--color-text-secondary); }
.empty-state   { color: var(--color-muted); font-style: italic; padding: var(--space-8) 0; }

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

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 640px)  { .container { padding-inline: var(--space-6); } }
@media (min-width: 1024px) { .container { padding-inline: var(--space-8); } }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── 7. Forms erreurs ──────────────────────────────────────────────────── */
.form-errors {
  padding: var(--space-4);
  background: var(--color-danger-bg);
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  color: var(--color-danger);
}

.form-errors h2 {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
  color: var(--color-danger);
}

.form-errors ul {
  list-style: disc;
  padding-left: var(--space-5);
}

.form-errors li {
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

/* ── 8. Alerts inline ────────────────────────────────────────────────── */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}

.alert--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: #FDE68A;
}

.alert--info {
  background: var(--color-info-bg);
  color: var(--color-info);
  border-color: #BFDBFE;
}

/* ── 9. Focus global ─────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* ═══════════════════════════════
   FICHE PROJET PUBLIQUE
   ═══════════════════════════════ */

.project-show {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.proj-hero {
  padding: 32px 0 0;
  border-left: 4px solid var(--color-or, #C4A882);
  padding-left: 20px;
  margin-bottom: 32px;
}

.proj-hero__back { margin-bottom: 16px; }
.proj-hero__back .back-link {
  font-size: 12px;
  color: var(--color-or, #C4A882);
  text-decoration: none;
  letter-spacing: 0.06em;
}

.proj-hero__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.proj-status {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 2px;
}
.proj-status--active   { background: rgba(138,170,94,0.2); color: #8AAA5E; }
.proj-status--inactive { background: rgba(196,168,130,0.15); color: #C4A882; }
.proj-status--completed{ background: rgba(46,139,139,0.2); color: #2E8B8B; }

.proj-org-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-or, #C4A882);
  text-decoration: none;
}

.proj-org-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
}

.proj-hero__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 400;
  color: #F5F0E8;
  margin: 0 0 10px;
  line-height: 1.2;
}

.proj-period {
  font-size: 12px;
  color: rgba(245,240,232,0.6);
  letter-spacing: 0.04em;
}

.proj-hero__band {
  height: 3px;
  background: linear-gradient(to right, #8B5E2A, #4A6632, #C4A47A);
  margin-top: 24px;
}

/* Corps 2 colonnes */
.proj-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}

.proj-section {
  margin-bottom: 28px;
}

.proj-section__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  font-weight: 600;
  color: #C4A882;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.proj-description {
  font-size: 13px;
  line-height: 1.75;
  color: rgba(245,240,232,0.85);
}

/* Aside sticky */
.proj-aside { position: sticky; top: 24px; }

.proj-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(196,168,130,0.2);
  padding: 16px;
  margin-bottom: 12px;
}

.proj-card__title {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #C4A882;
  margin-bottom: 12px;
}

.proj-org-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.proj-org-badge-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.proj-org-name {
  font-size: 13px;
  color: #F5F0E8;
  font-weight: 500;
}

.proj-org-country {
  font-size: 11px;
  color: rgba(245,240,232,0.5);
  margin-top: 2px;
}

.proj-dates { display: flex; flex-direction: column; gap: 8px; }
.proj-date-row { display: flex; justify-content: space-between; align-items: center; }
.proj-date-label { font-size: 10px; color: rgba(245,240,232,0.5); letter-spacing: 0.06em; }
.proj-date-val { font-size: 12px; color: #F5F0E8; }

@media (max-width: 768px) {
  .proj-body { grid-template-columns: 1fr; }
  .proj-aside { position: static; }
}
.gt-memberships { display:flex; flex-direction:column; gap:8px; }
.gt-membership-row { display:flex; align-items:center; justify-content:space-between; padding:10px 14px; border:1px solid #e5e5e5; border-radius:4px; background:#fafafa; }
.gt-membership-check { display:flex; align-items:center; gap:10px; }
.gt-membership-check input[type=checkbox] { width:16px; height:16px; cursor:pointer; }
.gt-label { display:flex; align-items:center; gap:8px; font-weight:500; cursor:pointer; font-size:13px; }
.gt-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.form-select--sm { font-size:12px; padding:4px 8px; width:150px; }

/* Focal points & locations blocks */
.focal-point-block, .location-block {
  padding: 16px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  margin-bottom: 12px;
  background: #fafafa;
}
.fp-divider, .loc-divider {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 12px 0 0;
}
.focal-point-destroy, .location-block__header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.destroy-label { font-size: 12px; color: #c00; cursor: pointer; }
.fp-badge--logo { padding: 0; overflow: hidden; background: transparent; border: 2px solid rgba(196,168,130,0.3); }
.fp-logo-img { width: 100%; height: 100%; object-fit: contain; }

/* ── Charte V2 — Utilitaires ─────────────────────────────────────────── */

.with-paper-texture {
  background-image: var(--paper-texture-url), var(--gradient-hero);
  background-size: 200px 200px, 100% 100%;
  background-repeat: repeat, no-repeat;
}

.organic-card {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  background: var(--gradient-card);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.organic-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.accent-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.accent-pill--olive   { background: rgba(74,102,50,0.12);  color: var(--color-olive); border: 1px solid rgba(74,102,50,0.25); }
.accent-pill--ocre    { background: rgba(139,94,42,0.12);  color: var(--color-ocre);  border: 1px solid rgba(139,94,42,0.25); }
.accent-pill--sienne  { background: rgba(201,123,79,0.12); color: var(--color-sienne);border: 1px solid rgba(201,123,79,0.25); }
.accent-pill--bleu    { background: rgba(42,107,138,0.12); color: var(--color-bleu-mediterranee); border: 1px solid rgba(42,107,138,0.25); }

.gradient-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
  border: none;
  cursor: pointer;
  color: #fff;
}
.gradient-btn--ocre  { background: var(--gradient-accent-ocre); }
.gradient-btn--olive { background: var(--gradient-accent-olive); }
.gradient-btn--bleu  { background: var(--gradient-accent-bleu); }
.gradient-btn:hover  { opacity: 0.9; transform: translateY(-1px); }

/* ── Garde-fou responsive global ─────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  img, svg, video, table { max-width: 100%; }
  .section-header { flex-wrap: wrap; gap: var(--space-2); }

  /* Plancher typographique 12 px — fiche projet publique */
  .proj-status,
  .proj-org-badge,
  .proj-card__title { font-size: 12px; }
}

/* Grilles déclarées inline (style="grid-template-columns:…") : sur téléphone,
   une seule colonne. Seul !important autorisé (il doit battre l'attribut style). */
@media (max-width: 600px) {
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
