@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700&family=Public+Sans:wght@400;500;600&display=swap");

:root {
  --paper: #eceef6;
  --card: #ffffff;
  --ink: #12142b;
  --muted: #565b7a;
  --line: #d6d9ea;
  --accent: #5b43f0;
  --accent-soft: #f1f0ff;
  --accent-line: #d9d5ff;
  --accent-light: #b7acff;
  --accent-bright: #7662ff;
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Base ---------- */

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 16px;
  max-width: 62ch;
  margin-inline: auto;
}

b {
  font-weight: 600;
}

#jspsych-content {
  box-sizing: border-box;
  width: min(100% - 32px, 720px);
  margin: 8vh auto;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 12px 40px rgba(18, 20, 43, 0.08);
}

/* Contador "Audio X de Y" que se muestra bajo los botones */
#jspsych-content > p {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Pantallas finales (se escriben directamente en el body) */
body > h2,
body > p,
body > pre {
  width: min(100% - 32px, 640px);
  margin-inline: auto;
  box-sizing: border-box;
  text-align: center;
}

body > h2 {
  margin-top: 12vh;
}

body > pre {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: left;
  overflow-x: auto;
}

/* ---------- Barra de carga (preload) ---------- */

#jspsych-loading-progress-bar-container {
  height: 8px;
  width: min(100%, 320px);
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

#jspsych-loading-progress-bar {
  height: 8px;
  border-radius: 99px;
  background: var(--accent);
}

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

.jspsych-btn {
  min-width: 140px;
  margin: 8px;
  padding: 14px 26px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.jspsych-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.jspsych-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.jspsych-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.jspsych-btn:focus-visible,
.audio-control-button:focus-visible,
#audio-seek:focus-visible,
#confidence-slider:focus-visible,
#jspsych-content input:focus-visible,
#jspsych-content select:focus-visible,
#participant-justification:focus-visible {
  outline: 3px solid var(--accent-light);
  outline-offset: 2px;
}

/* ---------- Formularios (consentimiento y datos) ---------- */

#jspsych-content label {
  font-weight: 600;
}

#jspsych-content input:not([type="range"]):not([type="checkbox"]),
#jspsych-content select {
  width: min(100%, 360px);
  margin-top: 6px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

#jspsych-content input:not([type="range"]):not([type="checkbox"]):hover,
#jspsych-content select:hover {
  border-color: var(--muted);
}

#jspsych-content input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: -3px;
  accent-color: var(--accent);
}

/* ---------- Reproductor de audio ---------- */

.audio-source {
  display: none;
}

.audio-control-bar {
  display: grid;
  grid-template-columns: 44px 44px minmax(80px, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(100%, 560px);
  margin: 32px auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-sizing: border-box;
}

.audio-control-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 20px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.audio-control-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

/* Play / pausa: el botón principal del reproductor */
#audio-toggle {
  background: var(--accent-bright);
}

#audio-toggle:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--ink);
}

.audio-control-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* La barra de posición es solo indicativa: se dibuja como línea de tiempo con cursor */
#audio-seek {
  width: 100%;
  min-width: 0;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: default;
  -webkit-appearance: none;
  appearance: none;
}

#audio-seek:disabled {
  opacity: 1;
  cursor: default;
}

#audio-seek::-webkit-slider-runnable-track {
  height: 22px;
  border-radius: 2px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.32) 0 2px,
    transparent 2px 6px
  );
}

#audio-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 3px;
  height: 30px;
  margin-top: -4px;
  border: 0;
  border-radius: 2px;
  background: var(--accent-light);
}

#audio-seek::-moz-range-track {
  height: 22px;
  border-radius: 2px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.32) 0 2px,
    transparent 2px 6px
  );
}

#audio-seek::-moz-range-thumb {
  width: 3px;
  height: 30px;
  border: 0;
  border-radius: 2px;
  background: var(--accent-light);
}

#audio-time {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.85);
}

