/*
  Mandiéval — Thème brun, ambiance médiévale
  Palette
    --bg: #f5e6cc (parchemin)
    --text: #2b211b (brun foncé)
    --brown-900: #3b2a23
    --brown-800: #4e342e
    --brown-600: #7b4f37
    --brown-400: #b08968
    --accent: #d4a373
*/
:root {
  --bg: #f5e6cc;
  --text: #2b211b;
  --brown-900: #3b2a23;
  --brown-800: #4e342e;
  --brown-700: #5d3a2a;
  --brown-600: #7b4f37;
  --brown-500: #8d5a3a;
  --brown-400: #b08968;
  --accent: #d4a373;
  --paper-shadow: 0 10px 30px rgba(43, 33, 27, 0.25);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Lora', ui-serif, Georgia, serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(139, 89, 51, 0.08), transparent 50%),
    radial-gradient(800px 400px at 100% 10%, rgba(139, 89, 51, 0.08), transparent 50%),
    linear-gradient(rgba(245, 230, 204, 0.94), rgba(245, 230, 204, 0.94)),
    url('../img/background.png'),
    var(--bg);
  background-repeat: no-repeat, no-repeat, no-repeat, repeat, no-repeat;
  line-height: 1.6;
}

main { flex: 1 0 auto; }

h1, h2, h3 {
  font-family: 'Enchanted Land', 'MedievalSharp', cursive;
}

.container {
  width: min(1100px, 92%);
  margin-inline: auto;
}

/* Header & Nav */
.site-header {
  background: linear-gradient(180deg, var(--brown-900), var(--brown-800));
  color: #fdf8f2;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #fdf8f2;
  text-decoration: none;
}
.brand-logo { height: 68px; width: auto; display: block; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.2)); }
.brand-text {
  font-family: 'Enchanted Land', 'MedievalSharp', cursive;
  letter-spacing: 0.5px;
  font-size: 2.45rem;
}
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.site-nav li.nav-cta { margin-left: auto; }
.site-nav a {
  color: #f9efe6;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
}
.site-nav a.btn {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
}
.site-nav a:hover,
.site-nav a.active {
  background: rgba(255, 255, 255, 0.12);
}
.site-nav a.admin-link {
  color: var(--accent);
  font-weight: 800;
}

.avatar-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
  color: #fdf8f2;
  text-decoration: none;
}
.avatar-pill:hover { background: rgba(255,255,255,0.14); }
.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  background: var(--accent);
  color: var(--brown-900);
  border: 1px solid rgba(43,33,27,0.25);
}
.avatar-name { font-weight: 700; }

.nav-toggle { display: none; }

/* Hero */
.hero {
  position: relative;
  padding: 4rem 0 calc(48px + 0.4rem);
  background: transparent;
}
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  height: 48px;
  background: url('../img/separator.png') center/min(920px, 92%) 100% no-repeat;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 1.2rem;
}
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}
.hero-visual img {
  width: min(420px, 100%);
  height: auto;
  filter: drop-shadow(0 20px 30px rgba(43,33,27,0.2));
}
.display {
  font-family: 'Enchanted Land', 'MedievalSharp', cursive;
  font-size: clamp(3.3rem, 6vw + 1.5rem, 5.1rem);
  line-height: 1.1;
  margin: 0 0 0.8rem;
}
.lead { font-size: 1.125rem; max-width: 62ch; }
.cta-row { margin-top: 1.2rem; display: flex; gap: 0.8rem; flex-wrap: wrap; }

/* Sections */
.section { padding: 2.5rem 0; }
.section-title {
  font-family: 'Enchanted Land', 'MedievalSharp', cursive;
  margin: 0 0 1rem;
  font-size: 2.7rem;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.card {
  background: #fff9ef;
  border: 1px solid rgba(43, 33, 27, 0.1);
  border-radius: 14px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--paper-shadow);
  position: relative;
}

