/* ==========================================================================
   IFSI Mende · Notes de cours synthétiques & visuelles (Mémoire Visuelle)
   Design System: Écrin médical, typographie soignée, repères graphiques à fort contraste
   ========================================================================== */

:root {
  --green: #175848;
  --green-dark: #0f3d32;
  --green-light: #e8f2ee;
  --green-glow: rgba(23, 88, 72, 0.12);
  --gold: #b17b31;
  --gold-light: #fef8ee;
  --gold-border: #e0b46a;
  --paper: #fbfaf6;
  --paper-card: #ffffff;
  --ink: #142a25;
  --ink-soft: #2d453e;
  --ink-muted: #536b63;
  --ink-faint: #7d948c;
  --line: #e3ded5;
  --line-strong: #c8c2b5;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(20, 42, 37, 0.05);
  --shadow-md: 0 6px 18px rgba(20, 42, 37, 0.07);
  --shadow-lg: 0 12px 32px rgba(20, 42, 37, 0.1);

  /* Couleurs sémantiques pour la mémoire visuelle */
  --c-blue: #0284c7;
  --c-blue-bg: #f0f9ff;
  --c-blue-border: #bae6fd;
  --c-green: #059669;
  --c-green-bg: #ecfdf5;
  --c-green-border: #a7f3d0;
  --c-amber: #d97706;
  --c-amber-bg: #fffbeb;
  --c-amber-border: #fde68a;
  --c-coral: #dc2626;
  --c-coral-bg: #fef2f2;
  --c-coral-border: #fecaca;
  --c-purple: #7c3aed;
  --c-purple-bg: #f5f3ff;
  --c-purple-border: #ddd6fe;
}

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

body.notes-page {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* En-tête officiel & navigation IFSI Mende */
.notes-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px max(24px, env(safe-area-inset-right, 0px)) 10px max(24px, env(safe-area-inset-left, 0px));
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.notes-header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.notes-header-brand img {
  height: 38px;
  width: auto;
  border-radius: var(--radius-sm);
  display: block;
  transition: transform 0.15s ease;
}
.notes-header-brand img:hover {
  transform: scale(1.03);
}

.notes-breadcrumb {
  font-size: 0.85rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.notes-breadcrumb a {
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}
.notes-breadcrumb a:hover {
  text-decoration: underline;
  color: var(--green-dark);
}
.notes-breadcrumb .sep {
  color: var(--ink-faint);
}
.notes-breadcrumb .current {
  color: var(--ink);
  font-weight: 500;
}

.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-notes-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 14px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--paper-card);
  color: var(--ink-soft);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}
.btn-notes-action:hover {
  background: #f1f3ec;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-notes-action.primary {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}
.btn-notes-action.primary:hover {
  background: var(--green-dark);
}

/* Zone principale */
.notes-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px max(24px, env(safe-area-inset-right, 0px)) 80px max(24px, env(safe-area-inset-left, 0px));
}

/* Hero visuel */
.notes-hero {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.notes-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--c-blue));
}

.hero-tag-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hero-pill {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--green);
}
.hero-pill.gold {
  background: var(--gold-light);
  color: #7d4e0e;
  border: 1px solid var(--gold-border);
}

.notes-hero h1 {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
  line-height: 1.2;
}

.notes-hero p.lead {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0 0 20px;
  max-width: 820px;
}

/* 3 Points clés indispensables */
.hero-keypoints {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.keypoint-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.keypoint-item strong {
  color: var(--ink);
}
.keypoint-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

/* Barre d'outils interactifs / Filtres visuels */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  min-height: 44px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-card);
  color: var(--ink-muted);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}
.filter-pill:hover,
.filter-pill.active {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

/* Bouton mode "Cache-mémoire" (Active recall) */
.toggle-memory-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  background: #fbf5e8;
  color: #7b4f0f;
  border: 1.5px solid var(--gold-border);
  padding: 8px 16px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}
.toggle-memory-mode:hover {
  background: #f5edd8;
}
.toggle-memory-mode.active {
  background: var(--gold);
  color: #ffffff;
  border-color: var(--gold);
}

/* Sections des notes */
.notes-section {
  margin-bottom: 38px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}

