/*
 * Dolphin — fase 1.
 * Monocromo por decisión de Nico (docs/DESIGN.md): la jerarquía la hacen el valor,
 * el peso, el área y el movimiento. Cero bordes: solo tonos apilados.
 */

/* Geist, la misma de la app: la puerta y lo que hay adentro se leen igual.
   Viene del paquete npm de web/, copiada acá para que el login no dependa
   de un build. */
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --bg: #eaeaec;
  --s1: #f7f7f8;
  --s2: #f0f0f2;
  --s3: #e7e7ea;
  --s4: #dcdce0;
  --ink-1: #0b0b0c;
  --ink-2: #56565e;
  --ink-3: #8c8c95;
  --on-ink: #fafafa;
  --state-layer: rgb(0 0 0 / 0.06);

  --ok: #2f7d4f;
  --warn: #8a6300;
  --err: #a8201a;

  --r-canvas: 18px;
  --r-window: 32px;
  --r-box: 24px;
  --r-row: 16px;
  --r-chip: 12px;

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Geist", var(--font-ui);

  /* Easings firma. Las mismas curvas están registradas en GSAP (app.js). */
  --ease-size: cubic-bezier(0.38, 0.49, 0, 1);
  --ease-enter: cubic-bezier(0.1, 0.8, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --s1: #0e0e10;
    --s2: #161619;
    --s3: #1e1e22;
    --s4: #27272c;
    --ink-1: #fafafa;
    --ink-2: #a3a3ad;
    --ink-3: #71717a;
    --on-ink: #09090b;
    --state-layer: rgb(255 255 255 / 0.08);

    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
  }
}

* {
  box-sizing: border-box;
}

/* Una clase con `display` le gana al [hidden] del user agent. Esto lo evita en todo el documento. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-1);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.canvas {
  min-height: 100%;
  /* Flex y no grid: un track `auto` se dimensiona por max-content y descentra la
     ventana (medido: 2054px de track en un viewport de 1440). */
  display: flex;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- ventana ---------- */

.window {
  width: min(100%, 420px);
  min-width: 0;
  /* `margin:auto` y no `align-items:center`: centra igual, pero cuando la ventana
     es más alta que la pantalla no recorta el borde de arriba. */
  margin: auto;
  background: var(--s1);
  border-radius: var(--r-window);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* Sombra en vez de borde: el límite se insinúa, no se dibuja. */
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.04),
    0 18px 48px -24px rgb(0 0 0 / 0.28);
}

/* ---------- marca y estado del vínculo ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-1);
}

.brand__mark {
  display: block;
  width: 22px;
  height: 22px;
}

.brand__mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand__word {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
}

.link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: var(--r-chip);
  background: var(--s2);
  color: var(--ink-2);
  font-size: 12.5px;
}

.link__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
}

.link[data-phase="ready"] .link__dot {
  background: var(--ok);
}

.link[data-phase="pairing-required"] .link__dot {
  background: var(--warn);
}

.link[data-phase="error"] .link__dot {
  background: var(--err);
}

/* ---------- vistas ---------- */

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.12;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.actions--end {
  flex-direction: row;
  justify-content: flex-end;
  gap: 4px;
}

/* ---------- botones ---------- */

.pill,
.ghost {
  position: relative;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  /* El press lo maneja GSAP; acá solo el color. Nunca transform en hover. */
  transition: background-color 15ms linear, color 15ms linear;
}

.pill {
  height: 46px;
  padding: 0 22px;
  background: var(--ink-1);
  color: var(--on-ink);
}

.pill::after,
.ghost::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 0.1);
  opacity: 0;
  transition: opacity 15ms linear;
}

@media (hover: hover) {
  .pill:hover::after {
    opacity: 1;
  }

  .ghost:hover {
    background: var(--s3);
  }
}

.pill:disabled {
  background: var(--s4);
  color: var(--ink-3);
  cursor: not-allowed;
}

.pill:disabled::after {
  display: none;
}

.ghost {
  height: 40px;
  padding: 0 16px;
  background: transparent;
  color: var(--ink-2);
}

.ghost::after {
  display: none;
}

:where(button, input):focus-visible {
  outline: 2px solid var(--ink-1);
  outline-offset: 2px;
}

/* ---------- código de alta ---------- */

.code {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code__cell {
  flex: 1 1 0;
  min-width: 0;
  height: 54px;
  padding: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  color: var(--ink-1);
  background: var(--s3);
  border: 0;
  border-radius: var(--r-row);
  text-transform: uppercase;
  transition: background-color 15ms linear;
}

.code__cell:focus {
  background: var(--s4);
  outline: none;
}

.code__cell:focus-visible {
  outline: 2px solid var(--ink-1);
  outline-offset: 2px;
}

.code__dash {
  width: 10px;
  height: 2px;
  flex: 0 0 auto;
  border-radius: 1px;
  background: var(--ink-3);
}

.code--error .code__cell {
  color: var(--err);
}

/* ---------- mensajes ---------- */

.msg {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.msg[data-tone="error"] {
  color: var(--err);
}

.msg[data-tone="ok"] {
  color: var(--ok);
}

@media (max-width: 420px) {
  .canvas {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .window {
    padding: 18px;
    border-radius: 28px;
  }

  .title {
    font-size: 26px;
  }
}
