@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Palette — "catalogue de bibliothèque" */
  --ink: #16213e;          
  --ink-soft: #24304f;     
  --paper: #faf8f3;        
  --paper-card: #ffffff;   
  --gold: #b8863b;         
  --gold-soft: #d9b877;    
  --text-primary: #1a1a2e;
  --text-muted: #6b7280;
  --text-on-ink: #e9e6dd;
  --border: #e6e1d6;
  --border-ink: rgba(233, 230, 221, 0.12);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
}

body {
  background: var(--paper);
  height: 100vh;
  overflow: hidden;
  color: var(--text-primary);
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: var(--paper);
}

/*  SIDEBAR GAUCHE  */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--ink);
  border-right: 1px solid var(--border-ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 28px 22px 18px 22px;
  border-bottom: 1px solid var(--border-ink);
  background: var(--ink);
}

.sidebar-header h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-on-ink);
  margin-bottom: 18px;
  letter-spacing: -0.3px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--gold-soft);
  font-size: 0.85rem;
  opacity: 0.8;
}

#search {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: 7px;
  border: 1px solid var(--border-ink);
  font-size: 0.88rem;
  outline: none;
  transition: 0.2s;
  background: var(--ink-soft);
  color: var(--text-on-ink);
}

#search:focus {
  border-color: var(--gold);
  background: var(--ink-soft);
  box-shadow: 0 0 0 3px rgba(184, 134, 59, 0.18);
}

#search::placeholder {
  color: rgba(233, 230, 221, 0.45);
}

#tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px 24px 12px;
  background: var(--ink);
}

#tree-container::-webkit-scrollbar {
  width: 6px;
}

#tree-container::-webkit-scrollbar-track {
  background: transparent;
}

#tree-container::-webkit-scrollbar-thumb {
  background: rgba(233, 230, 221, 0.18);
  border-radius: 10px;
}

/*  ARBORESCENCE  */
.category {
  margin-bottom: 4px;
}

.category-header {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: 0.15s;
  user-select: none;
  gap: 10px;
}

.category-header:hover {
  background: var(--ink-soft);
}

.category-icon {
  font-size: 0.95rem;
  width: 24px;
  text-align: center;
  color: var(--gold-soft);
  flex-shrink: 0;
}

.category-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-on-ink);
  letter-spacing: 0.1px;
}

.category-toggle {
  font-size: 0.7rem;
  color: rgba(233, 230, 221, 0.5);
  transition: transform 0.25s;
  margin-left: auto;
}

.category-toggle.rotated {
  transform: rotate(90deg);
  color: var(--gold-soft);
}

.category-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
  padding-left: 8px;
}

.category-content.open {
  max-height: 2000px;
}

/* sous-catégories  */
.subcategory {
  margin: 6px 0 6px 12px;
  padding-left: 14px;
  border-left: 2px solid rgba(184, 134, 59, 0.3);
}

.subcategory-name {
  font-weight: 700;
  font-size: 0.68rem;
  color: var(--gold-soft);
  padding: 6px 8px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.link-item {
  display: block;
  padding: 6px 10px 6px 20px;
  margin: 1px 0;
  border-radius: 4px;
  color: rgba(233, 230, 221, 0.75);
  text-decoration: none;
  font-size: 0.88rem;
  cursor: pointer;
  transition: 0.15s;
  position: relative;
}

.link-item::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(233, 230, 221, 0.3);
}

.link-item:hover {
  background: var(--ink-soft);
  color: var(--gold-soft);
}

.link-item.active {
  background: rgba(184, 134, 59, 0.16);
  color: var(--text-on-ink);
  border-left: 2px solid var(--gold);
  padding-left: 18px;
  font-weight: 500;
}

.link-item.active::before {
  background: var(--gold);
}

/*  PANEL DROIT  */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  height: 100vh;
  overflow: hidden;
}

.content-header {
  padding: 26px 40px;
  background: var(--paper-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.breadcrumb {
  margin-bottom: 12px;
}

#breadcrumb-path {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.module-badge {
  display: inline-block;
  background: rgba(184, 134, 59, 0.12);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

#page-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

#page-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 400;
}

.content-body {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  background: var(--paper);
}

.content-body::-webkit-scrollbar {
  width: 6px;
}

.content-body::-webkit-scrollbar-track {
  background: transparent;
}

.content-body::-webkit-scrollbar-thumb {
  background: #d1cabb;
  border-radius: 10px;
}

/*  MESSAGE D'ACCUEIL  */
.welcome-message {
  text-align: center;
  padding: 70px 20px;
  max-width: 600px;
  margin: 0 auto;
}

.welcome-message h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
}

.welcome-message p {
  color: var(--text-muted);
  font-size: 1rem;
}

.quick-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 36px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat i {
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 6px;
}

.stat span {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
}

