/* ==========================================================================
   MIRAI — Base, atmosphère organique & navigation flottante translucide
   Direction artistique : MOSS & STONE
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  position: relative;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-text);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Couche d'arrière-plan animée commune à toutes les pages (photo réseau neuronal en rotation lente) */
.bg-neural-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.bg-neural-layer__img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 165vmax;
  height: 165vmax;
  background: url("../assets/images/bg-neural.jpg") center / cover no-repeat;
  opacity: 0.56;
  transform-origin: center center;
  will-change: transform;
  animation: neuralBgSpin 110s linear infinite;
}

.bg-neural-layer__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(62% 45% at 50% 0%, rgba(78, 224, 181, 0.14) 0%, transparent 70%),
    linear-gradient(180deg, rgba(6, 10, 10, 0.42) 0%, rgba(6, 10, 10, 0.58) 55%, rgba(6, 10, 10, 0.72) 100%);
}

html.theme-clair .bg-neural-layer__img {
  opacity: 0.14;
  filter: invert(0.88) hue-rotate(155deg);
}

html.theme-clair .bg-neural-layer__veil {
  background:
    radial-gradient(60% 42% at 50% -6%, rgba(11, 110, 88, 0.08) 0%, transparent 72%),
    linear-gradient(180deg, rgba(243, 246, 245, 0.80) 0%, rgba(243, 246, 245, 0.88) 100%);
}

@keyframes neuralBgSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-neural-layer__img {
    animation: none !important;
    transform: translate(-50%, -50%) rotate(0deg);
  }
}

/* Fond neutre sur body::before (la couche dédiée .bg-neural-layer gère l'image animée) */
body::before {
  content: none;
}

html.theme-anim body,
html.theme-anim .nav-float {
  transition: background-color var(--dur-med) var(--ease), color var(--dur-med) var(--ease);
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.display {
  font-family: var(--f-display);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 75, "WONK" 1;
}

/* ---------- Sceau discret Mirai (未来) ---------- */
.hanko {
  display: inline-grid;
  place-items: center;
  width: var(--s, 36px);
  height: var(--s, 36px);
  border-radius: 10px;
  background: rgba(78, 224, 181, 0.14);
  border: 1px solid var(--border-glass);
  color: var(--accent-ink);
  font-family: var(--f-jp);
  font-weight: 500;
  writing-mode: vertical-rl;
  font-size: calc(var(--s, 36px) * 0.34);
  letter-spacing: 0.04em;
  line-height: 1;
  flex: none;
  user-select: none;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.hanko-link:hover .hanko {
  border-color: var(--accent-ink);
  background: rgba(78, 224, 181, 0.16);
}

/* ---------- Bandeaux d'alerte système ---------- */
.system-banners {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.sys-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.7rem var(--gutter);
  background: var(--surface-forest);
  color: var(--on-block);
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.88rem;
}

.sys-banner--warn {
  background: var(--signal);
  color: var(--on-signal);
}

.sys-banner__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ---------- Navigation supérieure plein-cadre à filet fin (spécification référence) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  padding: 0;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--hair);
  pointer-events: auto;
}

.nav-float {
  pointer-events: auto;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem var(--gutter);
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 0;
  box-shadow: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar__wordmark {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--dur-fast), background-color var(--dur-fast);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.is-active {
  color: var(--text);
  background: rgba(78, 224, 181, 0.10);
  box-shadow: inset 0 0 0 1px rgba(78, 224, 181, 0.25);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-btn {
  padding: 0.44rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  border: 1px solid var(--line);
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}

.nav-btn:hover {
  border-color: var(--accent-ink);
  background: var(--halo-sage);
}

.nav-btn--primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--on-signal);
  font-weight: 600;
}

.nav-btn--primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: #060A0A;
}

.nav-btn--busy {
  border-color: var(--accent-ink);
  background: var(--halo-sage);
  color: var(--text);
}

/* ---------- Conteneur principal ---------- */
.main-shell {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: calc(100vh - 96px);
}

/* ---------- En-tête d'espace (Tech, Opportunités, Bourses et études) ---------- */
.space-head {
  padding: clamp(1.8rem, 4vw, 3.25rem) var(--gutter) 1.5rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 1.25rem 2rem;
}

.space-head__kicker {
  color: var(--accent-sage-ink);
  margin-bottom: 0.55rem;
  display: block;
}

.space-head__title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  line-height: 0.94;
  letter-spacing: -0.03em;
  font-variation-settings: "SOFT" 60, "WONK" 1;
}

.space-head__title em {
  font-weight: 300;
  font-style: italic;
  color: var(--accent-ink);
}

.space-head__meta {
  text-align: right;
  color: var(--muted);
  display: grid;
  gap: 0.3rem;
}

.space-head__count {
  font-family: var(--f-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2rem, 3.8vw, 3rem);
  line-height: 1;
  color: var(--text);
}

/* ---------- Pied de page ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 2rem auto 0;
  padding: 1.5rem var(--gutter) 5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1.5rem;
  color: var(--muted);
  border-top: 1px solid var(--hair);
}

/* ---------- Toast d'annulation (action Écarter) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%) translateY(150%);
  visibility: hidden;
  pointer-events: none;
  z-index: 60;
  background: var(--surface-opaque);
  color: var(--text);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-deep);
  padding: 0.7rem 0.9rem 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: calc(100vw - 2rem);
  transition: transform var(--dur-med) var(--ease), visibility var(--dur-med);
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.toast__btn {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--signal);
  color: var(--on-signal);
  white-space: nowrap;
}

/* ---------- Responsive navigation ---------- */
@media (max-width: 900px) {
  .nav-float {
    grid-template-columns: auto 1fr;
    border-radius: var(--radius-lg);
    padding: 0.65rem 0.8rem;
    row-gap: 0.55rem;
  }
  .topbar__actions {
    justify-content: flex-end;
  }
  .nav-links {
    grid-column: 1 / -1;
    order: 3;
    justify-content: flex-start;
    padding-top: 0.5rem;
    border-top: 1px solid var(--hair);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar {
    display: none;
  }
  .space-head {
    grid-template-columns: 1fr;
  }
  .space-head__meta {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.5rem var(--gutter) 0.25rem;
  }
  .topbar__actions {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .nav-btn--desktop {
    display: none;
  }
  .nav-btn {
    padding: 0.34rem 0.56rem;
    font-size: 0.72rem;
  }
  .nav-link {
    padding: 0.38rem 0.58rem;
    font-size: 0.78rem;
  }
}

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