/* Couche visuelle commune aux quatre pages */
:root {
  --ease-premium: cubic-bezier(.22, 1, .36, 1);
  --switcher-bg: rgba(10, 9, 14, .82);
  --switcher-border: rgba(255, 255, 255, .13);
  --glow: rgba(139, 131, 255, .12);
  --oral-bg: #0b0a0f;
}

body[data-theme="maths"] {
  --glow: rgba(242, 170, 76, .14);
}

body[data-theme="nsi"] {
  --glow: rgba(139, 131, 255, .14);
}

body[data-layout="oral"] {
  background:
    linear-gradient(180deg, #0b0a0f 0%, #121017 48%, #0b0a0f 100%);
}

body {
  --pointer-x: 50vw;
  --pointer-y: 30vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  z-index: -2;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  animation: oral-grid-drift 44s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--pointer-x) var(--pointer-y), var(--glow), transparent 72%);
  animation: oral-glow-breathe 9s ease-in-out infinite;
}

.oral-ambient-layer {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  overflow: hidden;
}

.oral-ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: .38;
  animation: oral-orb-float 16s ease-in-out infinite;
}

.oral-ambient-orb--violet {
  width: 380px;
  height: 380px;
  top: -6%;
  right: -4%;
  background: rgba(139, 131, 255, .42);
}

.oral-ambient-orb--peach {
  width: 320px;
  height: 320px;
  bottom: 6%;
  left: -6%;
  background: rgba(239, 169, 157, .32);
  animation-delay: -5s;
  animation-duration: 19s;
}

.oral-ambient-orb--teal {
  width: 260px;
  height: 260px;
  top: 42%;
  left: 40%;
  background: rgba(51, 214, 193, .24);
  animation-delay: -9s;
  animation-duration: 22s;
}

.oral-ambient-grid {
  position: absolute;
  inset: -15%;
  opacity: .1;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 68px 68px;
  animation: oral-grid-drift 52s linear infinite reverse;
}

@keyframes oral-grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-68px, -44px, 0); }
}

@keyframes oral-glow-breathe {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}

@keyframes oral-orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -20px) scale(1.06); }
  66% { transform: translate(-18px, 14px) scale(.96); }
}

.scroll-progress {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--accent2));
  box-shadow: 0 0 18px color-mix(in srgb, var(--primary) 70%, transparent);
}

.site-switcher {
  position: fixed;
  z-index: 900;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  color: var(--text, #1a1a2e);
  background: var(--switcher-bg);
  border: 1px solid var(--switcher-border);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .18);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.site-switcher__brand,
.site-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 9px;
  text-decoration: none;
}

.site-switcher__brand {
  width: 34px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 30%, transparent);
}

.site-switcher a {
  padding: 0 11px;
  color: rgba(255, 255, 255, .68);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
  transition: color .25s, background .25s, transform .25s;
}

.site-switcher a:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  transform: translateY(-1px);
}

.site-switcher a[aria-current="page"] {
  color: #fff;
  background: color-mix(in srgb, var(--primary) 25%, transparent);
}

.back-to-top {
  position: fixed;
  z-index: 850;
  right: 22px;
  bottom: 22px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  color: #fff;
  background: color-mix(in srgb, var(--surface, #171729) 82%, transparent);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .22);
  backdrop-filter: blur(16px);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .3s, visibility .3s, transform .3s, background .3s;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--primary);
  transform: translateY(-3px);
}

/* Pages d'oral */
body[data-layout="oral"] .hero {
  isolation: isolate;
  overflow: hidden;
}

body[data-layout="oral"] .hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: .23;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 92%);
  transform: translate3d(0, var(--hero-shift, 0), 0);
  animation: oral-grid-drift 40s linear infinite;
}

body[data-layout="oral"] .hero h1,
body[data-layout="oral"] .hero .subtitle,
body[data-layout="oral"] .hero .tags {
  animation: hero-in .9s var(--ease-premium) both;
}

body[data-layout="oral"] .hero .subtitle { animation-delay: .12s; }
body[data-layout="oral"] .hero .tags { animation-delay: .22s; }

body[data-layout="oral"] .hero .tags span,
body[data-layout="oral"] .hero .tags a {
  transition: transform .25s var(--ease-premium), border-color .25s, box-shadow .25s;
}

