/* ============================================
   BASE + global utilities
   ============================================ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* Global focus visibility for keyboard users */
:focus-visible {
  outline: 2px solid var(--green-400);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip-to-content link — only visible on keyboard focus */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 12px 18px;
  background: var(--ink-900);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur-fast);
}
.skip-link:focus-visible { transform: translateY(0); }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "ss02", "cv11";
}
/* Stop offscreen reveal transforms (translateX/Y) from creating a horizontal
   scroll on mobile. `clip` doesn't establish a scroll container, so it does
   NOT break `position: sticky` or in-page anchor scrolling like `hidden` can. */
html, body { overflow-x: clip; }

/* Media never overflows its container — guards against authored intrinsic widths. */
img, video, svg, picture, canvas, iframe { max-width: 100%; }
img, video { height: auto; }
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: transparent; }

::selection { background: var(--green-400); color: var(--ink-900); }
[data-direction="tech"] ::selection { background: var(--green-200); color: var(--ink-900); }

/* ——— Typography primitives ——— */
.display {
  font-family: var(--font-display);
  font-weight: var(--font-display-weight);
  letter-spacing: var(--font-display-tracking);
  line-height: var(--font-display-line);
  text-wrap: balance;
}
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ——— Container ——— */
.container {
  width: 100%;
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container-wide { max-width: var(--content-wide); margin-inline: auto; padding-inline: var(--gutter); }
.container-narrow { max-width: var(--content-narrow); margin-inline: auto; padding-inline: var(--gutter); }

/* ——— Button ——— */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--step-0);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  line-height: 1;
}
.btn--primary {
  background: var(--white);
  color: var(--ink-900);
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.btn--dark {
  background: var(--ink-900);
  color: var(--paper);
}
.btn--dark:hover { transform: translateY(-2px); background: #000; }
.btn--green {
  background: var(--green-400);
  color: var(--ink-900);
}
.btn--green:hover { background: var(--green-500); transform: translateY(-2px); }
.btn--ghost {
  background: transparent;
  color: inherit;
  border: 1.5px solid currentColor;
}
.btn__arrow {
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-out);
}
.btn:hover .btn__arrow { transform: translateX(4px); }

/* ——— Reveal on scroll ——— */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--dur-reveal) var(--ease-editorial),
    transform var(--dur-reveal) var(--ease-editorial);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal="slide-left"] { transform: translateX(40px); }
[data-reveal="slide-up-big"] { transform: translateY(60px); }
[data-reveal="scale"] { transform: scale(.96); }
[data-reveal="blur"] { filter: blur(12px); }

.revealed { opacity: 1 !important; transform: none !important; filter: none !important; }

body[data-motion="subtle"] [data-reveal] { transition-duration: var(--dur-med); transform: translateY(12px); }
body[data-motion="rich"] [data-reveal] { transition-duration: 1100ms; transform: translateY(36px) scale(.98); }

/* On phones, when the hero/grid collapses to 1 column, sliding in from the
   right makes content land partially offscreen for a beat — looks awkward
   even with overflow:clip on body. Soften every horizontal-axis reveal to a
   smaller vertical one. */
@media (max-width: 720px) {
  [data-reveal="slide-left"] { transform: translateY(20px); }
}