.section-head h2 {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.45rem;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-head span.hint {
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-weight: 500;
}

/* 1. Grand schéma synoptique */
.synoptic-box {
  background: var(--paper-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  text-align: center;
}
.synoptic-box svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.synoptic-caption {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-top: 14px;
  font-style: italic;
}

/* 2. Grille de cartes mémo (Sketchnote Cards) */
.sketchnote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.sn-card {
  background: var(--paper-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.sn-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

/* Variantes de couleur des cartes */
.sn-card.blue {
  border-top: 4px solid var(--c-blue);
}
.sn-card.green {
  border-top: 4px solid var(--c-green);
}
.sn-card.amber {
  border-top: 4px solid var(--c-amber);
}
.sn-card.coral {
  border-top: 4px solid var(--c-coral);
}
.sn-card.purple {
  border-top: 4px solid var(--c-purple);
}

.sn-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sn-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.sn-card.blue .sn-badge { background: var(--c-blue-bg); color: var(--c-blue); border: 1px solid var(--c-blue-border); }
.sn-card.green .sn-badge { background: var(--c-green-bg); color: var(--c-green); border: 1px solid var(--c-green-border); }
.sn-card.amber .sn-badge { background: var(--c-amber-bg); color: var(--c-amber); border: 1px solid var(--c-amber-border); }
.sn-card.coral .sn-badge { background: var(--c-coral-bg); color: var(--c-coral); border: 1px solid var(--c-coral-border); }
.sn-card.purple .sn-badge { background: var(--c-purple-bg); color: var(--c-purple); border: 1px solid var(--c-purple-border); }

.sn-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.sn-card h3 {
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0 0 10px;
  font-weight: 700;
}

.sn-card ul {
  margin: 0 0 14px;
  padding-left: 18px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.sn-card ul li {
  margin-bottom: 6px;
  line-height: 1.45;
}
.sn-card ul li strong {
  color: var(--ink);
}

/* Encadré repère visuel dans la carte */
.sn-visual-cue {
  background: #f7f9f6;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sn-visual-cue strong {
  color: var(--green);
}

/* 3. Tableaux comparatifs visuels */
.comparison-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  background: var(--paper-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
}

.visual-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.visual-table th {
  background: #f4f6f1;
  padding: 14px 18px;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 2px solid var(--line);
}
.visual-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  vertical-align: top;
}
.visual-table tr:last-child td {
  border-bottom: none;
}
.visual-table tr:hover td {
  background: #f9fbf7;
}

/* 4. Grille des constantes & chiffres clés */
.constants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.const-card {
  background: var(--paper-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  position: relative;
}

.const-card .val {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1.1;
  margin: 6px 0;
  font-feature-settings: "tnum";
}
.const-card .val.coral { color: var(--c-coral); }
.const-card .val.amber { color: var(--c-amber); }
.const-card .val.blue { color: var(--c-blue); }

.const-card .label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
  letter-spacing: 0.03em;
}
.const-card .meaning {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 6px;
  line-height: 1.35;
}

/* 5. Mnémoniques & Règles d'or */
.mnemo-box {
  background: #fffcf4;
  border: 1.5px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.mnemo-icon {
  font-size: 2rem;
  line-height: 1;
}
.mnemo-content h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: #633f0c;
}
.mnemo-content p {
  margin: 0;
  font-size: 0.92rem;
  color: #4a3416;
  line-height: 1.5;
}
.mnemo-content strong {
  color: #2b1c05;
}

/* Effet du "Mode Cache-mémoire" (Active recall) */
body.memory-blur .memory-target {
  filter: blur(5px);
  background: #e4e7df;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.2s ease, background 0.2s ease;
  border-radius: 4px;
  padding: 1px 4px;
}
@media (hover: hover) and (pointer: fine) {
  body.memory-blur .memory-target:hover {
    filter: none;
    background: transparent;
  }
}
body.memory-blur .memory-target.revealed {
  filter: none;
  background: transparent;
}

/* Pied de page */
.notes-footer {
  border-top: 1px solid var(--line);
  padding-top: 24px;
  padding-bottom: max(32px, calc(20px + env(safe-area-inset-bottom, 0px)));
  margin-top: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ink-muted);
  flex-wrap: wrap;
  gap: 12px;
}
.notes-footer a {
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
}
.notes-footer a:hover {
  text-decoration: underline;
}

/* Style d'impression Fiche Mémo A4 */
@media print {
  .notes-header,
  .notes-toolbar,
  .btn-notes-action,
  .notes-footer nav,
  .skip-link {
    display: none !important;
  }
  body.notes-page {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .notes-main {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .notes-hero {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    page-break-inside: avoid;
  }
  .sn-card,
  .synoptic-box,
  .const-card,
  .mnemo-box,
  .comparison-wrap {
    box-shadow: none !important;
    border: 1px solid #bbb !important;
    page-break-inside: avoid;
  }
  .sketchnote-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  body.memory-blur .memory-target {
    filter: none !important;
    background: transparent !important;
  }
}

/* Responsive mobile */
@media (max-width: 768px) {
  .notes-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
  }
  .notes-header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .notes-hero {
    padding: 20px 18px;
  }
  .notes-hero h1 {
    font-size: 1.7rem;
  }
  .sketchnote-grid {
    grid-template-columns: 1fr;
  }
}
