:root {
  --blue: #063f86;
  --blue-dark: #07336b;
  --teal: #08b9b2;
  --orange: #ff880c;
  --ink: #10294a;
  --muted: #536176;
}

* { box-sizing: border-box; }

html { min-height: 100%; -webkit-text-size-adjust: 100%; }

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  padding: clamp(22px, 4vw, 52px);
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background-color: #f7f7f7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%231e1b4b' stroke-width='.4' stroke-opacity='.1'%3E%3Cpath d='M50 0 62 38 100 50 62 62 50 100 38 62 0 50 38 38Z'/%3E%3Cpath d='m15 15 15 15m55-15L70 30M15 85l15-15m55 15L70 70'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100px 100px;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

button { font: inherit; }

.page {
  width: min(100%, 780px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.hero-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 720px);
  padding: clamp(39px, 5.4vw, 58px) clamp(22px, 5vw, 54px) clamp(33px, 4.5vw, 45px);
  border: 1px solid rgba(209, 221, 233, 0.82);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 58px rgba(15, 40, 72, 0.10);
  text-align: center;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--orange));
}

.brand-logo {
  display: block;
  width: min(82vw, 390px);
  max-width: 100%;
  height: auto;
  margin: 0 auto 16px;
  filter: drop-shadow(0 10px 14px rgba(6, 63, 134, 0.08));
}

