/* ============================================================
   miravo — tipografia (Sora, self-hosted, com fallback de sistema)
   ============================================================ */
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("/assets/fonts/sora-300.woff2") format("woff2");
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/sora-400.woff2") format("woff2");
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/sora-600.woff2") format("woff2");
}

/* ============================================================
   miravo — design tokens
   ============================================================ */
:root {
  --void: #000000;
  --elev: #0c0c11;
  --elev-2: #131319;
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  --ink: #f4f4f8;
  --ink-dim: #9b9ba7;
  --ink-faint: #56565f;

  --violet: #6d5ef7;
  --violet-lift: #8577ff;
  --violet-press: #5a4ce0;
  --violet-glow: rgba(109, 94, 247, 0.45);

  --cyan: #22e6f0;         /* vem da logo — usado só na abertura */
  --danger: #f0575c;

  --r-lg: 22px;
  --r-md: 15px;
  --r-sm: 10px;

  --pad: clamp(18px, 5vw, 28px);
  --maxw: 560px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --sys: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, system-ui, sans-serif;
  --font: "Sora", var(--sys);
}

* { box-sizing: border-box; }

/* o atributo hidden sempre vence classes que definem display */
[hidden] { display: none !important; }

html, body { max-width: 100%; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button, input, textarea, select { font-family: inherit; }

::selection { background: var(--violet); color: #fff; }

/* ============================================================
   Barra superior (aparece ao rolar)
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  pointer-events: none;
}
.topbar.is-visible { opacity: 1; transform: translateY(0); }
.topbar__logo { width: 26px; height: 26px; object-fit: contain; }
.topbar__word {
  font-size: 0.95rem;
  letter-spacing: 0.26em;
  text-transform: lowercase;
  color: var(--ink);
  padding-left: 3px;
}

/* ============================================================
   Cena 1 — abertura
   ============================================================ */
.hero {
  position: relative;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14vh var(--pad) calc(env(safe-area-inset-bottom) + 26px);
  overflow: hidden;
}

.hero__glow {
  position: absolute;
  top: 42%;
  left: 50%;
  width: min(115vw, 720px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(34, 230, 240, 0.14), rgba(34, 230, 240, 0) 62%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}

.hero__mark {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: auto;      /* empurra a marca para a parte de baixo da tela */
  will-change: transform, opacity;
}

.hero__logo {
  width: min(58vw, 224px);
  height: auto;
  filter: drop-shadow(0 12px 40px rgba(34, 230, 240, 0.18));
  animation: rise 1s var(--ease) both;
}

.wordmark {
  margin: 20px 0 0;
  font-size: clamp(1.9rem, 9vw, 2.9rem);
  font-weight: 300;
  letter-spacing: 0.42em;
  text-indent: 0.42em;    /* compensa o tracking para centralizar */
  text-transform: lowercase;
  color: var(--ink);
  animation: rise 1s var(--ease) 0.08s both;
}

.tagline {
  margin: 14px 0 0;
  font-size: 0.98rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
  animation: rise 1s var(--ease) 0.16s both;
}

.scrollcue {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.74rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  animation: rise 1s var(--ease) 0.28s both;
}
.scrollcue__chev { animation: bob 2s var(--ease) infinite; }
.scrollcue:hover { color: var(--ink-dim); }

/* ============================================================
   Cena 2 — editor
   ============================================================ */
.editor {
  position: relative;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12vh var(--pad) calc(env(safe-area-inset-bottom) + 12vh);
}

/* crédito — discreto, afastado da área útil */
.credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  opacity: 0.6;
}
.credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding-bottom: 1px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.credit a:hover { color: var(--ink-dim); border-color: var(--ink-dim); }

.panel {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 10px; }
.field__label {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-left: 2px;
}

.prompt {
  width: 100%;
  min-height: 92px;
  resize: none;
  background: var(--elev);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 16px;
  font-size: 1.05rem;
  line-height: 1.45;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
  outline: none;
}
.prompt::placeholder { color: var(--ink-faint); }
.prompt:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-glow);
}

/* Uploader */
.uploader {
  position: relative;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-md);
  background: var(--elev);
  overflow: hidden;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
  cursor: pointer;
}
.uploader:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.uploader.is-drag { border-color: var(--violet); background: var(--elev-2); }
.uploader.has-image { border-style: solid; cursor: default; }

.uploader__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--ink-dim);
  text-align: center;
}
.uploader__icon { color: var(--violet-lift); opacity: 0.9; }
.uploader__title { font-size: 1rem; color: var(--ink); }
.uploader__hint { font-size: 0.82rem; color: var(--ink-faint); }

