/* ============================================
   BASE — Reset, Typography, Utilities
   ============================================ */

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

html {
  scroll-behavior: smooth;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  opacity: 0;
  transition: opacity 0.18s ease;
}

body.app-ready {
  opacity: 1;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--color-primary-darker);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  font-weight: var(--fw-bold);
}

h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }

p {
  margin-bottom: var(--space-md);
  max-width: 70ch;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover { color: var(--color-primary-dark); }

img, video, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

ul, ol { list-style: none; }

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

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

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

.skip-link {
  position: fixed;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-primary-darker);
  color: var(--nd-white);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-weight: var(--fw-semibold);
  transition: top var(--duration-fast);
}

.skip-link:focus {
  top: 0;
  color: var(--nd-white);
}

:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--max-width-narrow); }
.container--wide { max-width: var(--max-width-wide); }

.section {
  padding-block: var(--space-section);
  position: relative;
}

.section--alt { background: var(--color-bg-alt); }

.section--dark {
  background: var(--color-bg-dark);
  color: var(--color-text-on-dark);
}

.section--dark h2,
.section--dark h3,
.section--dark h4 { color: var(--nd-white); }

/* --- Grid System --- */
.grid {
  display: grid;
  gap: var(--space-xl);
}

/* Tab panels : grid stacking — tous les panels occupent la même cellule,
   le conteneur garde la hauteur du plus grand. Pas de layout shift au switch. */
.tabs-panels {
  display: grid;
}

[data-tab-panel] {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

[data-tab-panel].active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Les panels qui sont aussi des grids gardent leur display:grid */
[data-tab-panel].grid { display: grid; }

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
}

/* --- Flex utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* --- Text utilities --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent-dark); }
.text-primary { color: var(--color-primary); }
.text-uppercase {
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

/* --- Section header pattern --- */
.section-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto var(--space-3xl);
}

.section-header__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
}

.section-header__label::before {
  content: '';
  width: 24px;
  height: 2px;
  background: var(--color-accent);
}

.section-header__title {
  margin-bottom: var(--space-md);
}

.section-header__desc {
  color: var(--color-text-muted);
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
  margin: 0 auto;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 28px;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  border-radius: var(--radius-full);
  transition: all var(--duration-base) var(--ease-out);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--nd-white);
  box-shadow: 0 4px 16px rgba(74,173,228,0.3);
}

.btn--primary:hover {
  background: var(--color-primary-dark);
  color: var(--nd-white);
  box-shadow: 0 6px 24px rgba(74,173,228,0.4);
  transform: translateY(-2px);
}

.btn--accent {
  background: var(--color-accent);
  color: var(--nd-blue-950);
  box-shadow: 0 4px 16px rgba(245,213,71,0.3);
}

.btn--accent:hover {
  background: var(--nd-gold-500);
  color: var(--nd-blue-950);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(245,213,71,0.4);
}

.btn--outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn--outline:hover {
  background: var(--color-primary);
  color: var(--nd-white);
  transform: translateY(-2px);
}

.btn--outline.active {
  background: var(--color-primary);
  color: var(--nd-white);
  box-shadow: 0 4px 16px rgba(74,173,228,0.3);
  border-color: var(--color-primary);
}

.btn--white {
  background: var(--nd-white);
  color: var(--color-primary-dark);
}

.btn--white:hover {
  background: var(--nd-blue-50);
  color: var(--color-primary-dark);
  transform: translateY(-2px);
}

.btn--lg {
  padding: 18px 36px;
  font-size: var(--fs-base);
}

.btn--sm {
  padding: 10px 20px;
  font-size: var(--fs-xs);
}

.btn__icon {
  width: 18px;
  height: 18px;
  transition: transform var(--duration-fast) var(--ease-out);
}

.btn:hover .btn__icon { transform: translateX(4px); }

/* --- Cards --- */
.card {
  background: var(--nd-white);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  transition: all var(--duration-base) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--nd-blue-200);
}

.card__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--nd-blue-50);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  color: var(--color-primary);
  font-size: 24px;
  transition: all var(--duration-base) var(--ease-out);
}

.card:hover .card__icon {
  background: var(--color-primary);
  color: var(--nd-white);
  transform: scale(1.05);
}

.card__title {
  font-size: var(--fs-lg);
  margin-bottom: var(--space-sm);
  color: var(--color-primary-darker);
}

.card__text {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}

/* --- Badge/Tag --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(74,173,228,0.1);
  color: var(--color-primary-dark);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border: 1px solid rgba(74,173,228,0.2);
}

.badge--gold {
  background: rgba(245,213,71,0.15);
  color: var(--nd-gold-600);
  border-color: rgba(245,213,71,0.3);
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Selection --- */
::selection {
  background: var(--nd-blue-200);
  color: var(--nd-blue-900);
}