.stat small {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

/*  AFFICHAGE DU CONTENU  */
.content-display-content {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 1px 2px rgba(22, 33, 62, 0.04), 0 8px 24px rgba(22, 33, 62, 0.04);
}

.content-display-content iframe {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.content-display-content .link-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.content-display-content .link-actions a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.content-display-content .link-actions a:hover {
  text-decoration: underline;
}

/*  CARTE DE SECOURS  */
.external-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 32px;
  background: var(--paper);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.external-link-card-icon {
  font-size: 2.6rem;
  color: var(--gold);
  margin-bottom: 18px;
}

.external-link-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.external-link-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 380px;
  margin-bottom: 22px;
}

.external-link-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--text-on-ink);
  padding: 10px 22px;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: 0.2s;
}

.external-link-card-btn:hover {
  background: var(--gold);
  color: var(--ink);
}

/*  FOOTER */
.app-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px 16px 18px;
  background: var(--ink);
  border-top: 1px solid var(--border-ink);
}

.app-footer-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-footer-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ecf8e;
  box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.6);
  animation: pulse-status 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-status {
  0% {
    box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.55);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(62, 207, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(62, 207, 142, 0);
  }
}

.app-footer-text {
  font-size: 0.76rem;
  color: rgba(233, 230, 221, 0.8);
  font-weight: 500;
  letter-spacing: 0.1px;
}

.app-footer-heart {
  color: var(--gold);
  font-size: 0.7rem;
  margin: 0 1px;
}

.app-footer-brand {
  color: var(--gold-soft);
  text-decoration: none;
  font-weight: 700;
}

.app-footer-brand:hover {
  text-decoration: underline;
}

.app-footer-version {
  font-family: 'Courier New', monospace;
  font-size: 0.66rem;
  color: rgba(233, 230, 221, 0.45);
  border-left: 1px solid var(--border-ink);
  padding-left: 9px;
  margin-left: 2px;
  letter-spacing: 0.3px;
}

.app-footer-bio {
  font-size: 0.72rem;
  line-height: 1.5;
  color: rgba(233, 230, 221, 0.55);
  font-style: italic;
  padding-left: 17px;
  border-left: 2px solid rgba(184, 134, 59, 0.3);
  margin-left: 3px;
}

.app-footer-socials {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  padding-left: 17px;
}

.app-footer-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: rgba(233, 230, 221, 0.55);
  background: transparent;
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.app-footer-social-link:hover {
  background: rgba(184, 134, 59, 0.16);
  color: var(--gold-soft);
  transform: translateY(-1px);
}

.app-footer-social-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

/*  ACCESSIBILITÉ  */
a:focus-visible,
button:focus-visible,
.link-item:focus-visible,
.category-header:focus-visible,
#search:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

/*  PAGE D'INTRODUCTION  */
.intro-page {
  padding: 20px 10px;
  animation: fadeIn 0.5s ease;
}

.intro-page h1 {
  font-size: 2rem;
  color: #1a1a2e;
  margin-bottom: 16px;
  font-weight: 700;
}

.intro-page p {
  font-size: 1.05rem;
  color: #495057;
  line-height: 1.8;
  margin-bottom: 24px;
}

.intro-page strong {
  color: #e67e22;
}

.intro-objectives {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 24px 28px;
  margin: 24px 0;
  border-left: 4px solid #e67e22;
}

.intro-objectives h2 {
  font-size: 1.2rem;
  color: #1a1a2e;
  margin-bottom: 12px;
}

.intro-objectives ul {
  list-style: none;
  padding: 0;
}

.intro-objectives ul li {
  padding: 6px 0;
  color: #495057;
  font-size: 0.95rem;
}

.intro-objectives ul li::before {
  content: "▸ ";
  color: #e67e22;
  font-weight: bold;
}

.intro-quote {
  background: linear-gradient(135deg, #2d3436 0%, #1a1a2e 100%);
  border-radius: 12px;
  padding: 24px 28px;
  margin-top: 24px;
  text-align: center;
}

.intro-quote blockquote {
  color: white;
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 300;
  line-height: 1.6;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*  MENU BURGER  */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--ink);
  border: 1px solid var(--border-ink);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(22, 33, 62, 0.25);
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--gold-soft);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.sidebar-toggle.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.sidebar-toggle.active span:nth-child(2) {
  opacity: 0;
}
.sidebar-toggle.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 62, 0.45);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/*  RESPONSIVE   */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 280px;
    min-width: 280px;
  }
  .content-header,
  .content-body {
    padding-left: 28px;
    padding-right: 28px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 320px;
    max-height: 100vh;
    min-width: unset;
    z-index: 180;
    border-right: none;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 8px 0 30px rgba(22, 33, 62, 0.3);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-panel {
    width: 100%;
  }

  .content-header {
    padding: 16px 76px 16px 20px; 
  }

  #page-title {
    font-size: 1.5rem;
  }

  .content-body {
    padding: 16px 20px;
  }

  .content-display-content iframe {
    height: 300px;
  }

  .quick-stats {
    gap: 20px;
  }

  .link-item {
    padding: 10px 10px 10px 20px;
    font-size: 0.95rem;
  }

  .category-header {
    padding: 12px;
  }
}

@media (max-width: 380px) {
  .quick-stats {
    flex-wrap: wrap;
    gap: 20px;
  }
  .content-display-content {
    padding: 20px;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .sidebar {
    max-height: 100vh;
  }
  .content-header {
    padding: 12px 76px 12px 20px;
  }
}