/* ==========================================================
   KAMB — Thème parchemin vintage
   ========================================================== */

/* --- Google Fonts : MedievalSharp pour les titres --- */
@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&display=swap');

/* --- Fond parchemin global --- */
body,
[data-md-color-scheme="default"] {
  --md-default-bg-color: #f4e8c1;
  --md-default-fg-color: #3e2723;
}

/* --- Titres fantasy --- */
h1, h2, h3, h4, h5, h6,
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-family: 'MedievalSharp', cursive;
  color: #4e342e;
}

/* --- Conteneur principal : style vieux papier --- */
.md-main__inner {
  background-color: #faf3e0;
  border-left: 2px solid #c9b68e;
  border-right: 2px solid #c9b68e;
  box-shadow: 4px 4px 12px rgba(62, 39, 35, 0.15);
}

.md-content {
  padding: 1.2rem;
}

/* --- Navigation & header assortis --- */
.md-header {
  background-color: #4e342e;
}

.md-tabs {
  background-color: #5d4037;
}

/* --- Admonition : GLOIRE AU ROI TORG ! (danger) --- */
.md-typeset .admonition.danger,
.md-typeset details.danger {
  border-color: #8b0000;
  background-color: #f5e0dc;
}

.md-typeset .danger > .admonition-title,
.md-typeset .danger > summary {
  background-color: rgba(139, 0, 0, 0.15);
  border-color: #8b0000;
}

.md-typeset .danger > .admonition-title::before,
.md-typeset .danger > summary::before {
  color: #8b0000;
}

/* --- Admonition : Astuce de Kobold (tip) --- */
.md-typeset .admonition.tip,
.md-typeset details.tip {
  border-color: #2e5e1e;
  background-color: #e8f0e0;
}

.md-typeset .tip > .admonition-title,
.md-typeset .tip > summary {
  background-color: rgba(46, 94, 30, 0.15);
  border-color: #2e5e1e;
}

.md-typeset .tip > .admonition-title::before,
.md-typeset .tip > summary::before {
  color: #2e5e1e;
}

/* --- Admonition : Le Bourgmestre prévient (warning) --- */
.md-typeset .admonition.warning,
.md-typeset details.warning {
  border-color: #bf6900;
  background-color: #fdf0db;
}

.md-typeset .warning > .admonition-title,
.md-typeset .warning > summary {
  background-color: rgba(191, 105, 0, 0.15);
  border-color: #bf6900;
}

.md-typeset .warning > .admonition-title::before,
.md-typeset .warning > summary::before {
  color: #bf6900;
}

/* --- Admonition : Mort Horrible (failure) --- */
.md-typeset .admonition.failure,
.md-typeset details.failure {
  border-color: #4a0000;
  background-color: #f5d0d0;
}

.md-typeset .failure > .admonition-title,
.md-typeset .failure > summary {
  background-color: rgba(74, 0, 0, 0.15);
  border-color: #4a0000;
}

.md-typeset .failure > .admonition-title::before,
.md-typeset .failure > summary::before {
  color: #4a0000;
}

/* --- Liens assortis au thème --- */
.md-typeset a {
  color: #6d4c41;
}

.md-typeset a:hover {
  color: #bf360c;
}

/* --- Tables : style parchemin --- */
.md-typeset table:not([class]) th {
  background-color: #d7cba8;
  color: #3e2723;
}

.md-typeset table:not([class]) tr:nth-child(even) {
  background-color: #f0e6c8;
}

/* --- Footer --- */
.md-footer {
  background-color: #4e342e;
}

/* --- Sidebar navigation --- */
.md-sidebar {
  background-color: #f4e8c1;
}

.md-nav__link:hover,
.md-nav__link--active {
  color: #bf360c;
}

/* ==========================================================
   KAMB — Styles outils interactifs
   ========================================================== */

/* --- Conteneur outil --- */
.kamb-tool {
  max-width: 900px;
  margin: 0 auto;
}

.kamb-tool h3 {
  font-family: 'MedievalSharp', cursive;
  color: #4e342e;
  margin: 1.2rem 0 0.5rem;
  font-size: 1.2rem;
  border-bottom: 1px solid #c9b68e;
  padding-bottom: 0.3rem;
}

.kamb-tool h4 {
  font-family: 'MedievalSharp', cursive;
  color: #4e342e;
  font-size: 1rem;
  margin: 0.5rem 0 0.3rem;
}

.kamb-section {
  margin-bottom: 1.2rem;
}