body[data-layout="oral"] .hero .tags span:hover,
body[data-layout="oral"] .hero .tags a:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--primary) 42%, transparent);
  box-shadow: 0 12px 25px rgba(0, 0, 0, .14);
}

@keyframes hero-in {
  from { opacity: 0; transform: translateY(24px); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

body[data-layout="oral"] nav {
  transition: box-shadow .3s, background .3s;
}

body[data-layout="oral"] nav.is-scrolled {
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
}

body[data-layout="oral"] nav a {
  position: relative;
}

body[data-layout="oral"] nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
  opacity: 0;
  transform: translateX(-50%) scaleX(.3);
  transition: opacity .25s, transform .25s;
}

body[data-layout="oral"] nav a.is-active {
  color: var(--text);
  background: var(--surface);
}

body[data-layout="oral"] nav a.is-active::after {
  opacity: 1;
  transform: translateX(-50%) scaleX(1);
}

body[data-layout="oral"] .section {
  position: relative;
}

body[data-layout="oral"] .section::before {
  content: "";
  position: absolute;
  top: 7rem;
  bottom: 0;
  left: -42px;
  width: 1px;
  background: linear-gradient(var(--primary), transparent);
  opacity: .25;
}

body[data-layout="oral"] .box,
body[data-layout="oral"] .proof-box,
body[data-layout="oral"] .anecdote,
body[data-layout="oral"] .conclusion-box,
body[data-layout="oral"] .card-def {
  position: relative;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .12);
  transition: transform .35s var(--ease-premium), border-color .35s, box-shadow .35s;
  transform-style: preserve-3d;
}

body[data-layout="oral"] .box::after,
body[data-layout="oral"] .proof-box::after,
body[data-layout="oral"] .conclusion-box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 20%, rgba(255,255,255,.045), transparent 70%);
  transform: translateX(-100%);
  transition: transform .8s var(--ease-premium);
}

body[data-layout="oral"] .box:hover,
body[data-layout="oral"] .proof-box:hover,
body[data-layout="oral"] .anecdote:hover,
body[data-layout="oral"] .card-def:hover {
  border-color: color-mix(in srgb, var(--primary) 38%, transparent);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .2);
}

body[data-layout="oral"] .box:hover::after,
body[data-layout="oral"] .proof-box:hover::after,
body[data-layout="oral"] .conclusion-box:hover::after {
  transform: translateX(100%);
}

body[data-layout="oral"] .section-number {
  box-shadow: 0 9px 24px color-mix(in srgb, var(--primary) 28%, transparent);
}

body[data-layout="oral"] .bar-fill {
  transform-origin: left;
}

.js body[data-layout="oral"] .bar-chart .bar-fill {
  transform: scaleX(0);
  transition: transform 1s var(--ease-premium);
}

.js body[data-layout="oral"] .bar-chart.in-view .bar-fill {
  transform: scaleX(1);
}

.js .reveal {
  opacity: 0;
  transform: translateY(32px);
  filter: blur(6px);
  transition:
    opacity .75s var(--ease-premium),
    transform .75s var(--ease-premium),
    filter .75s var(--ease-premium);
  transition-delay: var(--reveal-delay, 0ms);
}

.js .reveal.in-view {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* Pages de plan */
body[data-layout="plan"] {
  --text: #1a1a2e;
  --surface: #fff;
  --switcher-bg: rgba(255, 255, 255, .78);
  --switcher-border: rgba(25, 25, 45, .1);
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 5%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 28rem),
    radial-gradient(circle at 95% 20%, color-mix(in srgb, var(--accent, var(--primary)) 12%, transparent), transparent 25rem),
    #f6f7fb;
  background-attachment: fixed;
}

body[data-layout="plan"] .site-switcher a {
  color: #67677a;
}

body[data-layout="plan"] .site-switcher a:hover,
body[data-layout="plan"] .site-switcher a[aria-current="page"] {
  color: #171724;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

body[data-layout="plan"] .container {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: 0 30px 90px rgba(36, 33, 73, .13);
}

body[data-layout="plan"] .container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--accent, var(--primary)), var(--accent2, var(--primary)));
}

