/*
 * Header fixe Arkarun (logo à gauche, recherche au centre, bouton Download à droite).
 * Partagé par la home (variante "overlay" sur photo) et les profils publics (variante "solid").
 * Aucun style inline : la CSP du site (style-src 'self') les bloque.
 */

:root {
  --sh-height: 76px;
  --sh-font-bold: "Futura-Bold", "Futura", "Futura PT", "Century Gothic", "Avenir Next", "Trebuchet MS", sans-serif;
  --sh-font-medium: "Futura-Medium", "Futura", "Futura PT", "Century Gothic", "Avenir Next", "Trebuchet MS", sans-serif;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--sh-height) + env(safe-area-inset-top));
  padding:
    env(safe-area-inset-top)
    max(24px, env(safe-area-inset-right))
    0
    max(24px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr minmax(0, 328px) 1fr;
  align-items: center;
  column-gap: 16px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

/* Colonnes latérales : jamais étirées, quel que soit le contenu. */
.site-header > :first-child {
  justify-self: start;
}

.site-header > :last-child {
  justify-self: end;
  width: max-content;
  max-width: 100%;
}

.sh-logo {
  justify-self: start;
  display: block;
  line-height: 0;
}

.sh-logo img {
  width: 46px;
  height: 46px;
  display: block;
  object-fit: contain;
}

/* ---------- Recherche ---------- */

.sh-search {
  position: relative;
  width: 100%;
}

.sh-search input {
  display: block;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0 44px 0 18px;
  border: 0;
  border-radius: 999px;
  font-family: var(--sh-font-medium);
  font-size: 16px; /* 16px minimum : évite le zoom automatique d'iOS au focus */
  line-height: 36px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.sh-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.sh-search input:focus-visible {
  box-shadow: 0 0 0 2px currentColor;
}

/* Loupe à droite du champ */
.sh-search-btn {
  position: absolute;
  top: 0;
  right: 5px;
  width: 40px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.sh-search-btn svg {
  display: block;
}

.sh-search-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

/* ---------- Suggestions ---------- */

.sh-suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(360px, 60svh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border-radius: 18px;
  background: #fff;
  color: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
}

.sh-suggest[hidden] {
  display: none;
}

.sh-suggest a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.sh-suggest a:hover,
.sh-suggest a[aria-selected="true"] {
  background: #f1f1f1;
}

.sh-suggest-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: #d9d9d9;
}

.sh-suggest-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.sh-suggest-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sh-suggest-name,
.sh-suggest-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sh-suggest-name {
  font-family: var(--sh-font-bold);
  font-weight: 700;
  font-size: 15px;
}

.sh-suggest-user {
  margin-top: 2px;
  font-family: var(--sh-font-medium);
  font-size: 13px;
  color: #6f6f6f;
}

.sh-suggest-empty {
  padding: 14px 12px;
  font-family: var(--sh-font-medium);
  font-size: 14px;
  color: #6f6f6f;
}

/* ---------- Actions à droite : partager + Download ---------- */

.sh-actions {
  position: relative;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Lien « About » à gauche du bouton de téléchargement (blanc sur la bannière, noir sur fond blanc). */
.sh-about {
  font-family: var(--sh-font-medium);
  font-size: 18px;
  line-height: 1;
  color: #fff;
  text-decoration: none;
  padding: 8px 4px;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.sh-about:hover {
  opacity: 0.72;
}

.sh-about:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 6px;
}

.site-header--overlay.is-solid .sh-about,
.site-header--solid .sh-about {
  color: #000;
}

.sh-share {
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #000;
  color: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.sh-share:hover {
  opacity: 0.82;
}

.sh-share:focus-visible {
  outline: 2px solid #000;
  outline-offset: 3px;
}

.sh-share svg {
  display: block;
}

.sh-toast {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-family: var(--sh-font-medium);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.sh-toast[hidden] {
  display: none;
}

/* ---------- Bouton Download ---------- */

.sh-download {
  position: relative;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.sh-download svg {
  display: block;
  flex: none;
}

.sh-logo:focus-visible,
.sh-download:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* Bouton Download en image (home) : largeur naturelle, collé à droite. */
.sh-download-img {
  justify-self: end;
  display: block;
  line-height: 0;
  border-radius: 999px;
}

.sh-download-img img {
  display: block;
  height: 45px;
  width: auto;
  max-width: none;
}

.sh-download-img:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* ---------- Variante : sur photo (home) ---------- */

.site-header--overlay {
  color: #fff;
}

.site-header--overlay .sh-search input {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.site-header--overlay .sh-search input::placeholder {
  color: rgba(255, 255, 255, 0.9);
}

.site-header--overlay .sh-download {
  background: #fff;
  color: #000;
}

/* Une fois la photo dépassée, le header passe en blanc (scroll). */
.site-header--overlay.is-solid {
  color: #000;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.site-header--overlay.is-solid .sh-logo img {
  filter: invert(1);
}

.site-header--overlay.is-solid .sh-search input {
  background: #efefef;
  color: #000;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.site-header--overlay.is-solid .sh-search input::placeholder {
  color: #8a8a8a;
}

.site-header--overlay.is-solid .sh-download-img img,
.site-header--solid .sh-download-img img {
  filter: invert(1);
}

.site-header--overlay.is-solid .sh-download {
  background: transparent;
  color: #000;
  box-shadow: inset 0 0 0 2px #000;
}

/* ---------- Variante : fond blanc (profils) ---------- */

.site-header--solid {
  background: #fff;
  color: #000;
}

.site-header--solid .sh-search input {
  background: #efefef;
  color: #000;
}

.site-header--solid .sh-search input::placeholder {
  color: #8a8a8a;
}

.site-header--solid .sh-download {
  background: transparent;
  color: #000;
  box-shadow: inset 0 0 0 2px #000;
}

.site-header--solid.is-scrolled {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  :root {
    --sh-height: 64px;
  }

  .site-header {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 10px;
  }

  .sh-logo img {
    width: 36px;
    height: 36px;
  }

  .sh-search input {
    padding: 0 14px;
  }

  .sh-download-img img {
    height: 40px;
  }

  .sh-about {
    font-size: 15px;
  }

  /* À côté du bouton de partage, un peu plus compact pour laisser de la place à la recherche. */
  .sh-actions .sh-download-img img {
    height: 34px;
  }

  /* Sur petit écran, seule la pomme reste dans le bouton (le libellé reste lu par les lecteurs d'écran). */
  .sh-download {
    width: 36px;
    padding: 0;
  }

  .sh-download span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .sh-suggest {
    position: fixed;
    top: calc(var(--sh-height) + env(safe-area-inset-top) + 4px);
    left: 10px;
    right: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header {
    transition: none;
  }
}
