/*
 * Socle commun de toutes les pages (Institute et livre) : polices, couleurs,
 * en-tête, focus clavier. Classes préfixées « pi- » pour ne pas se mélanger aux
 * styles des pages.
 */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/eb-garamond.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/eb-garamond-italic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --pi-navy: #072c50;
  --pi-navy-700: #0c3a68;
  --pi-teal: #05a9a4;
  --pi-teal-700: #047a76;
  --pi-gold: #c8873b;
  --pi-ink: #14273b;
  --pi-muted: #5b6b7b;
  --pi-line: #e3e9ef;
  --pi-line-strong: #cdd8e2;
  --pi-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --pi-serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --pi-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --pi-container: 1200px;
  --pi-gutter: clamp(18px, 4vw, 40px);
  --pi-shadow-sm: 0 1px 2px rgba(7, 44, 80, 0.06), 0 6px 18px rgba(7, 44, 80, 0.05);
  --pi-shadow-md: 0 2px 4px rgba(7, 44, 80, 0.05), 0 16px 38px rgba(7, 44, 80, 0.1);
  --pi-shadow-lg: 0 6px 14px rgba(7, 44, 80, 0.06), 0 34px 70px rgba(7, 44, 80, 0.16);
}

/* Focus clavier visible et cohérent partout */
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid rgba(5, 169, 164, 0.55);
  outline-offset: 3px;
}

/* ───────────────────────── En-tête ───────────────────────── */
.pi-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--pi-line);
  color: var(--pi-ink);
  font: 16px/1.6 var(--pi-sans);
  transition: box-shadow 0.3s var(--pi-ease), background-color 0.3s;
}
.pi-header.is-scrolled {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 0 rgba(7, 44, 80, 0.04), 0 12px 32px -14px rgba(7, 44, 80, 0.22);
}
/* Pages du livre : en-tête fixe, la page se place dessous (--header-h) */
.pi-header--fixed {
  position: fixed;
  inset: 0 0 auto;
}
.pi-header__inner {
  max-width: var(--pi-container);
  margin: auto;
  padding: 10px var(--pi-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.pi-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: 12px;
}
.pi-brand img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}
.pi-brand__title {
  display: block;
  font-weight: 700;
  letter-spacing: 0.005em;
  font-size: 1.15rem;
  line-height: 1.25;
}
.pi-brand__sub {
  display: block;
  max-width: 215px;
  margin-top: 1px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--pi-muted);
}
.pi-nav {
  order: 1;
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}
.pi-nav__link {
  position: relative;
  padding: 9px 10px;
  border-radius: 999px;
  color: #3d5063;
  font: 600 0.84rem/1.2 var(--pi-sans);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
}
.pi-nav__link::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 14px;
  right: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--pi-teal);
  transform: scaleX(0);
  transition: transform 0.25s var(--pi-ease);
}
.pi-nav__link:hover {
  color: var(--pi-navy);
  background: rgba(7, 44, 80, 0.06);
}
.pi-nav__link[aria-current='page'] {
  color: var(--pi-navy);
}
.pi-nav__link[aria-current='page']::after {
  transform: scaleX(1);
}
/* « Contact » : action principale du menu */
.pi-nav__link:last-child {
  margin-left: 6px;
  padding: 10px 20px;
  background: var(--pi-navy);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(7, 44, 80, 0.7);
}
.pi-nav__link:last-child::after {
  display: none;
}
.pi-nav__link:last-child:hover {
  background: var(--pi-navy-700);
  color: #fff;
  transform: translateY(-1px);
}
.pi-nav__link:last-child[aria-current='page'] {
  background: var(--pi-teal-700);
}

/* Panier */
.pi-cart {
  order: 2;
  position: relative;
  appearance: none;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--pi-line-strong);
  border-radius: 50%;
  background: #fff;
  color: var(--pi-navy);
  font: 600 0.83rem/1.2 var(--pi-sans);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s;
}
.pi-cart:hover {
  border-color: var(--pi-navy);
  box-shadow: 0 8px 18px -10px rgba(7, 44, 80, 0.5);
  transform: translateY(-1px);
}
.pi-cart:active {
  transform: none;
}
.pi-cart .cart-icon {
  position: relative;
  display: grid;
  place-items: center;
}
.pi-cart .cart-icon svg {
  width: 20px;
  height: 20px;
}
.pi-cart .cart-button__count {
  position: absolute;
  top: -8px;
  right: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--pi-teal-700);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px #fff;
}
.pi-cart__label {
  display: none;
}

/* Bouton du menu (mobile) */
.pi-menu-toggle {
  order: 3;
  display: none;
}

@media (max-width: 1180px) {
  .pi-brand {
    flex: 1;
  }
  .pi-nav {
    order: 4;
    flex-basis: 100%;
    justify-content: flex-start;
    gap: 2px;
    margin-left: 0;
    padding-top: 4px;
    border-top: 1px solid var(--pi-line);
  }
  .pi-nav__link:last-child {
    margin-left: auto;
  }
}
@media (max-width: 760px) {
  .pi-header__inner {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .pi-brand img {
    width: 48px;
    height: 48px;
  }
  .pi-brand__sub {
    display: none;
  }
  .pi-menu-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--pi-line-strong);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
  }
  .pi-menu-toggle:hover {
    border-color: var(--pi-navy);
  }
  .pi-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--pi-navy);
    transition: transform 0.25s var(--pi-ease), opacity 0.2s;
  }
  .pi-menu-toggle[aria-expanded='true'] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .pi-menu-toggle[aria-expanded='true'] span:nth-child(2) {
    opacity: 0;
  }
  .pi-menu-toggle[aria-expanded='true'] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  .pi-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 2px;
    max-height: calc(100vh - 90px);
    overflow: auto;
    margin: 6px 0 0;
    padding: 10px 0 12px;
  }
  .pi-nav.is-open {
    display: flex;
    animation: pi-menu-in 0.28s var(--pi-ease);
  }
  .pi-nav__link {
    padding: 14px 14px;
    border-radius: 12px;
    font-size: 1rem;
    white-space: normal;
  }
  .pi-nav__link[aria-current='page'] {
    background: #eaf6f6;
    color: var(--pi-navy);
  }
  .pi-nav__link::after {
    display: none;
  }
  .pi-nav__link:last-child {
    margin: 8px 0 0;
    text-align: center;
  }
}
@keyframes pi-menu-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}
.pi-header [hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .pi-header *,
  .pi-nav {
    animation: none !important;
    transition: none !important;
  }
}