body[data-layout="plan"] h1 {
  background: linear-gradient(120deg, #111127, var(--primary));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

body[data-layout="plan"] h2 {
  position: relative;
  border-left-color: var(--primary);
}

body[data-layout="plan"] .card,
body[data-layout="plan"] .proof-mini {
  transition: transform .3s var(--ease-premium), box-shadow .3s, border-color .3s;
}

body[data-layout="plan"] .card:hover,
body[data-layout="plan"] .proof-mini:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(35, 30, 80, .09);
}

body[data-layout="plan"] .btn-back,
body[data-layout="plan"] .subh a {
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 25%, transparent);
  transition: transform .25s, box-shadow .25s;
}

body[data-layout="plan"] .btn-back:hover,
body[data-layout="plan"] .subh a:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px color-mix(in srgb, var(--primary) 32%, transparent);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 65%, white);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  body[data-layout="oral"] .section::before { display: none; }
}

@media (max-width: 640px) {
  body[data-layout] {
    padding-bottom: calc(5.8rem + env(safe-area-inset-bottom));
  }

  .site-switcher {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    justify-content: center;
    min-height: 56px;
    padding: 6px;
    border-radius: 18px;
  }

  .site-switcher__brand { display: none; }
  .site-switcher a {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 4px;
    font-size: .72rem;
  }

  .back-to-top {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(5.7rem + env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
  }

  body[data-layout="oral"] .hero {
    min-height: 100svh;
    padding: 4.5rem 1.1rem 7rem;
  }

  body[data-layout="oral"] nav {
    top: 0;
    padding-inline: .45rem;
  }

  body[data-layout="oral"] nav ul {
    justify-content: flex-start;
    gap: .15rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-padding-inline: 1rem;
  }

  body[data-layout="oral"] nav ul::-webkit-scrollbar {
    display: none;
  }

  body[data-layout="oral"] nav ul li a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: .55rem .8rem;
  }

  body[data-layout="oral"] .scroll-down {
    bottom: calc(5.8rem + env(safe-area-inset-bottom));
  }

  body[data-layout="oral"] .section {
    padding-inline: 1rem;
  }

  body[data-layout="oral"] .section-header {
    align-items: flex-start;
    margin-bottom: 1.8rem;
  }

  body[data-layout="oral"] .box,
  body[data-layout="oral"] .proof-box,
  body[data-layout="oral"] .conclusion-box,
  body[data-layout="oral"] .anecdote,
  body[data-layout="oral"] .card-def {
    padding-inline: 1rem;
    border-radius: 14px;
  }

  body[data-layout="oral"] .table-wrap,
  body[data-layout="oral"] .code-block {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  body[data-layout="oral"] table {
    min-width: 520px;
  }

  body[data-layout="oral"] .code-block {
    padding: 1rem;
    font-size: .77rem;
  }

  body[data-layout="oral"] .bar-row {
    gap: .45rem;
  }

  body[data-layout="oral"] .bar-label {
    width: 58px;
    font-size: .78rem;
  }

  body[data-layout="oral"] footer {
    padding-bottom: 1.5rem;
  }

  body[data-layout="plan"] {
    padding-top: 1rem;
  }

  body[data-layout="plan"] .container {
    padding: 1.35rem 1rem;
    border-radius: 16px;
  }

  body[data-layout="plan"] .subh {
    align-items: flex-start !important;
  }

  body[data-layout="plan"] .subh a {
    min-height: 44px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  body[data-layout="plan"] h1 {
    font-size: clamp(1.4rem, 7vw, 1.8rem);
  }

  body[data-layout="plan"] h2 {
    font-size: 1.02rem;
    line-height: 1.35;
  }

  body[data-layout="plan"] .card {
    padding: .9rem;
  }

  body[data-layout="plan"] .mini-table {
    table-layout: fixed;
  }

  body[data-layout="plan"] .mini-table td {
    vertical-align: top;
    overflow-wrap: anywhere;
  }

  body[data-layout="plan"] .mini-table td:first-child {
    width: 5.6rem;
  }
}

@media (max-width: 380px) {
  .site-switcher a {
    font-size: .66rem;
    letter-spacing: 0;
  }

  body[data-layout="oral"] .hero h1 {
    font-size: 2rem;
  }

  body[data-layout="oral"] .hero .tags {
    gap: .45rem;
  }

  body[data-layout="oral"] .hero .tags span,
  body[data-layout="oral"] .hero .tags a {
    padding: .4rem .75rem !important;
    font-size: .75rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
