/* ================================================================
   HOME | Page-specific styles
   Desktop base, max-width queries step down.
================================================================ */

/* ================================================================
   STAFF | "L'équipe": four portraits in a row, one member open at a time.
   Desktop: the open portrait widens and its panel sits beside it.
   Below 1024px: the portraits are a row of tabs, the panel shows
   underneath. Below 600px: one complete card per member, the cards swipe.
================================================================ */
.staff-section {
  padding: var(--space-16) 0 var(--space-20);
}

.staff-section .section-header-centered {
  margin-bottom: var(--space-10);
}

.staff-row {
  --staff-gap: var(--space-4);
  --staff-grow: 3.6;              /* width of the open member, in closed members */
  --staff-photo-share: 0.44;      /* part of the open card held by the photo */
  --staff-unit: calc((100cqw - 3 * var(--staff-gap)) / (var(--staff-grow) + 3));
  --staff-open: calc(var(--staff-unit) * var(--staff-grow));
  container-type: inline-size;
  display: flex;
  gap: var(--staff-gap);
  height: clamp(500px, 58vh, 540px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.staff-member {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-2xl);
  background: var(--color-bg);
  box-shadow: 0 0 0 1px transparent;
  transition:
    flex-grow var(--transition-enter) var(--ease-silk),
    box-shadow var(--transition-slow) var(--ease-silk);
}

.staff-member.is-open {
  flex-grow: var(--staff-grow);
  box-shadow: 0 0 0 1px var(--color-border), var(--shadow-lg);
}

/* ---- Portrait (the button that opens the member) ---- */
.staff-photo {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-accent-light);
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition:
    width var(--transition-enter) var(--ease-silk),
    filter var(--transition-slow) var(--ease-silk),
    box-shadow var(--transition-base) var(--ease-out);
}

.staff-member.is-open .staff-photo {
  width: 44%;
  cursor: default;
}

.staff-photo:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -5px;
}

.staff-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
  transition: transform var(--transition-fluid) var(--ease-silk);
}

.staff-member:not(.is-open) .staff-photo:hover img {
  transform: scale(1.04);
}

/* Name and role on the closed portrait */
.staff-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-16) var(--space-4) var(--space-4);
  background: linear-gradient(to top, var(--overlay-dark-heavy) 0%, var(--overlay-dark) 38%, transparent 100%);
  color: var(--color-text-on-dark);
  transition: opacity var(--transition-base) var(--ease-out);
}

@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .staff-tag {
    background: linear-gradient(
      to top,
      color-mix(in srgb, var(--color-bg-dark) 92%, transparent) 0%,
      color-mix(in srgb, var(--color-bg-dark) 70%, transparent) 42%,
      transparent 100%
    );
  }
}

.staff-tag-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: var(--line-height-tight);
  letter-spacing: -0.01em;
}

.staff-tag-role {
  font-size: var(--text-xs);
  line-height: var(--line-height-snug);
  opacity: 0.86;
}

.staff-member.is-open .staff-tag {
  opacity: 0;
}

/* Plus mark: says the portrait opens */
.staff-plus {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transition:
    transform var(--transition-slow) var(--ease-elastic),
    opacity var(--transition-base) var(--ease-out),
    background var(--transition-base) var(--ease-out),
    color var(--transition-base) var(--ease-out);
}

.staff-plus svg {
  width: 16px;
  height: 16px;
}

.staff-photo:hover .staff-plus {
  background: var(--color-accent);
  color: var(--color-text-on-dark);
  transform: rotate(90deg);
}

.staff-member.is-open .staff-plus {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

/* ---- Panel (shown for the open member only) ---- */
.staff-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 44%;
  width: 56%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-8);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-fast) var(--ease-out),
    visibility 0s linear var(--transition-fast);
}

.staff-member.is-open .staff-panel {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--transition-slow) var(--ease-out) 260ms,
    visibility 0s;
}

/* The photo and the panel keep their open size while the card grows,
   so the text never reflows mid-transition. */