/* Défis: réserve de la place pour le bouton "play" */
#challenges .card {
  padding-bottom: calc(1.1rem + 44px);
}
.card h3 { margin: 0 0 0.25rem; font-size: 1.65rem; }
.card .meta { color: #5c4a40; font-size: 0.9rem; }

.meta { color: #5c4a40; font-size: 0.9rem; }

.challenge-action {
  position: absolute;
  top: auto;
  right: 12px;
  bottom: 12px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(43, 33, 27, 0.18);
  background: var(--accent);
  color: var(--brown-900);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.challenge-action:hover { filter: brightness(0.98); }
.challenge-action[disabled] { opacity: 0.6; cursor: not-allowed; }
.challenge-action-icon { font-size: 16px; line-height: 1; transform: translateX(1px); }

.challenge-action--validated {
  background: #2e7d32;
  border-color: #1b5e20;
  color: #fff;
}

.challenge-action--validated:hover { filter: none; }
.challenge-action--validated[disabled] { opacity: 1; cursor: default; }

.card-spaced + .card-spaced { margin-top: 10px; }

/* Buttons & chips */
.btn {
  display: inline-block;
  background: #fff;
  color: var(--brown-800);
  border: 2px solid var(--brown-400);
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}
.btn:hover { background: #fff3e0; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--brown-400));
  border-color: var(--brown-600);
  color: #281a14;
}
.btn-primary:hover { filter: brightness(0.97); }

.btn-danger {
  border-color: #8b0000;
  color: #8b0000;
}

.btn-danger:hover {
  background: #fff3e0;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

/* Forms */
.field { margin: 0 0 1rem; }
.field label { font-weight: 700; }
.input {
  width: 100%;
  padding: 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(43, 33, 27, 0.15);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
.input:focus { outline: none; }
.input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.error-text {
  margin: 0.4rem 0 0.9rem;
  font-weight: 700;
  color: #8b0000;
}

/* Page hero */
.page-hero { padding: 2.8rem 0 1.2rem; }

/* Filters */
.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chip {
  background: #fff;
  color: var(--brown-800);
  border: 1px solid rgba(43, 33, 27, 0.15);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}
.chip.active, .chip:hover { background: #fde9cf; border-color: var(--brown-400); }

/* Admin table (gestion défis) */
.admin-table-wrap {
  overflow-x: auto;
  background: #fff9ef;
  border: 1px solid rgba(43, 33, 27, 0.10);
  border-radius: 14px;
  box-shadow: var(--paper-shadow);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: fixed;
}

.admin-table th:nth-child(1),
.admin-table td:nth-child(1) { width: 150px; }

.admin-table th:nth-child(2),
.admin-table td:nth-child(2) { width: 180px; }

.admin-table th:nth-child(4),
.admin-table td:nth-child(4) { width: 190px; }

.admin-table th:nth-child(5),
.admin-table td:nth-child(5) { width: 190px; }

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(43, 33, 27, 0.10);
  vertical-align: top;
}

.admin-table th {
  position: sticky;
  top: 0;
  background: #fff9ef;
  text-align: left;
  font-weight: 800;
  color: var(--brown-900);
}

.admin-table tbody tr:hover { background: #fff3e0; }
.admin-table tbody tr:last-child td { border-bottom: 0; }

.admin-challenge {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.admin-challenge-id {
  flex: 0 0 auto;
}

.admin-challenge-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Prose */
.prose h2 { font-family: 'Enchanted Land', 'MedievalSharp', cursive; font-size: 2.25rem; margin-top: 0; }
.prose ul { padding-left: 1.2rem; }
.divider { display: block; width: 60%; height: auto; margin: 1.2rem auto; }
.team { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
.person {
  position: relative;
  width: 380px;
  height: 380px;
  background: url('../img/cadre-bois.jpg') center no-repeat;
  background-size: 380px 380px;
  background-color: transparent;
}
.person h3 {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.25rem 0.6rem;
  font-family: 'Enchanted Land', 'MedievalSharp', cursive;
  font-size: 1.8rem;
  color: #fdf8f2;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(43,33,27,0.35), 0 2px 6px rgba(0,0,0,0.25);
}
.person img {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
.member{display:flex;flex-direction:column;align-items:center}
.member .role{margin-top:.4rem;color:var(--brown-900);font-size:.95rem;text-align:center}

/* Footer */
.site-footer {
  border-top: 2px solid rgba(0,0,0,0.06);
  background: #f2dfc3;
}
.footer-inner { padding: 1rem 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.small { font-size: 0.92rem; color: #5c4a40; }
.social { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.social a { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; background: #fff9ef; border: 1px solid rgba(43,33,27,0.10); }
.social a:hover { background: #fde9cf; }
.social svg { width: 18px; height: 18px; fill: var(--brown-700); }

/* Calendar embed (responsive) */
.calendar-embed {
  display: flex;
  justify-content: center;
}
.calendar-embed .iframe-wrap {
  position: relative;
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 4 / 3; /* 800x600 baseline */
  border: 1px solid rgba(43,33,27,0.15);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--paper-shadow);
}
.calendar-embed .iframe-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Mobile nav */
@media (max-width: 800px) {
  .site-nav { display: none; }
  .nav-toggle { display: inline-block; background: transparent; color: #fdf8f2; border: 1px solid rgba(255,255,255,0.35); padding: 0.4rem 0.6rem; border-radius: 8px; }
  .site-nav.open { display: block; position: absolute; top: 100%; right: 4%; left: 4%; background: #3b2a23; border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; }
  .site-nav.open ul { flex-direction: column; padding: 0.5rem; }
  .site-nav.open a { display: block; }
  .site-nav.open li.nav-cta { margin-left: 0; }
}

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { margin-top: 1rem; }
}

/* Focus styles */
:where(a, button, .chip, .btn):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Modal (confirmation) */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(43, 33, 27, 0.55);
  z-index: 2000;
}

.modal {
  width: min(520px, 100%);
  background: #fff9ef;
  border: 1px solid rgba(43, 33, 27, 0.12);
  border-radius: 14px;
  box-shadow: var(--paper-shadow);
  padding: 1rem;
}

.modal-title {
  margin: 0 0 0.35rem;
  font-size: 1.8rem;
}

.modal-text { margin: 0; color: #5c4a40; }

.modal-actions {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