h1 {
  margin: 0;
  color: var(--blue-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 5vw, 3.65rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.subtitle {
  margin: clamp(17px, 2.5vw, 23px) auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  letter-spacing: 0.01em;
}

.maths-scene {
  position: relative;
  width: min(100%, 500px);
  aspect-ratio: 560 / 205;
  margin: clamp(19px, 2.6vw, 25px) auto 0;
}

.scene-plate {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 6px 9px rgba(15, 40, 72, 0.055));
}

.scene-grid {
  position: absolute;
  inset: 8% 4.5%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-items: center;
}

.scene-link {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  outline: none;
}

.scene-link:nth-child(1) { transform: translateY(2%); }
.scene-link:nth-child(2) { transform: translateY(-3%); }
.scene-link:nth-child(3) { transform: translateY(2%); }
.scene-link:nth-child(4) { transform: translateY(-2%); }
.scene-link:nth-child(5) { transform: translateY(-8%); }
.scene-link:nth-child(6) { transform: translateY(-11%); }
.scene-link:nth-child(7) { transform: translateY(-7%); }
.scene-link:nth-child(8) { transform: translateY(-10%); }

.scene-item {
  width: min(var(--scene-icon-width, 84px), 88%);
  height: min(var(--scene-icon-height, 58px), 76%);
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 50%;
  transition: transform 0.18s ease;
}

.scene-item svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.scene-item-automatismes { --scene-icon-width: 55px; --scene-icon-height: 58px; }
.scene-item-nombres { --scene-icon-width: 80px; --scene-icon-height: 58px; }
.scene-item-algebre { --scene-icon-width: 51px; --scene-icon-height: 53px; }
.scene-item-proportionnalite { position: relative; left: -5%; --scene-icon-width: 96px; --scene-icon-height: 56px; }
.scene-item-geometrie { --scene-icon-width: 84px; --scene-icon-height: 49px; }
.scene-item-donnees { position: relative; left: 0; --scene-icon-width: 82px; --scene-icon-height: 56px; }
.scene-item-informatique { --scene-icon-width: 76px; --scene-icon-height: 57px; }
.scene-item-recherches { position: relative; left: -6%; --scene-icon-width: 62px; --scene-icon-height: 54px; }

.scene-link:hover .scene-item,
.scene-link:focus-visible .scene-item {
  transform: scale(1.12);
}

.scene-link:focus-visible {
  background: rgba(8, 185, 178, 0.1);
  box-shadow: inset 0 0 0 2px var(--teal);
}

.scene-link-disabled {
  cursor: default;
  opacity: 0.58;
}

.scene-link-disabled:hover .scene-item {
  transform: none;
}

.btn-start {
  min-width: min(100%, 300px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: clamp(19px, 2.5vw, 25px);
  padding: 16px 28px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(145deg, #0b55a5, #063f86);
  box-shadow: 0 15px 26px rgba(6, 63, 134, 0.2);
  text-decoration: none;
  font-size: 1.08rem;
  font-weight: 780;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 34px rgba(6, 63, 134, 0.26);
}

.btn-start svg { width: 20px; height: 20px; }

.home-footer {
  width: 100%;
  min-height: 24px;
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 6px;
  color: rgba(16, 41, 74, 0.52);
  font-size: 0.84rem;
  text-align: center;
  line-height: 1.5;
}

/* Sur tous les ordinateurs, y compris les portables peu hauts, les deux écrans
   d'entrée occupent exactement le même cadre. Le logo, la scène et le bouton
   conservent leur taille : seuls les espaces verticaux sont redistribués. */
@media (min-width: 921px) {
  .hero-card {
    height: var(--mathsgo-entry-card-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 38px;
    padding-bottom: 24px;
  }

  .hero-card > .home-footer {
    margin-top: auto;
  }
}

@media (min-width: 921px) and (max-height: 820px) {
  .hero-card {
    padding-top: 20px;
    padding-bottom: 18px;
  }
}

@media (min-width: 1600px) and (min-height: 1000px) {
  .hero-card {
    justify-content: space-between;
  }

  .hero-card > .home-footer {
    margin-top: 18px;
  }
}

/* Sur ordinateur, le bord supérieur du cadre reprend exactement le repère
   de la page des domaines. Le contenu peut ainsi s'ouvrir vers le bas sans
   que toute la composition saute au clic. */
@media (min-width: 921px) {
  body {
    justify-content: flex-start;
    padding-top: var(--mathsgo-entry-top);
  }
}

/* Jusqu'au format tablette, l'accueil reprend le même bord supérieur que
   l'en-tête du catalogue. Sa carte s'allonge uniquement vers le bas. */
@media (max-width: 920px) {
  body {
    justify-content: flex-start;
    padding-top: var(--mathsgo-entry-top);
  }

  .home-footer {
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }

  .footer-section-separator { display: none; }
}

.footer-row {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.contact-btn,
.footer-link {
  margin: 0;
  padding: 0;
  border: 0;
  color: rgba(6, 63, 134, 0.72);
  background: transparent;
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.footer-row-legal .footer-link {
  color: #526d8d;
  font-weight: 500;
}

.modal-overlay {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
}

.modal-overlay.is-open { display: flex; }

.modal-content {
  position: relative;
  width: 100%;
  max-width: 470px;
  max-height: min(90vh, 700px);
  overflow-y: auto;
  padding: 2.3rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28);
  text-align: left;
}

.close-modal {
  position: absolute;
  top: 14px;
  right: 18px;
  padding: 0;
  border: 0;
  color: #94a3b8;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.modal-content h2 { margin: 0 32px 12px; color: var(--blue-dark); font-size: 1.5rem; text-align: center; }
.modal-note { margin: 0 0 20px; color: #64748b; line-height: 1.5; text-align: center; }
.btn-send {
  width: 100%;
  display: inline-flex;
  justify-content: center;
  padding: 15px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #0b55a5, #063f86);
  text-decoration: none;
  font-weight: 760;
}

.contact-privacy-note { margin: 14px 0 0; color: #64748b; font-size: 0.8rem; line-height: 1.45; text-align: center; }

@media (max-width: 600px) {
  body {
    min-height: 100svh;
    padding: var(--mathsgo-entry-top) 12px 12px;
    justify-content: flex-start;
  }
  .page {
    min-height: 0;
    gap: 12px;
  }
  .hero-card {
    min-height: calc(100svh - var(--mathsgo-entry-top) - 12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 34px 14px max(24px, env(safe-area-inset-bottom));
    border-radius: 25px;
  }
  .brand-logo { width: min(82vw, 330px); margin-bottom: 0; }
  .subtitle,
  .maths-scene,
  .btn-start { margin-top: 0; }
  .maths-scene {
    width: calc(100% + 4px);
    aspect-ratio: 560 / 230;
  }
  .scene-grid { inset: 6% 3.5%; }
  .scene-item { transform: scale(1.1); }
  .scene-item-donnees {
    left: 4%;
    transform: scale(1);
  }
  .scene-item-geometrie { transform: scale(0.9); }
  .scene-item-recherches {
    left: -8%;
    transform: scale(0.92);
  }
  .scene-plate { transform: scale(1.08); transform-origin: center; }
  .home-footer {
    margin-top: 12px;
    padding-bottom: max(2px, env(safe-area-inset-bottom));
    font-size: clamp(0.73rem, 3.45vw, 0.84rem);
  }
  .footer-row {
    gap: clamp(4px, 1.8vw, 6px);
  }
  .modal-content { padding: 2rem 1.35rem 1.5rem; }
}

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