@supports (width: 1cqw) {
  .staff-photo {
    width: calc(var(--staff-unit) + 1px);
  }
  .staff-member.is-open .staff-photo {
    width: calc(var(--staff-open) * var(--staff-photo-share));
  }
  .staff-panel {
    left: calc(var(--staff-open) * var(--staff-photo-share));
    width: calc(var(--staff-open) * (1 - var(--staff-photo-share)));
  }
}

.staff-panel-main,
.staff-panel-creds {
  transform: translateY(14px);
  transition: transform var(--transition-enter) var(--ease-silk);
}

.staff-member.is-open .staff-panel-main,
.staff-member.is-open .staff-panel-creds {
  transform: none;
}

.staff-member.is-open .staff-panel-main  { transition-delay: 240ms; }
.staff-member.is-open .staff-panel-creds { transition-delay: 320ms; }

.staff-name {
  font-size: 1.75rem;
  margin: 0 0 var(--space-1);
}

.staff-role {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-snug);
  color: var(--color-gold-deep);
  margin: 0;
}

.staff-rule {
  display: block;
  width: 0;
  height: 1px;
  margin: var(--space-4) 0;
  background: var(--color-gold-deep);
  transition: width var(--transition-fluid) var(--ease-silk);
}

.staff-member.is-open .staff-rule {
  width: 40px;
  transition-delay: 420ms;
}

.staff-text {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--color-text-muted);
  margin: 0;
}

.staff-creds-label {
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-widest);
  line-height: var(--line-height-normal);
  text-transform: uppercase;
  color: var(--color-text-subtle);
  margin: 0 0 var(--space-2);
}

.staff-creds {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0 0 0 var(--space-4);
  border-left: 1px solid var(--color-border-strong);
  list-style: none;
}

.staff-creds li {
  font-size: var(--text-sm);
  line-height: var(--line-height-normal);
  color: var(--color-text);
}

.staff-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
  text-decoration: none;
}

.staff-link svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-base) var(--ease-brand);
}

.staff-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.staff-link:hover svg {
  transform: translateX(4px);
}

/* Position dots under the cards: phones only (built by staff.js) */
.staff-dots {
  display: none;
}

.staff-more {
  display: flex;
  justify-content: center;
  margin-top: var(--space-10);
}

/* ---- 1279px and below: tighter card ---- */
@media (max-width: 1279px) {
  .staff-row {
    --staff-gap: var(--space-3);
    --staff-grow: 3.8;
    --staff-photo-share: 0.4;
    height: 500px;
  }
  .staff-panel {
    gap: var(--space-4);
    padding: var(--space-6);
  }
  @supports not (width: 1cqw) {
    .staff-member.is-open .staff-photo { width: 40%; }
    .staff-panel { left: 40%; width: 60%; }
  }
  .staff-name { font-size: var(--text-2xl); }
  .staff-rule { margin: var(--space-3) 0; }
  .staff-text { font-size: var(--text-sm); }
  .staff-creds li { font-size: 0.8125rem; }
  .staff-tag { padding: var(--space-12) var(--space-3) var(--space-3); }
  .staff-tag-name { font-size: var(--text-base); }
}

/* ---- 1023px and below: portraits as a row of tabs, panel underneath ---- */
@media (max-width: 1023px) {
  .staff-section {
    padding: var(--space-12) 0 var(--space-16);
  }

  .staff-row {
    container-type: normal;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5) var(--space-3);
    height: auto;
  }

  /* The members dissolve: photos and panels are laid out by the row itself */
  .staff-member,
  .staff-member.is-open {
    display: contents;
  }

  .staff-member .staff-photo,
  .staff-member.is-open .staff-photo {
    position: relative;
    grid-row: 1;
    width: auto;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-xl);
    cursor: pointer;
  }

  .staff-member:not(.is-open) .staff-photo {
    filter: saturate(0.7) brightness(0.96);
  }

  .staff-member.is-open .staff-photo {
    box-shadow: 0 0 0 3px var(--color-bg-alt), 0 0 0 5px var(--color-accent);
  }

  .staff-member.is-open .staff-tag { opacity: 1; }
  .staff-plus { display: none; }

  /* The four panels share one cell, so the block keeps one height */
  .staff-member .staff-panel {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    grid-area: 2 / 1 / 3 / -1;
    width: auto;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: start;
    align-content: start;
    gap: var(--space-10);
    padding: var(--space-8);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-md);
  }

  .staff-member.is-open .staff-panel {
    transition:
      opacity var(--transition-slow) var(--ease-out) 80ms,
      visibility 0s;
  }

  .staff-panel-main,
  .staff-panel-creds { transform: translateY(8px); }
  .staff-member.is-open .staff-panel-main  { transition-delay: 60ms; }
  .staff-member.is-open .staff-panel-creds { transition-delay: 120ms; }
  .staff-member.is-open .staff-rule        { transition-delay: 200ms; }

  .staff-name { font-size: var(--text-3xl); }
  .staff-text { font-size: var(--text-base); }
  .staff-creds li { font-size: var(--text-sm); }
  .staff-link { min-height: 44px; margin-top: var(--space-2); }
}