.break-minigame {
  width: 100%;
  max-width: 800px;
  margin: 16px auto 8px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.break-minigame.break-minigame-ending {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.break-transition {
  display: grid;
  min-height: 160px;
  place-content: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--ink);
  animation: break-transition-in 0.6s ease both;
}

.break-transition > span {
  color: var(--accent);
  font-size: 2rem;
}

.break-transition p {
  margin: 4px auto;
}

@keyframes break-transition-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#break-timer {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Grado de confianza ---------- */

.confidence-panel {
  width: min(100%, 560px);
  margin: 28px auto 8px;
  padding: 24px 20px;
  border: 1px solid var(--accent-line);
  border-radius: 14px;
  background: var(--accent-soft);
  box-sizing: border-box;
}

.confidence-panel[hidden] {
  display: none;
}

.confidence-panel > label {
  display: block;
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.confidence-endpoints {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

#confidence-slider {
  display: block;
  width: 100%;
  height: 28px;
  margin: 16px 0 8px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

#confidence-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 99px;
  background: var(--accent-line);
}

#confidence-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(18, 20, 43, 0.4);
}

#confidence-slider::-moz-range-track {
  height: 8px;
  border-radius: 99px;
  background: var(--accent-line);
}

#confidence-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(18, 20, 43, 0.4);
}

#confidence-value {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: center;
}

#confidence-done {
  display: block;
  margin: 16px auto 0;
}

/* ---------- Justificación ---------- */

#participant-justification {
  display: block;
  width: 100%;
  min-height: 140px;
  margin: 12px 0;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

#participant-justification:hover {
  border-color: var(--muted);
}

/* ---------- Responsive (mobile-first) ---------- */

/* Móvil (por defecto): todo apilado en una columna */
#jspsych-html-button-response-btngroup {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#jspsych-html-button-response-btngroup .jspsych-btn {
  width: 100%;
  min-width: 0;
  margin: 6px 0;
}

/* Móvil y tablet: todo más grande y fácil de tocar */
@media (max-width: 899px) {
  body {
    font-size: 1.125rem;
  }

  h2 {
    font-size: 2rem;
  }

  #jspsych-content {
    width: calc(100% - 24px);
    margin: 4vh auto;
    padding: 24px 18px;
  }

  #jspsych-content > p {
    font-size: 1rem;
  }

  .jspsych-btn {
    padding: 18px 26px;
    font-size: 1.15rem;
  }

  /* Reproductor */
  .audio-control-bar {
    grid-template-columns: 56px 56px minmax(60px, 1fr) auto;
    gap: 12px;
    padding: 14px 16px;
  }

  .audio-control-button {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  #audio-time {
    font-size: 1rem;
  }

  #audio-seek {
    height: 36px;
  }

  #audio-seek::-webkit-slider-runnable-track {
    height: 28px;
  }

  #audio-seek::-webkit-slider-thumb {
    height: 36px;
    margin-top: -4px;
  }

  #audio-seek::-moz-range-track {
    height: 28px;
  }

  #audio-seek::-moz-range-thumb {
    height: 36px;
  }

  /* Confianza */
  .confidence-panel > label {
    font-size: 1.3rem;
  }

  .confidence-endpoints {
    font-size: 1rem;
  }

  #confidence-slider {
    height: 44px;
  }

  #confidence-slider::-webkit-slider-thumb {
    width: 38px;
    height: 38px;
    margin-top: -15px;
  }

  #confidence-slider::-moz-range-thumb {
    width: 30px;
    height: 30px;
  }

  #confidence-value {
    font-size: 2.6rem;
  }

  /* Formularios (16px o más evita el zoom automático en iPhone) */
  #jspsych-content input:not([type="range"]):not([type="checkbox"]),
  #jspsych-content select {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1rem;
  }

  #jspsych-content input[type="checkbox"] {
    width: 24px;
    height: 24px;
    vertical-align: -5px;
  }

  #participant-justification {
    font-size: 1.1rem;
  }
}

/* Móviles pequeños: el tiempo del audio pasa a una segunda fila */
@media (max-width: 460px) {
  .audio-control-bar {
    grid-template-columns: 56px 56px minmax(60px, 1fr);
  }

  #audio-time {
    grid-column: 1 / -1;
    text-align: center;
  }
}

/* Ordenador (pantallas anchas): tarjeta más ancha y botones en fila */
@media (min-width: 900px) {
  #jspsych-content {
    width: min(100% - 64px, 960px);
  }

  #jspsych-html-button-response-btngroup {
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }

  #jspsych-html-button-response-btngroup .jspsych-btn {
    width: auto;
    min-width: 180px;
    margin: 8px;
  }

  .audio-control-bar,
  .confidence-panel {
    width: min(100%, 680px);
  }
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---------- Gif / imagen decorativa ---------- */
 
.page-gif {
  display: block;
  width: min(100% - 32px, 360px);
  height: auto;
  margin: 24px auto;
  border-radius: 12px;
}