/* --- Boutons --- */
.kamb-btn {
  font-family: 'MedievalSharp', cursive;
  background: #5d4037;
  color: #faf3e0;
  border: 1px solid #4e342e;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
  white-space: nowrap;
}
.kamb-btn:hover { background: #4e342e; }

.kamb-btn-accent {
  background: #bf360c;
  border-color: #8b0000;
}
.kamb-btn-accent:hover { background: #8b0000; }

.kamb-btn-danger {
  background: #8b0000;
  border-color: #4a0000;
}
.kamb-btn-danger:hover { background: #4a0000; }

.kamb-btn-small {
  padding: 0.15rem 0.5rem;
  font-size: 0.85rem;
}

.kamb-btn-remove {
  background: #8b0000;
  border-color: #4a0000;
  padding: 0.1rem 0.4rem;
  font-size: 1rem;
  line-height: 1;
  font-family: sans-serif;
}

/* --- Edition toggle --- */
.kamb-edition-toggle {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.kamb-btn-edition {
  flex: 1;
  text-align: center;
  opacity: 0.6;
}
.kamb-btn-edition.active {
  opacity: 1;
  background: #bf360c;
  border-color: #8b0000;
}

/* --- Inputs --- */
.kamb-input {
  font-family: Roboto, sans-serif;
  padding: 0.35rem 0.5rem;
  border: 1px solid #c9b68e;
  border-radius: 4px;
  background: #faf3e0;
  color: #3e2723;
  font-size: 0.9rem;
}
.kamb-input:focus {
  outline: 2px solid #bf360c;
  outline-offset: -1px;
}

.kamb-input-sm { width: 5rem; }

.kamb-name-input { flex: 1; min-width: 0; }

.kamb-select {
  font-family: Roboto, sans-serif;
  padding: 0.35rem 0.5rem;
  border: 1px solid #c9b68e;
  border-radius: 4px;
  background: #faf3e0;
  color: #3e2723;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
}

/* --- Rows --- */
.kamb-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* --- Stat grid --- */
.kamb-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.kamb-secondary-grid {
  grid-template-columns: repeat(5, 1fr);
}

.kamb-stat-card {
  text-align: center;
  background: #f0e6c8;
  border: 1px solid #c9b68e;
  border-radius: 6px;
  padding: 0.4rem;
}

.kamb-stat-label {
  display: block;
  font-family: 'MedievalSharp', cursive;
  font-size: 0.75rem;
  color: #5d4037;
  margin-bottom: 0.2rem;
}

.kamb-stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: bold;
  color: #4e342e;
  min-height: 1.6rem;
  outline: none;
}

.kamb-stat-value:focus {
  background: #faf3e0;
  border-radius: 3px;
}

.kamb-stat-secondary .kamb-stat-value {
  font-size: 1.1rem;
}

/* --- Dice animations --- */
@keyframes kamb-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(2deg); }
}

@keyframes kamb-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.kamb-dice-rolling {
  animation: kamb-shake 0.1s infinite;
  color: #bf360c;
}

.kamb-dice-landed {
  animation: kamb-pulse 0.3s ease-out;
  color: #2e5e1e;
}

/* --- Skills --- */
.kamb-skill-columns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
}

.kamb-skill-col h4 {
  font-size: 0.85rem;
}

.kamb-skill-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.1rem 0;
}

.kamb-skill-row input[type="checkbox"] {
  accent-color: #bf360c;
}

.kamb-skill-counter {
  font-family: 'MedievalSharp', cursive;
  font-size: 1rem;
  color: #2e5e1e;
  margin-bottom: 0.3rem;
}

.kamb-skill-counter.kamb-warn {
  color: #8b0000;
  font-weight: bold;
}

/* --- Traits --- */
.kamb-traits-fixed {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.kamb-trait {
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: help;
}

.kamb-atout {
  background: #e8f0e0;
  border: 1px solid #2e5e1e;
  color: #2e5e1e;
}

.kamb-tare {
  background: #f5d0d0;
  border: 1px solid #8b0000;
  color: #8b0000;
}

.kamb-trait-row { margin-bottom: 0.4rem; }

.kamb-trait-result {
  font-size: 0.9rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  min-width: 8rem;
}

/* --- Equipment --- */
.kamb-equip-row { margin-bottom: 0.4rem; }

.kamb-equip-result {
  font-size: 0.9rem;
  color: #3e2723;
}

.kamb-pattes {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}
.kamb-pattes .kamb-input { flex: 1; min-width: 8rem; }

/* --- Death register --- */
.kamb-death-row {
  margin-bottom: 0.3rem;
}

.kamb-marque-value {
  font-size: 1.1rem;
  font-weight: bold;
  color: #4e342e;
  min-width: 1.5rem;
  text-align: center;
  display: inline-block;
}

.kamb-death-result {
  font-family: 'MedievalSharp', cursive;
  font-size: 1rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.3rem;
}

.kamb-death-result.kamb-dead {
  background: #f5d0d0;
  color: #8b0000;
  border: 1px solid #8b0000;
}

.kamb-death-result.kamb-alive {
  background: #e8f0e0;
  color: #2e5e1e;
  border: 1px solid #2e5e1e;
}

/* --- Actions --- */
.kamb-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  padding-top: 0.5rem;
  border-top: 1px solid #c9b68e;
}

