/* ============================================================
   GarblanSportLive - estilos
   Pensado para pantalla grande (la profesora) y movil/tablet
   (las alumnas suelen seguir la clase desde el movil apoyado).
   ============================================================ */

:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --surface: #1e222b;
  --surface-hover: #262b36;
  --border: #2e3440;
  --text: #e8eaed;
  --text-dim: #9aa3b2;
  --accent: #5b8cff;
  --accent-strong: #3d73f5;
  --danger: #e5484d;
  --danger-strong: #c93b40;
  --speaking: #37d67a;
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

[hidden] {
  display: none !important;
}

/* ---------------- Pantalla de entrada ---------------- */

/*
 * Pantalla partida: collage a la izquierda, acceso a la derecha. Por debajo de
 * 900px se apila (el collage se convierte en una banda) para que en el movil
 * el formulario siga siendo lo primero que se ve al hacer scroll.
 */
.screen--join {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}

/* ---------------- Collage / reclamo ---------------- */

.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  min-height: 100dvh;
  padding: 48px;
  isolation: isolate;
}

.hero__collage {
  position: absolute;
  inset: 0;
  z-index: -2;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
}

.hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Unifica fotos de temperaturas distintas para que el collage no se vea
     como tres imagenes pegadas sino como una sola pieza. */
  filter: saturate(0.85) contrast(1.05);
}

.hero__img--main {
  grid-row: span 2;
}

/* Velo oscuro: sin esto el texto blanco no se lee sobre las zonas claras. */
.hero__collage::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgb(15 17 21 / 0.25) 0%,
    rgb(15 17 21 / 0.5) 45%,
    rgb(15 17 21 / 0.93) 100%
  );
}

.hero__content {
  max-width: 30rem;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgb(55 214 122 / 0.16);
  color: var(--speaking);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero__eyebrow::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--speaking);
  box-shadow: 0 0 0 0 rgb(55 214 122 / 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px rgb(55 214 122 / 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgb(55 214 122 / 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero__eyebrow::before {
    animation: none;
  }
}

.hero__title {
  margin: 0 0 14px;
  font-size: clamp(32px, 3.6vw, 52px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 20px rgb(0 0 0 / 0.5);
}

.hero__text {
  margin: 0 0 20px;
  font-size: 17px;
  line-height: 1.55;
  color: #cfd5df;
  text-shadow: 0 1px 10px rgb(0 0 0 / 0.5);
}

.hero__points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hero__points li {
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.07);
  backdrop-filter: blur(6px);
  font-size: 13px;
  color: #e3e8ef;
}

/* ---------------- Columna del acceso ---------------- */

.screen--join .card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100dvh;
  padding: 48px;
  background: var(--bg-elevated);
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  overflow-y: auto;
}

/* La columna es ancha, pero un formulario de dos campos con inputs de 600px
   se lee fatal: se limita el contenido y se centra. */
.screen--join .card > * {
  width: 100%;
  max-width: 400px;
}

.card__title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card__subtitle {
  margin: 0 0 24px;
  color: var(--text-dim);
  font-size: 15px;
}

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.field__input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(91 140 255 / 0.18);
}

.field__input::placeholder {
  color: #5c6575;
}

/* Campo con botón "Ver" dentro */
.field__with-toggle {
  position: relative;
  display: block;
}

.field__with-toggle .field__input {
  padding-right: 64px;
}

.field__toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.field__toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.field__input--code {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 600;
  font-size: 19px;
}

/* ---------------- Selector de avatar ---------------- */

.avatars {
  margin: 0;
  padding: 0;
  border: none;
}

.avatars .field__label {
  padding: 0;
  margin-bottom: 8px;
}

.avatars__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.avatar-btn {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}

.avatar-btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.avatar-btn[aria-checked='true'] {
  border-color: var(--accent);
  background: rgb(91 140 255 / 0.18);
  box-shadow: 0 0 0 2px rgb(91 140 255 / 0.25);
}

