/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, sans-serif;
  background-color: #f4f6f9;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 60px;
  padding-top: 96px;
  color: #1a1a2e;
}

/* ── Header ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #dde3eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 500;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
}
.logo-icon { font-size: 22px; color: #3a6fa8; }
.logo-text { font-family: Georgia, serif; font-size: 20px; font-weight: 400; color: #1a1a2e; }
.logo-text strong { font-weight: 700; color: #3a6fa8; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-nav a {
  font-size: 13px;
  color: #555;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.header-nav a:hover { background: #f0f4f8; color: #3a6fa8; }

/* Cours links live in the header on desktop */
.header-cours {
  display: flex;
  gap: 6px;
  margin-right: 12px;
}
.header-cours a {
  font-size: 13px;
  color: #3a6fa8;
  text-decoration: none;
  border: 1px solid #b8d0ea;
  border-radius: 6px;
  padding: 4px 12px;
  background: #f0f6ff;
  transition: background 0.15s, border-color 0.15s;
}
.header-cours a:hover { background: #ddeeff; border-color: #3a6fa8; }

/* ── Page title ── */
h1 {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 6px;
}

/* ── Timer ── */
#timer {
  font-size: 17px;
  color: #444;
  background: #e8ecf2;
  border-radius: 20px;
  padding: 6px 20px;
  margin-bottom: 24px;
  letter-spacing: 0.3px;
}
#timer.urgent {
  color: #c0392b;
  animation: pulse 0.6s infinite alternate;
}
@keyframes pulse {
  from { opacity: 1; }
  to   { opacity: 0.35; }
}

/* ── Class buttons (hidden on desktop, shown on mobile) ── */
#classButtons {
  display: none;
}

/* ── Instruction text ── */
.instruction {
  text-align: center;
  font-size: 16px;
  color: #666;
  margin-bottom: 16px;
}

/* ── Period buttons ── */
#periodButtons {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  justify-content: center;
}

#periodButtons button {
  font-size: 15px;
  padding: 9px 20px;
  cursor: pointer;
  border: 1.5px solid #c8d4e0;
  border-radius: 8px;
  background: #fff;
  color: #333;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#periodButtons button:hover {
  background: #f0f6ff;
  border-color: #3a6fa8;
}
#periodButtons button.selected {
  background: #3a6fa8;
  border-color: #2d5a8a;
  color: #fff;
  font-weight: bold;
}

#start {
  font-size: 15px;
  padding: 9px 28px;
  background: #2ecc71;
  border-color: #27ae60;
  color: #fff;
  font-weight: bold;
}
#start:hover { background: #27ae60; }

/* ── Table ── */
table {
  border-collapse: collapse;
  width: 100%;
  max-width: 640px;
  margin-bottom: 24px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 8px rgba(0,0,0,0.07);
}
th, td {
  border: 1px solid #dde3eb;
  padding: 12px 18px;
  font-size: 15px;
  text-align: left;
}
th {
  background-color: #eaf1fb;
  color: #1a1a2e;
  font-weight: 600;
}
input[type="number"] {
  font-size: 15px;
  padding: 6px 10px;
  width: 130px;
  border: 1px solid #c8d4e0;
  border-radius: 6px;
}

/* Row feedback */
tr.row-correct td { background-color: #d4edda; }
tr.row-wrong td { background-color: #f8d7da; }
.correct-hint {
  font-weight: bold;
  color: #27ae60;
  margin-left: 6px;
  font-size: 13px;
}

/* ── Score ── */
#scoreArea {
  margin: 16px 0;
  text-align: center;
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
#scoreTitle { font-size: 15px; color: #555; margin-bottom: 6px; }
#scoreValue {
  font-size: 48px;
  font-weight: bold;
  color: #333;
  transition: color 0.3s;
}
#scoreValue.score-positive { color: #27ae60; }
#scoreValue.score-negative { color: #c0392b; }
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
#scoreValue.score-pop { animation: pop 0.4s ease; }

/* ── Footer ── */
footer {
  margin-top: 48px;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
footer a {
  color: #777;
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 2px;
  transition: color 0.15s;
}
footer a:hover { color: #333; }

/* ── Cookie banner ── */
#cookieBanner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #d0d8e4;
  border-radius: 10px;
  padding: 14px 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 1000;
}
#cookieBanner p { margin: 0; color: #444; }
#cookieButtons { display: flex; gap: 8px; }
#cookieButtons button {
  font-size: 13px;
  padding: 5px 14px;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid #bbb;
}
#cookieButtons button.reject {
  background: #fff;
  color: #666;
}

