/* Recepción: la recepcionista detrás de su mostrador. Los colores de fondo, acento, blazer y pelo
   los pone cada negocio (theme en su plugin); el mostrador y la placa son iguales para todos. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --background: #e6f2f0;
  --accent: #0f766e;
  --jacket: #1e3a5f;
  --hair: #3a2a20;
  --skin: #f3c9a8;
  --ink: #1d2a33;
  --muted: #55636f;
  --oak-top: #e6c7a0;
  --oak: #c99a66;
  --oak-edge: #a27245;
  --plate: #23313b;
  --end: #c62828;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Escena ---------- */

.scene {
  min-height: 100dvh;
  display: grid;
  /* Áreas con nombre: la barra de llamada se oculta en reposo y no debe correr las demás filas */
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-areas: "bar" "booth" "desk" "talk" "controls";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.callbar {
  grid-area: bar;
  display: none;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem 0;
  font-size: 0.95rem;
  color: var(--muted);
}
.callbar-timer {
  font-variant-numeric: tabular-nums;
}
body[data-channel="movil"]:not([data-state="idle"]):not([data-state="ended"]) .callbar {
  display: flex;
}

/* ---------- Recepcionista y mostrador ---------- */

.booth {
  grid-area: booth;
  position: relative;
  display: grid;
  justify-items: center;
  padding-top: 3vh;
  isolation: isolate;
}

.avatar {
  position: relative;
  z-index: 0;
  width: min(80vw, 44vh);
  aspect-ratio: 1;
  cursor: default;
}
.avatar svg {
  display: block;
  width: 100%;
  height: 100%;
}
body[data-state="speaking"] .avatar,
body[data-state="thinking"] .avatar {
  cursor: pointer;
}

.halo {
  position: absolute;
  z-index: -1;
  top: 6%;
  left: 50%;
  width: min(62vw, 34vh);
  aspect-ratio: 1;
  translate: -50% 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}
body[data-state="listening"] .halo {
  animation: listening 1.8s ease-out infinite;
}
@keyframes listening {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent);
  }
  100% {
    box-shadow: 0 0 0 22px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

.counter {
  grid-area: desk;
  position: relative;
  z-index: 1;
  height: clamp(54px, 10vh, 104px);
  margin-top: calc(min(80vw, 44vh) * -0.1);
  background: var(--oak);
  border-top: 14px solid var(--oak-top);
  box-shadow: inset 0 -7px 0 var(--oak-edge);
  display: flex;
  justify-content: center;
}

.nameplate {
  margin: -46px 0 0;
  height: fit-content;
  padding: 0.35em 1.1em 0.45em;
  display: grid;
  justify-items: center;
  background: var(--plate);
  color: #f2f5f7;
  border-radius: 4px 4px 2px 2px;
  border-bottom: 5px solid #121c22;
  line-height: 1.2;
}
.nameplate-name {
  font-weight: 700;
  font-size: 1.15rem;
}
.nameplate-business {
  font-size: 0.8rem;
  color: #c3ccd3;
}

/* ---------- Avatar (SVG) ---------- */

.av-skin { fill: var(--skin); }
.av-shade { fill: rgb(0 0 0 / 0.12); }
.av-jacket { fill: var(--jacket); }
.av-lapel { fill: rgb(0 0 0 / 0.22); }
.av-shirt { fill: #fbfbfa; }
.av-scarf,
.av-accent,
.av-hair-tie { fill: var(--accent); }
.av-hair { fill: var(--hair); }
.av-hair-shine { fill: none; stroke: rgb(255 255 255 / 0.16); stroke-width: 4; stroke-linecap: round; }
.av-brow { fill: none; stroke: var(--hair); stroke-width: 5.5; stroke-linecap: round; }
.av-pupil { fill: #2b211d; }
.av-glint { fill: #fff; }
.av-lash { fill: none; stroke: #2b211d; stroke-width: 2.5; stroke-linecap: round; }
.av-nose { fill: none; stroke: rgb(140 70 45 / 0.45); stroke-width: 3; stroke-linecap: round; }
.av-cheek { fill: #e8828a; opacity: 0.28; }
.av-cavity { fill: #5c1a22; stroke: #a8495a; stroke-width: 2.6; stroke-linejoin: round; }
.av-teeth { fill: #fff; }
.av-tongue { fill: #d4646f; }
.av-lipline { fill: none; stroke: #a8495a; stroke-width: 3.2; stroke-linecap: round; }
.av-headset { fill: none; stroke: #2f3437; stroke-width: 7; stroke-linecap: round; }
.av-headset-part { fill: #2f3437; }
.av-boom { fill: none; stroke: #2f3437; stroke-width: 4.5; stroke-linecap: round; }

.av-bust {
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe {
  50% {
    transform: translateY(1.6px);
  }
}
.av-head {
  transform-origin: 200px 250px;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.avatar[data-state="listening"] .av-head {
  transform: rotate(-3deg);
}
.av-eyes {
  transition: transform 0.35s ease;
}
.avatar[data-state="thinking"] .av-eyes {
  transform: translate(4px, -4px);
}
.av-brows {
  transition: transform 0.25s ease;
}
.avatar[data-state="listening"] .av-brows,
.avatar.brows-up .av-brows {
  transform: translateY(-3.5px);
}
.avatar[data-state="thinking"] .av-brows {
  transform: translateY(-2px);
}
.av-eye {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.07s ease-in;
}
.avatar.blink .av-eye {
  transform: scaleY(0.1);
}

/* ---------- Conversación ---------- */

.talk {
  grid-area: talk;
  width: 100%;
  max-width: 40ch;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 0.5rem;
}
/* En reposo, la presentación va junto al botón */
body[data-state="idle"] .talk,
body[data-state="ended"] .talk {
  align-self: end;
}
.status {
  min-height: 1.45em;
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-weight: 700;
}
.line {
  margin: 0;
  text-wrap: pretty;
}
.line-you {
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.3rem);
}
.line-you:not(:empty)::before {
  content: "«";
}
.line-you:not(:empty)::after {
  content: "»";
}
.line-you.is-live {
  opacity: 0.7;
}
.line-her {
  font-size: clamp(1.5rem, 1rem + 2.2vw, 2.45rem);
  line-height: 1.25;
}
.notice {
  margin: 1rem 0 0;
  padding: 0.7em 1em;
  background: #fff;
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
}

/* ---------- Controles ---------- */

.controls {
  grid-area: controls;
  align-self: end;
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem 4vh;
}
.idle-actions {
  display: grid;
  justify-items: center;
  text-align: center;
}
.call-actions {
  display: flex;
  gap: clamp(0.75rem, 3vw, 1.5rem);
}
body[data-state="idle"] .call-actions,
body[data-state="ended"] .call-actions,
body:not([data-state="idle"]):not([data-state="ended"]) .idle-actions {
  display: none;
}

button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
button svg path,
button svg rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  min-height: 68px;
  padding: 0.85em 1.7em;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.65rem);
  font-weight: 700;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 65%, black);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-start:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 65%, black);
}
.btn-start svg {
  width: 1.3em;
  height: 1.3em;
}
.hint {
  max-width: 34ch;
  margin: 0.9rem 0 0;
  color: var(--muted);
}

.round {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgb(29 42 51 / 0.14);
  background: #fff;
  color: var(--ink);
}
.round svg {
  width: 28px;
  height: 28px;
}
.round:disabled {
  opacity: 0.35;
  cursor: default;
}
.round .slash {
  display: none;
}
.round[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}
.round[aria-pressed="true"] .slash {
  display: inline;
}
.round-end {
  background: var(--end);
  border-color: transparent;
  color: #fff;
}
.round-end svg path {
  fill: currentColor;
  stroke-width: 1;
}

.typeform {
  display: flex;
  gap: 0.6rem;
  width: min(100%, 40ch);
}
.typeform[hidden] {
  display: none;
}
.typeform input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 0.9em;
  font: inherit;
  font-size: 1.1rem;
  border: 2px solid rgb(29 42 51 / 0.2);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.typeform button {
  padding: 0 1.2em;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

/* ---------- Kiosco vertical (pantalla grande de pie): todo un poco más grande ---------- */

@media (min-width: 900px) and (min-height: 1400px) and (max-aspect-ratio: 5/4) {
  html {
    font-size: 125%;
  }
  .line-her {
    font-size: 2.3rem;
  }
}

/* ---------- Mostrador apaisado (pantalla de kiosco) ---------- */

@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .scene {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      "bar bar"
      "booth talk"
      "booth controls"
      "desk desk";
    column-gap: 4vw;
  }
  .booth {
    align-self: end;
    padding-top: 0;
  }
  .avatar {
    width: min(42vw, 72vh);
  }
  .halo {
    width: min(32vw, 54vh);
  }
  .counter {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    column-gap: 4vw;
    margin-top: calc(min(42vw, 72vh) * -0.1);
    height: clamp(80px, 16vh, 150px);
  }
  .nameplate {
    justify-self: center;
  }
  .talk {
    align-self: end;
    margin: 0;
    padding: 0 4vw 0 0;
  }
  .controls {
    align-self: start;
    justify-items: start;
    padding: 2.5rem 4vw calc(min(42vw, 72vh) * 0.1 + 2rem) 0;
  }
  .idle-actions {
    justify-items: start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .av-bust,
  body[data-state="listening"] .halo {
    animation: none;
  }
  body[data-state="listening"] .halo {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 30%, transparent);
  }
  .av-head,
  .av-eyes,
  .av-brows {
    transition: none;
  }
}

/* ?depurar=1: registro del micrófono y la voz, para revisar en un móvil */
.debug-log {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  max-height: 32vh;
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  background: rgb(0 0 0 / 0.8);
  color: #b6f7b6;
  font: 11px/1.35 ui-monospace, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}
