/* ==========================================================================
   Barre de navigation fixe + HUD « Dynamic Island » de compilation
   ========================================================================== */

.topbar {
  position: fixed;
  z-index: 9;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  translate: -50% 0;
  animation: slide-down 0.9s 0.5s both var(--ease-out);
}

@keyframes slide-down {
  from {
    opacity: 0;
    translate: -50% -30px;
  }
}

/* ---- Navigation ---- */
.topbar nav {
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--color-line);
  border-radius: 99px;
  background: color-mix(in srgb, var(--color-bg) 75%, transparent);
  backdrop-filter: blur(14px);
}

.topbar nav button {
  white-space: nowrap;
}

.topbar nav .is-primary {
  background: var(--color-fg);
  color: var(--color-bg);
}

.nav-tab.is-active {
  box-shadow: inset 0 0 0 1px var(--color-fg);
}

/* ---- HUD : progression de lecture façon build Xcode ---- */
.hud {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(100% + 8px);
  display: flex;
  transition: scale 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.hud-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 220px;
  height: 100%;
  overflow: hidden;
  padding: 0 14px 0 8px;
  border: 1px solid #ffffff1f;
  border-radius: 99px;
  background: #000;
  color: #fff;
  font: 500 12px var(--font-mono);
  white-space: nowrap;
  box-shadow: 0 10px 30px -8px #0007;
  cursor: pointer;
  transition:
    width 0.45s cubic-bezier(0.3, 1.3, 0.5, 1),
    background 0.2s;
}

.hud-toggle:hover {
  background: #111;
}

.hud-toggle:focus-visible {
  outline: 2px solid var(--color-system-blue);
  outline-offset: 2px;
}

.hud-toggle > * {
  transition: opacity 0.25s 0.15s;
}

.hud-ring {
  flex: none;
  width: 24px;
  height: 24px;
  rotate: -90deg;
}

.hud-ring circle {
  fill: none;
  stroke-width: 2.6;
}

.hud-ring circle:first-child {
  stroke: #ffffff26;
}

/* stroke-dasharray = circonférence du cercle (2π × 8) */
.hud-progress {
  stroke: var(--color-system-blue);
  stroke-linecap: round;
  stroke-dasharray: 50.27;
  stroke-dashoffset: 50.27;
  transition: stroke 0.3s;
}

.hud-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  line-height: 1.2;
}

.hud-status {
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8e8e93;
}

.hud-file {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hud-percent {
  flex: none;
  color: #8e8e93;
  font-size: 11px;
}

.hud.is-done .hud-progress {
  stroke: var(--color-system-green);
}

.hud.is-done .hud-status {
  color: var(--color-system-green);
}

/* En haut de page, l'île se replie */
.hud.is-idle .hud-toggle {
  width: 96px;
}

.hud.is-idle .hud-toggle > * {
  opacity: 0;
  transition-delay: 0s;
}

/* ---- Menu des sections ---- */
.hud-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 250px;
  padding: 6px;
  border: 1px solid #ffffff1f;
  border-radius: 18px;
  background: #000;
  box-shadow: 0 20px 40px -12px #0008;
}

.hud-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font: 500 12px var(--font-mono);
  text-align: left;
  cursor: pointer;
}

.hud-menu button:hover {
  background: #ffffff14;
}

.hud-menu i {
  width: 12px;
  font-style: normal;
  text-align: center;
  color: #8e8e93;
}

.hud-menu span {
  margin-left: auto;
  color: #8e8e93;
  font-size: 10px;
}

.hud-menu .is-done i {
  color: var(--color-system-green);
}

.hud-menu .is-current {
  background: #ffffff0d;
}

.hud-menu .is-current i {
  color: var(--color-system-blue);
}

/* Le HUD n'a pas de sens sur la vue Portfolio */
body.is-portfolio .hud {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .topbar nav button {
    padding: 8px 11px;
  }

  .hud {
    top: calc(100% + 8px);
    bottom: auto;
    left: 50%;
    translate: -50% 0;
  }

  .hud-toggle {
    width: 210px;
    height: 36px;
  }

  .hud.is-idle .hud-toggle {
    width: 76px;
    height: 26px;
  }

  .hud-ring {
    width: 20px;
    height: 20px;
  }

  .hud-menu {
    right: auto;
    left: 50%;
    translate: -50% 0;
  }
}

@media (max-width: 380px) {
  .topbar nav button {
    padding: 8px 8px;
    font-size: 11.5px;
  }
}