/* ——— Topbar ——— */
.topbar {
  background: var(--ink-900);
  color: var(--green-400);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  padding: 10px 0;
  position: relative;
  z-index: 50;
  overflow: hidden;
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  letter-spacing: .02em;
}
.topbar__dot {
  width: 8px; height: 8px;
  background: var(--green-400);
  border-radius: 50%;
  animation: pulse 1.8s ease-in-out infinite;
}
.topbar__code {
  background: var(--green-400);
  color: var(--ink-900);
  padding: 2px 10px;
  border-radius: var(--radius-xs);
  font-weight: 600;
}
.topbar__sep { opacity: .4; }
.topbar__muted { color: rgba(255,255,255,.55); }
.topbar__muted b { color: var(--green-400); font-weight: 500; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ——— Nav ——— */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in oklab, var(--fg) 8%, transparent);
  transition: background var(--dur-med) var(--ease-out);
}
.nav__inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: 18px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}
.nav__brand {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: var(--font-display-weight);
  color: var(--fg);
}
.nav__mark {
  display: inline-block;
  width: 47px;  /* 40 * 189/161 = 46.96 */
  height: 40px;
  background-color: currentColor;
  -webkit-mask: url("../assets/brand/fsm-mark-dark-tight.png") center / contain no-repeat;
  mask: url("../assets/brand/fsm-mark-dark-tight.png") center / contain no-repeat;
  flex-shrink: 0;
}

/* === Logo "battery charge" hover ===
   O retângulo abaixo das letras "FSM" é HOLLOW (apenas contorno) no PNG
   da marca. Interior medido no asset (189×161): x 10.1%..89.4%, y 67.1%..87.6%.
   No hover, um overlay enche o interior da esquerda pra direita,
   simulando carregamento de bateria. Fora do hover, volta a vazio.

   IMPORTANTE: O fill NÃO pode ser pseudo-elemento de .nav__mark porque
   .nav__mark tem `mask: url(...)` — qualquer filho seria clipado pelo
   mesmo mask, e o interior do retângulo é justamente a parte transparente.
   Então o fill é um ::after de .nav__brand, posicionado absolutamente
   SOBRE a marca, fora do contexto de mask. */
.nav__brand {
  position: relative;
}
.nav__brand::after {
  content: "";
  position: absolute;
  /* Posição calculada em cima da .nav__mark (47px × 40px no desktop):
       x 11%..89% de 47px → ~5.2px a 41.8px (width ~36.6px)
       y 68%..87%  de 40px → ~27.2px a 34.8px (height ~7.6px)
     Margem reduzida: 11% nas laterais, 1px de respiro vertical. */
  left: calc(47px * 0.11);
  width: calc(47px * 0.78);
  top: calc(40px * 0.68 + 1px);
  height: calc(40px * 0.18);
  background-color: currentColor;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 720ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}
.nav__brand:hover::after,
.nav__brand:focus-visible::after {
  transform: scaleX(1);
}
@media (max-width: 720px) {
  /* Mobile: .nav__mark é 40×34px */
  .nav__brand::after {
    left: calc(40px * 0.11);
    width: calc(40px * 0.78);
    top: calc(34px * 0.68 + 1px);
    height: calc(34px * 0.18);
  }
}
@media (prefers-reduced-motion: reduce) {
  .nav__brand::after { transition: none; }
}
@media (max-width: 720px) {
  .nav__mark { width: 40px; height: 34px; }
}
.nav__dot { color: var(--accent); }
.nav__links {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.5vw, 28px);
  font-size: var(--step--1);
  font-weight: 500;
}
.nav__links a {
  position: relative;
  padding: 6px 2px;
  transition: color var(--dur-fast);
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-med) var(--ease-out);
}
.nav__links a:hover::after { transform: scaleX(1); }
.nav__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink-900);
  color: var(--paper);
  font-weight: 600;
  font-size: var(--step--1);
  transition: transform var(--dur-fast), background var(--dur-fast);
}
.nav__cta:hover { transform: translateY(-1px); background: #000; }
.nav__arrow { transition: transform var(--dur-fast) var(--ease-out); display: inline-block; }
.nav__cta:hover .nav__arrow { transform: translateX(3px); }

[data-direction="tech"] .nav {
  background: color-mix(in oklab, var(--ink-900) 88%, transparent);
}
[data-direction="tech"] .nav__cta {
  background: var(--green-400);
  color: var(--ink-900);
}

@media (max-width: 840px) {
  .nav__links { display: none; }
}

/* ——— Footer ——— */
.footer {
  background: var(--ink-900);
  color: var(--paper);
  padding: var(--space-2xl) 0 var(--space-xl);
}
.footer__inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: var(--space-2xl);
  align-items: start;
}
.footer__brand { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.footer__mark {
  display: inline-block;
  width: 66px; /* 56 * 192/164 = 65.56 */
  height: 56px;
  background-color: var(--green-400);
  -webkit-mask: url("../assets/brand/fsm-mark-dark-tight.png") center / contain no-repeat;
  mask: url("../assets/brand/fsm-mark-dark-tight.png") center / contain no-repeat;
}
.footer__brand p { max-width: 280px; color: rgba(255,255,255,.7); font-size: var(--step-0); line-height: 1.5; }
.footer__nav { display: flex; flex-direction: column; gap: 10px; font-size: var(--step--1); }
.footer__nav h4 {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: var(--step--2);
  color: rgba(255,255,255,.5);
  font-weight: 500;
  margin: 0 0 8px;
}
.footer__nav a { color: rgba(255,255,255,.85); }
.footer__nav a:hover { color: var(--green-400); }
.footer__nav .footer__primary { color: var(--green-400); }
.footer__social { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-md); font-size: var(--step--2); color: rgba(255,255,255,.4); }
.footer__social a {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,.8);
  margin-right: 6px;
}
.footer__social a:hover { background: var(--green-400); color: var(--ink-900); }

