/* Menu em arco: em tela estreita, as abas do topo e o dock viram um botão só, que abre tudo em arcos em volta dele. */

/* O movimento inteiro vem de dois números por item: --t (0 a 1) leva o disco do botão até o lugar dele no arco,
   e --s (0 a 1) é o tamanho. Registrados, o navegador consegue animar os dois com curvas e tempos separados. */
@property --t { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --s { syntax: "<number>"; inherits: false; initial-value: 0; }

.arco { display: none; }

@media (max-width: 1080px) {
  .tabs, .dock { display: none; }
  .arco { display: block; }
}

.arco {
  --d: 48px;
  --base: calc(14px + env(safe-area-inset-bottom));
  /* mola: passa uns 8% do ponto e assenta */
  --mola: linear(
    0 0%, .193 3.57%, .541 7.14%, .835 10.71%, 1.01 14.29%,
    1.077 17.86%, 1.079 21.43%, 1.053 25%, 1.025 28.57%,
    1.005 32.14%, .995 35.71%, .993 39.29%, .994 42.86%,
    .997 46.43%, .999 50%, 1 53.57%, 1.001 57.14%, 1 64.29%, 1 100%
  );
  --sai: cubic-bezier(.22, .9, .24, 1);
}

.arco__veu {
  position: fixed; inset: 0; z-index: 38;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.arco[data-state="aberto"] .arco__veu { opacity: 1; pointer-events: auto; }

/* ---- botão ---- */
.arco__botao {
  position: fixed; left: 50%; bottom: var(--base); z-index: 40; translate: -50% 0;
  display: grid; place-items: center; min-width: 52px; height: 52px; padding: 0 22px;
  border: 0; border-radius: 999px; background: var(--pill); color: var(--on-pill);
  font: 600 var(--fs-sm)/1 var(--font); cursor: pointer; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 26px 34px -24px #000c, 0 5px 10px -6px #0007;
  transition: padding .38s var(--sai), box-shadow .3s ease, opacity .24s ease, scale .3s ease, translate .34s var(--sai);
}
/* Com um campo de texto em uso, o botão desce para fora da tela e libera o rodapé para o teclado e para o campo. */
.arco[data-digitando] .arco__botao { translate: -50% calc(100% + var(--base) + 12px); opacity: 0; pointer-events: none; }
.arco__botao:active { scale: .96; }
.arco__botao:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.arco__atual {
  display: inline-flex; align-items: center; gap: 8px; max-width: 220px; overflow: hidden; white-space: nowrap;
  transition: max-width .38s var(--sai), opacity .16s ease, scale .3s var(--sai);
}
.arco__atual .ico { flex: none; width: 18px; height: 18px; }
.arco__x {
  position: absolute; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  opacity: 0; transform: scale(.4) rotate(-90deg);
  transition: opacity .2s ease, transform .4s var(--mola);
}
.arco[data-state="aberto"] .arco__botao { padding: 0; box-shadow: 0 16px 24px -18px #000c; }
.arco[data-state="aberto"] .arco__atual { max-width: 0; opacity: 0; scale: .7; }
.arco[data-state="aberto"] .arco__x { opacity: 1; transform: none; }
/* Na escolha, o disco escolhido volta ao centro e ocupa o lugar do botão por um instante. */
.arco[data-state="escolhido"] .arco__botao { opacity: 0; scale: .85; pointer-events: none; }

/* ---- leque ---- */
/* O leque é um ponto no centro do botão; cada item se afasta dele por --x e --y, calculados no script. */
.arco__leque { position: fixed; left: 50%; bottom: calc(var(--base) + 26px); z-index: 39; width: 0; height: 0; }

/* Linha fina por baixo de cada arco: mostra a curva e separa uma fileira da outra. Só aparece no trecho com itens. */
.arco__trilho {
  position: absolute; left: calc(var(--r) * -1); top: calc(var(--r) * -1); width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  border: 1px solid var(--line-2); border-radius: 50%; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 calc(var(--corte) - 4%), #0000 calc(var(--corte) + 4%));
  mask-image: linear-gradient(#000 calc(var(--corte) - 4%), #0000 calc(var(--corte) + 4%));
  opacity: 0; scale: .6; transition: opacity .16s ease, scale .3s cubic-bezier(.45, 0, .75, .4);
}
.arco[data-state="aberto"] .arco__trilho { opacity: 1; scale: 1; transition: opacity .4s ease var(--atraso), scale .8s var(--mola) var(--atraso); }

.arco__item {
  --t: 0;
  --s: 0;
  /* A coluna tem a largura do disco: rótulo mais largo passa por igual dos dois lados, sem empurrar o disco. */
  position: absolute; left: 0; top: 0; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 4px;
  width: var(--d); margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2); padding: 0;
  border: 0; background: none; color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  opacity: 0; pointer-events: none;
  transform: translate(calc(var(--x) * var(--t)), calc(var(--y) * var(--t))) scale(var(--s));
  /* fechar: acelera para dentro, quase junto */
  transition:
    --t .38s cubic-bezier(.45, 0, .75, .4) var(--volta),
    --s .26s ease-in var(--volta),
    opacity .18s ease;
}
/* abrir: cada item com o seu atraso, da esquerda para a direita, um arco depois do outro */
.arco[data-state="aberto"] .arco__item {
  --t: 1;
  --s: 1;
  opacity: 1; pointer-events: auto;
  transition:
    --t .86s var(--mola) var(--atraso),
    --s .72s var(--mola) var(--atraso),
    opacity .1s linear var(--atraso);
}

.arco__corpo { position: relative; width: var(--d); height: var(--d); }
.arco__disco {
  position: relative; display: grid; place-items: center; width: var(--d); height: var(--d); border-radius: 50%; overflow: hidden;
  background: var(--glass-3);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 #ffffff59, 0 22px 28px -20px #000b, 0 6px 10px -8px #0006;
  transition: box-shadow .3s ease, translate .3s var(--sai), scale .3s var(--sai);
}
.arco__disco .ico, .arco__disco animate-icons, .arco__disco pulso-icone { --ico-s: 20px; width: 20px; height: 20px; }
@media (hover: hover) {
  .arco[data-state="aberto"] .arco__item:hover .arco__disco { translate: 0 -2px; scale: 1.06; }
}
.arco[data-state="aberto"] .arco__item:active .arco__disco { scale: .94; }
.arco__item:focus-visible { outline: none; }
.arco__item:focus-visible .arco__disco { outline: 2px solid var(--primary); outline-offset: 2px; }
.arco__item[aria-current] .arco__disco { background: var(--pill); color: var(--on-pill); box-shadow: 0 22px 28px -20px #000b, 0 6px 10px -8px #0006; }

/* A cor da escolha entra pelo ponto do toque, recortada por um círculo. */
.arco__cor {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%;
  background: var(--pill); color: var(--on-pill);
  clip-path: circle(0% at var(--fx, 50%) var(--fy, 50%));
  transition: clip-path .52s cubic-bezier(.4, 0, .2, 1);
}
.arco__onda { position: absolute; inset: 0; border: 2px solid var(--pill); border-radius: 50%; opacity: 0; pointer-events: none; }

.arco__rotulo {
  justify-self: center; width: max-content; max-width: var(--lw, 64px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 10.5px/1.2 var(--font); letter-spacing: .01em; text-align: center;
  transition: opacity .16s ease;
}
/* O contador fica fora do disco, que recorta o que passa da borda. */
.arco__conta {
  position: absolute; top: -3px; left: calc(50% + var(--d) / 2 - 14px); z-index: 2; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--text); color: var(--bg); font: 700 10px/17px var(--font); text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.arco__item--esq .arco__conta { left: auto; right: calc(50% + var(--d) / 2 - 14px); }
.arco__conta:empty { display: none; }

/* ---- escolha ---- */
/* Todos voltam para o centro e só o escolhido fica inteiro, vindo ocupar o lugar do botão. */
.arco__item.is-escolhido {
  --t: 0;
  --s: 1;
  opacity: 1; z-index: 3;
  transition: --t .46s cubic-bezier(.55, 0, .85, .4) 40ms, --s .18s ease;
}
.arco__item.is-escolhido .arco__cor { clip-path: circle(150% at var(--fx, 50%) var(--fy, 50%)); }
.arco__item.is-escolhido .arco__rotulo, .arco__item.is-escolhido .arco__conta { opacity: 0; }
.arco__item.is-escolhido .arco__onda { animation: arco-onda .7s cubic-bezier(.2, .7, .3, 1) .06s; }
@keyframes arco-onda {
  0% { opacity: .45; transform: scale(.92); }
  100% { opacity: 0; transform: scale(1.7); }
}

@media (prefers-reduced-motion: reduce) {
  .arco__item, .arco[data-state="aberto"] .arco__item, .arco__item.is-escolhido, .arco__trilho, .arco[data-state="aberto"] .arco__trilho,
  .arco__botao, .arco__atual, .arco__x, .arco__veu, .arco__cor {
    transition-duration: 1ms !important; transition-delay: 0ms !important;
  }
  .arco__item.is-escolhido .arco__onda { animation: none; }
}
