/* Tab-app shell — painéis a ecrã inteiro com transição */

html.is-tab-app,
body.is-tab-app {
  height: 100%;
  overflow: hidden;
  scroll-behavior: auto;
}

body.is-tab-app {
  padding-bottom: 0;
}

.panels {
  position: relative;
  height: calc(100dvh - var(--nav-h) - env(safe-area-inset-top, 0px));
  margin-top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  overflow: hidden;
}

.panel {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 22px, 0) scale(0.985);
  filter: blur(6px);
  transition:
    opacity 0.42s var(--ease),
    transform 0.48s var(--ease),
    filter 0.42s var(--ease),
    visibility 0.42s;
  z-index: 0;
  background: var(--bg);
}

.panel.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  filter: none;
  z-index: 2;
}

.panel.is-exit {
  opacity: 0;
  transform: translate3d(0, -14px, 0) scale(0.99);
  filter: blur(4px);
  z-index: 1;
}

.panel.is-enter {
  opacity: 0;
  transform: translate3d(0, 28px, 0) scale(0.98);
  filter: blur(8px);
}

.panel[hidden] {
  display: block !important; /* keep for transitions; visibility handles hide */
}

.panel[hidden]:not(.is-active):not(.is-exit):not(.is-enter) {
  display: none !important;
}

/* Hero as panel */
.panel--home.hero {
  min-height: 100%;
  height: 100%;
  display: grid;
  align-items: center;
  padding-top: 0.5rem;
  padding-bottom: 1.5rem;
}

.panel--home .hero__canvas {
  position: absolute;
  inset: 0;
}

.panel .section {
  padding-top: clamp(1.75rem, 4vh, 3rem);
  padding-bottom: clamp(2rem, 5vh, 3.5rem);
}

.panel--sobre .section--about {
  padding-bottom: 1rem;
}

.panel--sobre .section--diff {
  border-top: 1px solid var(--line);
}

.panel--leader .section--purpose {
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}

.panel--contact {
  display: flex;
  flex-direction: column;
}

.panel--contact .footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
}

/* Nav active tab */
.nav__links a.is-active {
  color: var(--cyan);
}

.nav__links a.is-active::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 0.2rem;
  background: var(--cyan);
  opacity: 0.7;
}

.nav__cta.is-active {
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.45);
}

/* Tiny social links in contact */
.contact__social {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.55rem;
  margin: 1.1rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 300;
}

.contact__social a {
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.contact__social a:hover {
  color: var(--cyan);
  border-bottom-color: rgba(0, 229, 255, 0.35);
}

.footer__social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.55rem;
  margin-top: 0.65rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.footer__social a {
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
}

.footer__social a:hover {
  color: var(--cyan);
  border-bottom-color: rgba(0, 229, 255, 0.35);
}

/* Ambient audio toggle */
.audio-toggle {
  position: fixed;
  z-index: 80;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(2, 6, 15, 0.82);
  backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}

.audio-toggle:hover {
  color: var(--text);
  border-color: rgba(0, 229, 255, 0.35);
}

.audio-toggle.is-on {
  color: var(--cyan);
  border-color: rgba(0, 229, 255, 0.4);
}

.audio-toggle__icon {
  width: 0.85rem;
  height: 0.85rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.audio-toggle.is-on .audio-toggle__icon::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
  animation: audioPulse 1.6s ease-in-out infinite;
}

.audio-toggle.is-muted .audio-toggle__icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  width: 1px;
  height: calc(100% + 4px);
  background: currentColor;
  transform: translateX(-50%) rotate(45deg);
}

@keyframes audioPulse {
  0%, 100% { transform: scale(0.55); opacity: 0.5; }
  50% { transform: scale(0.9); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .panel {
    transition: opacity 0.2s ease;
    filter: none !important;
    transform: none !important;
  }

  .audio-toggle.is-on .audio-toggle__icon::after {
    animation: none;
  }
}

@media (max-width: 979px) {
  .panels {
    height: calc(100dvh - var(--nav-h) - env(safe-area-inset-top, 0px));
  }

  .nav__links a.is-active::after {
    display: none;
  }

  .audio-toggle {
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom) + 4.5rem));
  }
}