/* ---- 767px and below: panel in one column ---- */
@media (max-width: 767px) {
  .staff-member .staff-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    padding: var(--space-6);
  }
  .staff-name { font-size: var(--text-2xl); }
  .staff-tag { padding: var(--space-10) var(--space-3) var(--space-3); }
  .staff-tag-name { font-size: 0.9375rem; }
  .staff-tag-role { font-size: 0.6875rem; }
}

/* ---- 599px and below: one complete card per member, the cards swipe.
        Photo, name and role on top, text and diplomas right under it,
        so nothing has to be read in a second place. ---- */
@media (max-width: 599px) {
  .staff-row {
    display: flex;
    align-items: stretch;
    gap: var(--space-3);
    margin: 0 calc(var(--space-5) * -1);
    padding: 6px 0 var(--space-3) var(--space-5);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-left: var(--space-5);
    scrollbar-width: none;
  }

  .staff-row::-webkit-scrollbar { display: none; }

  /* Room after the last card, so it can rest clear of the screen edge */
  .staff-row::after {
    content: '';
    flex: 0 0 var(--space-2);
  }

  .staff-member,
  .staff-member.is-open {
    display: flex;
    flex: 0 0 84vw;
    flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-sm);
    scroll-snap-align: start;
  }

  .staff-member .staff-photo,
  .staff-member.is-open .staff-photo {
    flex: none;
    aspect-ratio: 16 / 10;
    border-radius: 0;
    box-shadow: none;
    cursor: default;
  }

  .staff-member:not(.is-open) .staff-photo { filter: none; }

  /* Each face sits in the upper part of its wide crop */
  .staff-member:nth-child(1) .staff-photo img { object-position: 50% 2%; }
  .staff-member:nth-child(2) .staff-photo img { object-position: 50% 21%; }
  .staff-member:nth-child(3) .staff-photo img { object-position: 50% 13%; }
  .staff-member:nth-child(4) .staff-photo img { object-position: 50% 15%; }

  .staff-tag { padding: var(--space-10) var(--space-5) var(--space-3); }
  .staff-tag-name { font-size: var(--text-xl); }
  .staff-tag-role { font-size: var(--text-xs); }

  .staff-member .staff-panel,
  .staff-member.is-open .staff-panel {
    position: static;
    grid-area: auto;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transition: none;
  }

  .staff-panel-main,
  .staff-panel-creds {
    transform: none;
    transition: none;
  }

  /* Name and role are on the photo; the heading stays for screen readers */
  .staff-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .staff-role,
  .staff-rule { display: none; }

  .staff-text { font-size: 0.9375rem; }

  /* The link rests at the foot of the card, whatever the length above it */
  .staff-panel-creds {
    display: flex;
    flex: 1;
    flex-direction: column;
  }

  .staff-link {
    margin-top: auto;
    padding-top: var(--space-3);
  }

  .staff-dots {
    display: flex;
    justify-content: center;
  }

  .staff-dot {
    display: grid;
    place-items: center;
    width: 32px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .staff-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-border-strong);
    transition:
      width var(--transition-base) var(--ease-out),
      background var(--transition-base) var(--ease-out);
  }

  .staff-dot.is-active::before {
    width: 22px;
    background: var(--color-accent);
  }

  .staff-more { margin-top: var(--space-4); }
}
