/* Stile dell'app RQ3: pagine semplici, pulsanti grandi per il tablet. */
:root {
  --bg: #f7f4ee;
  --fg: #1d2a33;
  --muted: #5d6b73;
  --accent: #2f4858;
  --accent-fg: #ffffff;
  --line: #d9d3c7;
  --ok: #2e7d4f;
  --err: #b3261e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

main.wide { max-width: 1240px; }

/* Schermate del visitatore: i pulsanti per andare avanti stanno a fondo pagina */
main:not(.operator) { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
main:not(.operator) > .actions, main:not(.operator) > .bottom { margin-top: auto; padding-top: 28px; }

h1 { font-size: 1.6rem; margin: 0 0 16px; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
p { margin: 0 0 14px; }

button {
  font: inherit;
  min-height: 48px;
  min-width: 48px;
  padding: 8px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.4; cursor: default; }
button.secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
button.big { min-height: 64px; font-size: 1.1rem; width: 100%; }

.ok { color: var(--ok); }
.err { color: var(--err); }
.muted { color: var(--muted); }

pre {
  white-space: pre-wrap;
  font-size: 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

/* Player */
.player {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.player-label { font-weight: 600; margin-bottom: 10px; }
.player-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.player-play { min-width: 120px; }
.player-back { min-width: 120px; }
.player-time { font-variant-numeric: tabular-nums; color: var(--muted); margin-left: auto; }
.player-seek { display: block; width: 100%; height: 44px; margin: 10px 0 0; accent-color: var(--accent); }
.player-disabled .player-label { color: var(--muted); }
.player-error { color: var(--err); margin-top: 8px; font-size: 0.9rem; }

/* Percorso del visitatore */
.lead { font-size: 1.1rem; }
.note { color: var(--muted); font-size: 0.95rem; }
.stack { display: flex; flex-direction: column; gap: 14px; margin: 20px 0; }
.steps { padding-left: 1.4em; margin: 0 0 16px; }
.steps li { margin-bottom: 8px; }
.actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 16px;
  margin-top: 28px;
}
.actions button { min-width: 160px; }
.counter { margin: 0 auto 0 0; color: var(--muted); }

/* Pulsanti a scelta (descrizioni, opzioni, scala) */
button.opt, button.card {
  background: #fff;
  color: var(--fg);
  border: 2px solid var(--line);
}
button.card { text-align: left; padding: 16px 20px; line-height: 1.45; }
button.opt[aria-pressed="true"], button.card[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e3ebef;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.choices { display: flex; gap: 12px; }
.choices button { flex: 1 1 0; }
.scale { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.scale button { padding: 8px 0; font-variant-numeric: tabular-nums; }
.scale-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.95rem; margin-top: 6px; }

/* Domande */
.question { margin: 0 0 24px; }
.q { font-weight: 600; margin: 0 0 10px; display: block; }
.questions { margin: 20px 0 0; }
textarea {
  display: block; width: 100%; margin-top: 10px;
  font: inherit; font-weight: normal; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--fg);
}

/* Prova: dipinto e guide */
.trial { display: block; }
.painting { margin: 0 0 16px; }
.painting img {
  display: block; width: 100%; max-height: 42vh; object-fit: contain;
  background: #ebe6dc; border-radius: 10px;
}
.painting figcaption { margin-top: 12px; }
.painting h1 { margin: 0 0 4px; }
.kicker { color: var(--muted); margin: 0 0 8px; font-size: 0.95rem; }
.artist { color: var(--muted); margin: 0; }

/* iPad orizzontale: dipinto a sinistra, guide e domande a destra */
@media (orientation: landscape) and (min-width: 960px) {
  .trial { display: grid; grid-template-columns: 5fr 6fr; gap: 32px; align-items: start; }
  .painting { position: sticky; top: 24px; }
  .painting img { max-height: 62vh; }
}

/* Operatore */
main.operator button.big { max-width: 420px; margin: 16px 0 8px; }
.op-corner {
  position: fixed; top: env(safe-area-inset-top, 0); right: env(safe-area-inset-right, 0);
  width: 80px; height: 80px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.op-corner::after {
  content: ''; position: absolute; top: 24px; right: 24px; width: 14px; height: 14px;
  border-radius: 50%; border: 2px solid var(--line);
}
.op-corner.holding::after { background: var(--accent); border-color: var(--accent); transition: background 2s linear; }
.op-corner[hidden], .op-panel[hidden], form[hidden], .op-overlay[hidden] { display: none; }
#op-abort-corner { z-index: 10; }
/* PIN dell'operatore sopra una schermata del visitatore */
.op-overlay {
  position: fixed; z-index: 11; top: calc(env(safe-area-inset-top, 0px) + 16px); right: 16px; left: 16px;
  max-width: 480px; margin-left: auto; padding: 16px;
  background: var(--bg, #fff); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.op-overlay > p { margin: 0 0 4px; font-weight: 600; }
.op-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 12px; }
.op-row p { margin: 0; }
.op-row input {
  font: inherit; min-height: 48px; padding: 8px 12px; min-width: 200px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--fg);
}
.op-panel { border-top: 1px solid var(--line); margin-top: 24px; }
.op-list { font-size: 0.9rem; max-height: 260px; overflow: auto; margin: 0 0 12px; }
a.op-download { display: inline-block; margin: 0 0 12px; font-weight: 600; color: var(--accent); }
.op-status p { margin: 0 0 4px; font-size: 0.95rem; }