/* --- Tabs (bestiaire) --- */
.kamb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.kamb-tab {
  font-family: 'MedievalSharp', cursive;
  background: #f0e6c8;
  color: #5d4037;
  border: 1px solid #c9b68e;
  padding: 0.3rem 0.7rem;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.kamb-tab:hover { background: #d7cba8; }

.kamb-tab.active {
  background: #5d4037;
  color: #faf3e0;
  border-color: #4e342e;
}

.kamb-sub-toggle {
  margin-bottom: 0.5rem;
}

/* --- Tables (bestiaire) --- */
.kamb-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.8rem;
}

.kamb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.kamb-table th {
  background: #d7cba8;
  color: #3e2723;
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 2px solid #c9b68e;
  white-space: nowrap;
}

.kamb-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #e0d5b0;
}

.kamb-table tr:nth-child(even) {
  background: #f0e6c8;
}

.kamb-table tr:hover {
  background: #e8dfc0;
}

.kamb-name-cell {
  font-weight: bold;
  white-space: nowrap;
}

.kamb-row-highlight {
  background: #fdf0db !important;
  outline: 2px solid #bf360c;
}

/* --- M/B badges --- */
.kamb-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: bold;
  font-size: 0.8rem;
}

.kamb-badge-m {
  background: #f5d0d0;
  color: #8b0000;
}

.kamb-badge-b {
  background: #e8f0e0;
  color: #2e5e1e;
}

/* --- Roll result --- */
.kamb-roll-result {
  font-family: 'MedievalSharp', cursive;
  font-size: 1rem;
  padding: 0.3rem 0.5rem;
  margin: 0.3rem 0;
  border-radius: 4px;
  min-height: 1.5rem;
}

.kamb-roll-result.kamb-highlight {
  background: #fdf0db;
  border: 1px solid #bf6900;
  color: #4e342e;
}

/* --- Search --- */
.kamb-search {
  width: 100%;
  max-width: 20rem;
}

/* --- Details (sous-table) --- */
.kamb-details {
  margin-top: 0.8rem;
  border: 1px solid #c9b68e;
  border-radius: 4px;
  padding: 0.5rem;
  background: #f0e6c8;
}

.kamb-details summary {
  font-family: 'MedievalSharp', cursive;
  color: #4e342e;
  cursor: pointer;
  font-size: 0.95rem;
}

/* --- Combat cards --- */
.kamb-combat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.kamb-card {
  background: #faf3e0;
  border: 2px solid #c9b68e;
  border-radius: 8px;
  padding: 0.8rem;
  box-shadow: 2px 2px 8px rgba(62, 39, 35, 0.1);
  position: relative;
  transition: opacity 0.3s;
}

.kamb-card-dead {
  opacity: 0.6;
  border-color: #8b0000;
}

.kamb-card-dead-overlay {
  text-align: center;
  font-family: 'MedievalSharp', cursive;
  font-size: 1.2rem;
  color: #8b0000;
  padding: 0.3rem;
  margin-bottom: 0.3rem;
}

.kamb-skull {
  font-size: 1.5rem;
}

.kamb-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.kamb-card-name {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.1rem;
  color: #4e342e;
  flex: 1;
}

.kamb-card-deg {
  font-size: 0.8rem;
  background: #f5d0d0;
  color: #8b0000;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.kamb-counter-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
}

.kamb-counter-label {
  font-size: 0.85rem;
  min-width: 4rem;
}

.kamb-counter-value {
  font-weight: bold;
  font-size: 0.95rem;
  min-width: 4rem;
  text-align: center;
}

.kamb-dmg-row {
  margin: 0.4rem 0;
}

.kamb-marq-row {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.kamb-notes-row {
  margin-top: 0.3rem;
}

.kamb-notes-input {
  width: 100%;
  font-size: 0.8rem;
}

.kamb-custom-row .kamb-input { min-width: 0; }
.kamb-custom-row .kamb-input:first-child { flex: 2; }

.kamb-combat-reset {
  display: block;
  margin: 1rem auto 0;
}

/* --- Responsive --- */
@media (max-width: 700px) {
  .kamb-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kamb-secondary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .kamb-skill-columns {
    grid-template-columns: repeat(2, 1fr);
  }
  .kamb-tabs {
    gap: 0.2rem;
  }
  .kamb-tab {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
  }
  .kamb-combat-cards {
    grid-template-columns: 1fr;
  }
}