@media (max-width: 840px) {
  .footer__inner { grid-template-columns: 1fr; gap: var(--space-xl); }
}

/* ——— Sticky CTA bar ——— */
.stickybar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--ink-900);
  color: var(--paper);
  border-radius: var(--radius-pill);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.08);
  animation: stickyIn var(--dur-slow) var(--ease-editorial) both;
  max-width: calc(100vw - 32px);
}
.stickybar__inner {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: 12px 12px 12px 28px;
}
.stickybar__left { display: flex; align-items: baseline; gap: 14px; }
.stickybar__price {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
  color: var(--green-400);
  letter-spacing: var(--font-display-tracking);
}
.stickybar__price small { font-size: 12px; vertical-align: 6px; margin-right: 2px; opacity: .8; }
.stickybar__label { font-size: var(--step--1); color: rgba(255,255,255,.7); }
.stickybar__cta {
  background: var(--green-400);
  color: var(--ink-900);
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--step--1);
  transition: transform var(--dur-fast), background var(--dur-fast);
}
.stickybar__cta:hover { transform: translateY(-1px); background: var(--green-500); }

@keyframes stickyIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 640px) {
  .stickybar__label { display: none; }
  .stickybar__inner { padding-left: 20px; gap: 16px; }
}

/* ——— Mobile responsive: ≤640px ——— */
@media (max-width: 640px) {
  :root {
    --gutter: 18px;
    --space-4xl: 80px;
    --space-3xl: 56px;
    --space-2xl: 40px;
  }

  /* Topbar — keep readable, allow truncation */
  .topbar__inner { font-size: 11px; gap: 8px; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .topbar__sep, .topbar__muted { display: none; }

  /* Nav — compact CTA */
  .nav__inner { padding: 14px var(--gutter); }
  .nav__cta { padding: 10px 14px; font-size: 13px; gap: 6px; }

  /* Footer */
  .footer__social { flex-direction: column; align-items: flex-start; gap: 12px; }
  .footer__social a { font-size: 14px; }

  /* Sticky bar */
  .stickybar { bottom: 12px; }
  .stickybar__price { font-size: 22px; }
  .stickybar__cta { padding: 12px 18px; font-size: 13px; }

  /* Tweaks panel — full-width drawer on mobile */
  .tweaks { left: 12px !important; right: 12px !important; bottom: 12px !important; top: auto !important; width: auto !important; max-width: none !important; }
}

/* Smaller screens: stack hero CTA full-width */
@media (max-width: 520px) {
  .btn { width: 100%; justify-content: center; }
  .hero__actions { width: 100%; }
}