/* ── Sub-pages ── */
.page-content {
  max-width: 700px;
  width: 100%;
  background: #fff;
  border: 1px solid #dde3eb;
  border-radius: 10px;
  padding: 36px 40px;
  margin-top: 20px;
  line-height: 1.7;
  font-size: 15px;
  color: #333;
}
.page-content h1 { font-size: 24px; margin-bottom: 20px; }
.page-content h2 { font-size: 16px; margin-top: 24px; margin-bottom: 8px; color: #222; }
.page-content p, .page-content ul { margin-bottom: 12px; }
.page-content ul { padding-left: 20px; }
.back-link {
  margin-top: 28px;
  display: inline-block;
  font-size: 14px;
  color: #555;
  text-decoration: none;
  border-bottom: 1px solid #bbb;
}
.back-link:hover { color: #222; }

/* ════════════════════════════════
   MOBILE — ≤ 640px
   ════════════════════════════════ */
@media (max-width: 640px) {

  body {
    padding: 80px 12px 60px;
    background: #f0f4ff;
  }

  /* Header simplifié sur mobile */
  .site-header { padding: 0 16px; }
  .logo-text { font-size: 17px; }
  .header-cours { display: none; } /* les boutons cours vont dans la page */
  .header-nav a { padding: 4px 8px; font-size: 12px; }

  h1 { font-size: 22px; margin-bottom: 4px; }

  #timer {
    font-size: 16px;
    padding: 7px 18px;
    margin-bottom: 16px;
  }

  /* Boutons cours visibles sur mobile, colorés */
  #classButtons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
  }
  #classButtons a {
    display: block;
    text-align: center;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    padding: 14px;
    border-radius: 12px;
    color: #fff;
    transition: opacity 0.2s;
  }
  #classButtons a:nth-child(1) { background: #3a6fa8; }
  #classButtons a:nth-child(2) { background: #e67e22; }
  #classButtons a:nth-child(3) { background: #8e44ad; }
  #classButtons a:active { opacity: 0.8; }

  /* Boutons période pleine largeur */
  #periodButtons {
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
  }
  #periodButtons button {
    width: 100%;
    font-size: 17px;
    padding: 14px;
    border-radius: 10px;
    border: none;
    background: #e8edf5;
    color: #1a1a2e;
  }
  #periodButtons button.selected {
    background: #3a6fa8;
    color: #fff;
  }
  #start {
    width: 100%;
    font-size: 18px;
    padding: 16px;
    border-radius: 10px;
    border: none;
    background: #2ecc71;
    color: #fff;
  }

  /* Tableau grand et tactile */
  table {
    width: 100%;
    max-width: 100%;
    font-size: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  }
  th, td {
    padding: 14px 12px;
    font-size: 15px;
  }
  th:first-child, td:first-child { width: 55%; }
  th:last-child, td:last-child { width: 45%; }

  input[type="number"] {
    width: 100%;
    font-size: 18px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 2px solid #3a6fa8;
    text-align: center;
    -moz-appearance: textfield;
  }
  input[type="number"]::-webkit-inner-spin-button,
  input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
  }

  #scoreValue { font-size: 40px; }

  /* Cookie banner pleine largeur sur mobile */
  #cookieBanner {
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    border-radius: 10px 10px 0 0;
    flex-direction: column;
    align-items: flex-start;
    white-space: normal;
    gap: 10px;
    padding: 16px;
  }

  footer {
    gap: 14px;
    margin-top: 32px;
  }
  footer a { font-size: 12px; }
}