@media (max-width: 420px) {
  .avatars__grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ---------------- Botones ---------------- */

.btn {
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn--block {
  width: 100%;
}

.btn--primary {
  background: var(--accent-strong);
  color: #fff;
}

.btn--primary:not(:disabled):hover {
  background: var(--accent);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn--secondary:not(:disabled):hover {
  background: var(--surface-hover);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--surface);
}

/* ---------------- Estado / avisos ---------------- */

.status {
  margin: 0;
  min-height: 20px;
  font-size: 14px;
  color: var(--text-dim);
}

.status--error {
  color: #ff8a8d;
}

.status--ok {
  color: var(--speaking);
}

/* ---------------- Bloque de la profesora ---------------- */

.teacher {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.teacher__title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.teacher__subtitle {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.teacher__sep {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.teacher__help {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.teacher .field {
  margin-bottom: 12px;
}

.created {
  margin-top: 18px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.created__label {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.created__row {
  display: flex;
  gap: 8px;
}

.created__code {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--text-dim);
}

.created__code strong {
  color: var(--text);
  letter-spacing: 0.18em;
  font-size: 17px;
}

/* ---------------- Sala de clase ---------------- */

.screen--room {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.topbar__info {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.topbar__title {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__code {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__count {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge--live {
  background: rgb(55 214 122 / 0.14);
  color: var(--speaking);
}

.badge--warn {
  background: rgb(229 72 77 / 0.14);
  color: #ff8a8d;
}

/* ---------------- Mosaico ---------------- */

/*
 * Con un maximo de 7 personas el mosaico nunca pasa de 3 columnas, asi que
 * cada recuadro se mantiene grande. `auto-fit` + `minmax` reparte solo, y las
 * media queries ajustan el minimo segun el ancho.
 */
.grid {
  display: grid;
  gap: 10px;
  padding: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-content: center;
  overflow-y: auto;
}

/*
 * Vista destacada: una grande arriba y las demás en una tira pequeña debajo.
 * Se entra pulsando cualquier recuadro, y se sale pulsando el grande.
 */
.grid--destacada {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  grid-template-rows: minmax(0, 1fr);
  grid-auto-rows: 96px;
  align-content: stretch;
}

.grid--destacada .tile {
  aspect-ratio: auto;
}

.grid--destacada .tile--destacada {
  grid-column: 1 / -1;
  grid-row: 1;
}

/* En la tira, los nombres estorban más que ayudan. */
.grid--destacada .tile:not(.tile--destacada) .tile__footer {
  padding: 4px 6px;
}

.grid--destacada .tile:not(.tile--destacada) .tile__name {
  font-size: 11px;
}

.grid--destacada .tile:not(.tile--destacada) .tile__role,
.grid--destacada .tile:not(.tile--destacada) .tile__host-actions {
  display: none;
}

.grid--destacada .tile:not(.tile--destacada) .tile__initial {
  width: 40px;
  height: 40px;
  font-size: 17px;
}

.grid--destacada .tile--destacada .tile__initial--emoji {
  font-size: 76px;
}

.tile__hint {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgb(10 12 16 / 0.75);
  backdrop-filter: blur(4px);
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.tile--destacada .tile__hint {
  opacity: 1;
}

.tile {
  position: relative;
  aspect-ratio: 4 / 3;
  cursor: pointer;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.12s ease-out;
}

/* Indicador visual de quien esta hablando */
.tile--speaking {
  border-color: var(--speaking);
  box-shadow: 0 0 0 3px rgb(55 214 122 / 0.18);
}

.tile--local .tile__video {
  transform: scaleX(-1); /* efecto espejo solo en tu propia camara */
}

.tile__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0b0d11;
}

.tile__video--off {
  display: none;
}

/* Avatar con la inicial cuando la camara esta apagada */
.tile__avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
}

.tile__initial {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-strong);
  color: #fff;
  font-size: 30px;
  font-weight: 600;
}

/* Con emoji no hace falta el círculo de color: el dibujo ya destaca solo. */
.tile__initial--emoji {
  background: transparent;
  font-size: 52px;
}

.tile__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.72));
}

/* El dibujo elegido, junto al nombre, también con la cámara encendida. */
.tile__avatar-chip {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}

.tile__name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}

.tile__role {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-strong);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tile__muted {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--danger);
  font-size: 13px;
  flex-shrink: 0;
}

/* Controles de host que aparecen sobre cada recuadro */
/* Siempre visibles: escondidos tras un hover no los encontraba nadie. Se
   quedan discretos y se avivan al pasar por encima. */
.tile__host-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0.75;
  transition: opacity 0.15s;
}

.tile:hover .tile__host-actions,
.tile:focus-within .tile__host-actions {
  opacity: 1;
}

.tile-btn {
  padding: 5px 10px;
  border: none;
  border-radius: 8px;
  background: rgb(10 12 16 / 0.82);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.tile-btn:hover {
  background: rgb(10 12 16 / 0.95);
}

.tile-btn--danger:hover {
  background: var(--danger);
}

.tile-btn--ask:hover {
  background: var(--accent-strong);
}

/* ---------------- Asistencia ---------------- */

.attendance__form {
  display: flex;
  gap: 8px;
}

.attendance__form .field__input {
  flex: 1;
}

.attendance {
  margin-top: 16px;
}

.attendance__empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
}

.attendance__group {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.attendance__list {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.attendance__row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.attendance__name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attendance__meta {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.attendance__badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(55 214 122 / 0.16);
  color: var(--speaking);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------------- Aviso "activa tu micro" ---------------- */

.request {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  z-index: 10;
  width: calc(100% - 32px);
  max-width: 420px;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.55);
}

.request__text {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.45;
}

.request__actions {
  display: flex;
  gap: 8px;
}

.request__actions .btn {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
}

/* ---------------- Barra de controles ---------------- */

.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 74px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.ctrl:hover {
  background: var(--surface-hover);
}

.ctrl__label {
  font-size: 12px;
  font-weight: 500;
}

.ctrl__icon {
  font-size: 19px;
  line-height: 1;
}

/* Estado "apagado" de micro/camara */
.ctrl[aria-pressed="false"] {
  background: rgb(229 72 77 / 0.16);
  border-color: rgb(229 72 77 / 0.4);
  color: #ff8a8d;
}

.ctrl--danger {
  color: #ff8a8d;
}

.ctrl--danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.ctrl--host {
  border-color: rgb(91 140 255 / 0.4);
}

/* ---------------- Reacciones ---------------- */

.ctrl-wrap {
  position: relative;
}

/* La bandeja sale por encima del botón, como en Zoom o Meet. */
.reactions {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
}

.reaction-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
}

.reaction-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.18);
}

/* El emoji que sube flotando sobre el recuadro */
.floating {
  position: absolute;
  bottom: 56px;
  z-index: 5;
  font-size: 34px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  animation: subir 2.6s ease-out forwards;
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.5);
}

@keyframes subir {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.6);
  }
  12% {
    opacity: 1;
    transform: translateY(0) scale(1.15);
  }
  25% {
    transform: translateY(-14px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-190px) scale(1);
  }
}