.uploader__preview { position: relative; display: block; }
.uploader__preview img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  background: #000;
}
.uploader__bar {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
}

.chip {
  border: 1px solid var(--hairline-strong);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.chip:hover { background: rgba(0, 0, 0, 0.75); border-color: var(--ink-faint); }
.chip--x:hover { color: var(--danger); border-color: var(--danger); }

.hint { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-faint); min-height: 1.2em; text-align: center; }
.hint.is-error { color: var(--danger); }

/* ============================================================
   Botões
   ============================================================ */
.btn {
  position: relative;
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 15px 22px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease),
    border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--violet-lift); outline-offset: 2px; }
.btn--block { width: 100%; }

.btn--primary {
  background: var(--violet);
  box-shadow: 0 8px 26px -8px var(--violet-glow);
}
.btn--primary:hover { background: var(--violet-lift); }
.btn--primary:active { background: var(--violet-press); }

.btn--ghost {
  background: transparent;
  border-color: var(--hairline-strong);
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--ink-dim); background: rgba(255, 255, 255, 0.03); }

.btn--danger {
  background: transparent;
  border-color: rgba(240, 87, 92, 0.35);
  color: var(--danger);
}
.btn--danger:hover { border-color: var(--danger); background: rgba(240, 87, 92, 0.08); }

.btn:disabled { cursor: not-allowed; box-shadow: none; }
.btn:disabled:active { transform: none; }
.btn--primary:disabled {
  background: #1a1a20;
  color: var(--ink-faint);
  border-color: var(--hairline);
}

/* Estado de processamento — o spinner é o "movimento" em toda ação */
.btn.is-busy { pointer-events: none; }
.btn.is-busy .btn__label { opacity: 0; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  opacity: 0.9;
  animation: spin 0.7s linear infinite;
}
.btn.is-done .btn__label { opacity: 0; }
.btn.is-done::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 10px;
  border-left: 2.4px solid currentColor;
  border-bottom: 2.4px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}

/* ============================================================
   Cena 3 — resultado
   ============================================================ */
.result {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12vh var(--pad) calc(env(safe-area-inset-bottom) + 12vh);
}
.result[hidden] { display: none; }

.stage {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--elev);
  border: 1px solid var(--hairline);
}

.frame__placeholder {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(109, 94, 247, 0.10), rgba(0, 0, 0, 0) 60%),
    var(--elev);
  transition: opacity 0.6s var(--ease);
}
.frame__pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(109, 94, 247, 0.16), rgba(0, 0, 0, 0) 55%);
  animation: breathe 2.6s var(--ease) infinite;
}
.scan {
  position: absolute;
  top: 0; bottom: 0;
  width: 45%;
  left: -50%;
  background: linear-gradient(
    100deg,
    rgba(109, 94, 247, 0) 0%,
    rgba(133, 119, 255, 0.42) 45%,
    rgba(34, 230, 240, 0.30) 55%,
    rgba(109, 94, 247, 0) 100%
  );
  filter: blur(2px);
  animation: sweep 1.7s var(--ease) infinite;
}

.frame__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 0.7s var(--ease), transform 0.9s var(--ease);
}
.frame__img.is-in { opacity: 1; transform: scale(1); }
.frame.is-done .frame__placeholder { opacity: 0; }

.status {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
  text-align: center;
  min-height: 1.3em;
}
.status.is-error { color: var(--danger); }

.interpreted {
  margin: -6px 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-faint);
  text-align: center;
  max-width: 52ch;
  max-height: 6.5em;
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding: 0 2px;
}
.interpreted b { color: var(--ink-dim); font-weight: 500; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}
.actions .btn { flex: 1 1 30%; min-width: 96px; }

.errorbox { width: 100%; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.errorbox__msg { margin: 0; color: var(--danger); font-size: 0.95rem; }
.errorbox__actions { display: flex; gap: 10px; }
.errorbox__actions .btn { flex: 1; }

/* ============================================================
   Reveal ao rolar
   ============================================================ */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }

/* ============================================================
   Animações
   ============================================================ */
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sweep { 0% { left: -55%; } 100% { left: 110%; } }
@keyframes breathe { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Desktop refina o layout */
@media (min-width: 720px) {
  body { font-size: 17px; }
  .hero__logo { width: 240px; }
}

/* Acessibilidade — respeita quem prefere menos movimento */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .scan { display: none; }
}