/* Sin animación: el emoji aparece y se desvanece, sin recorrido. */
@media (prefers-reduced-motion: reduce) {
  .floating {
    animation: asomar 2.2s ease-out forwards;
  }

  @keyframes asomar {
    0%,
    100% {
      opacity: 0;
    }
    15%,
    70% {
      opacity: 1;
    }
  }
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.45);
}

/* ---------------- Responsive ---------------- */

/* Tablet y movil: el collage pasa a ser una banda superior y el acceso queda
   justo debajo, sin obligar a hacer scroll a ciegas. */
@media (max-width: 900px) {
  .screen--join {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 42vh;
    padding: 26px 24px;
  }

  .hero__collage {
    grid-template-columns: 1.3fr 1fr;
  }

  .hero__text,
  .hero__points {
    display: none; /* en vertical el espacio lo manda el formulario */
  }

  .hero__title {
    margin-bottom: 0;
  }

  .screen--join .card {
    min-height: 0;
    padding: 30px 24px 44px;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .hero {
    min-height: 34vh;
    padding: 20px;
  }

  .hero__eyebrow {
    margin-bottom: 12px;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    padding: 8px;
  }

  .tile__host-actions {
    opacity: 1; /* en tactil no hay hover */
  }

  /* Solo iconos. Con los 7 botones de la profesora, el texto obligaba a dos
     filas y se comía casi la mitad de la pantalla del móvil. */
  .controls {
    gap: 6px;
    padding: 10px 8px;
  }

  .ctrl {
    min-width: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .ctrl__label {
    display: none;
  }

  .ctrl__icon {
    font-size: 20px;
  }

  .card {
    padding: 26px 20px;
  }
}
