@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:  #2e7d32;
  --rose:   #ad1457;
  --text:   #1a1a1a;
  --bg:     #ffffff;
  --font:   'Consolas', 'JetBrains Mono', 'Courier New', monospace;
  --size:   15px;
  --lh:     1.7;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--size);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Canvas ──────────────────────────────────────────────────── */
#canvas {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ── Storico ─────────────────────────────────────────────────── */
#history {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 12px;
}
#history::-webkit-scrollbar { width: 3px; }
#history::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

/* ── Turni ───────────────────────────────────────────────────── */
.turn {
  display: flex;
  align-items: flex-start;
  margin-bottom: 3px;
}

.turn-label {
  flex-shrink: 0;
  white-space: nowrap;
  user-select: none;
}

/* indages: tutto verde — label E contenuto */
.turn.is-indages .turn-label   { color: var(--green); }
.turn.is-indages .turn-content { color: var(--green); }

/* utente: rosa */
.turn.is-user .turn-label   { color: var(--rose); }
.turn.is-user .turn-content { color: var(--text); }

/* prompt neutro durante fase nome */
.turn.is-prompt .turn-label   { color: var(--green); }
.turn.is-prompt .turn-content { color: var(--text); }

.turn-content {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* Markdown verde per indages */
.turn.is-indages .turn-content p  { margin: 0 0 3px; }
.turn.is-indages .turn-content p:last-child { margin-bottom: 0; }
.turn.is-indages .turn-content h1,
.turn.is-indages .turn-content h2,
.turn.is-indages .turn-content h3 {
  font-size: var(--size);
  font-weight: 600;
  margin: 8px 0 2px;
  color: var(--green);
}
.turn.is-indages .turn-content ul,
.turn.is-indages .turn-content ol { padding-left: 2ch; margin: 3px 0; }
.turn.is-indages .turn-content li { margin: 1px 0; }
.turn.is-indages .turn-content a  {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.turn.is-indages .turn-content strong { font-weight: 600; color: var(--green); }
.turn.is-indages .turn-content em     { font-style: italic; }
.turn.is-indages .turn-content code {
  background: #f1f8f1;
  padding: 0 4px;
  border-radius: 3px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--green);
}
.turn.is-indages .turn-content pre {
  background: #f1f8f1;
  border-left: 2px solid var(--green);
  padding: 10px 14px;
  margin: 6px 0;
  overflow-x: auto;
  font-size: 13px;
  color: var(--green);
}
.turn.is-indages .turn-content pre code { background: none; padding: 0; }
.turn.is-indages .turn-content blockquote {
  border-left: 2px solid var(--green);
  padding-left: 10px;
  opacity: .75;
  margin: 4px 0;
}
.turn.is-indages .turn-content table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
}
.turn.is-indages .turn-content th,
.turn.is-indages .turn-content td {
  border: 1px solid #a5d6a7;
  padding: 3px 10px;
}
.turn.is-indages .turn-content th { background: #e8f5e9; }

/* marcatori epistemici */
.ep-doc { font-weight: 700; }
.ep-inf { opacity: .8; }
.ep-unv { font-style: italic; }

/* ── Cursore ─────────────────────────────────────────────────── */
.cursor {
  display: inline-block;
  width: 0.5ch;
  height: 1em;
  background: var(--green);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink .75s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Indicatore tool ─────────────────────────────────────────── */
.tool-line {
  color: var(--green);
  opacity: .55;
  font-size: 13px;
  margin-bottom: 2px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.35} 50%{opacity:.7} }

/* ── Azioni turno ────────────────────────────────────────────── */
.turn-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  opacity: 0;
  transition: opacity .15s;
}
.turn:hover ~ .turn-actions,
.turn-actions:hover { opacity: 1; }
.turn-action {
  font-family: var(--font);
  font-size: 12px;
  color: #b0bec5;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.turn-action:hover { color: var(--green); }

/* ── Input (fissa in basso) ──────────────────────────────────── */
#input-line {
  display: flex;
  align-items: flex-start;
  padding: 10px 0 20px;
  border-top: 1px solid #f0f0f0;
}

#input-label {
  flex-shrink: 0;
  white-space: nowrap;
  color: var(--rose);
  padding-top: 1px;
}
#input-label.phase-name { color: var(--green); }

#input-field {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--size);
  line-height: var(--lh);
  color: var(--text);
  caret-color: var(--rose);
  overflow: hidden;
  min-height: calc(var(--size) * var(--lh));
}
#input-field.phase-name { caret-color: var(--green); }

/* ── Mascotte mano ───────────────────────────────────────────── */
#hand-mascot {
  position: fixed;
  width: 58px;
  z-index: 300;
  cursor: grab;
  user-select: none;
  transition: left .45s cubic-bezier(.4,0,.2,1),
              top  .45s cubic-bezier(.4,0,.2,1);
  filter: drop-shadow(1px 2px 6px rgba(0,0,0,.18));
}
#hand-mascot:hover  { filter: drop-shadow(1px 2px 10px rgba(66,133,244,.35)); }
#hand-mascot:active { cursor: grabbing; }

/* ogni dito ruota intorno alla propria base */
.mano-dito {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform .38s cubic-bezier(.4,0,.2,1);
}

/* ── Gestures ── */

/* open: tutte le dita estese (default) */
.mano-dito { transform: rotate(0deg); }

/* pointing: solo indice su */
.gesto-pointing .mano-dito { transform: rotate(90deg); }
.gesto-pointing #fm-index  { transform: rotate(0deg); }

/* fist: tutte chiuse */
.gesto-fist .mano-dito { transform: rotate(92deg); }

/* peace ✌ */
.gesto-peace .mano-dito  { transform: rotate(90deg); }
.gesto-peace #fm-index   { transform: rotate(0deg); }
.gesto-peace #fm-middle  { transform: rotate(0deg); }

/* thumbs: pollice su — mano ruotata, dita chiuse */
.gesto-thumbs .mano-dito { transform: rotate(92deg); }

/* beckoning: indice che chiama */
.gesto-beckoning .mano-dito { transform: rotate(90deg); }
.gesto-beckoning #fm-index  { animation: beckon 1.1s ease-in-out infinite; }
@keyframes beckon {
  0%,100% { transform: rotate(0deg); }
  50%      { transform: rotate(60deg); }
}

/* wave: tutta la mano oscilla */
.gesto-wave { animation: wave .7s ease-in-out 3 forwards; }
@keyframes wave {
  0%,100% { transform: rotate(0deg) scale(1); }
  30%      { transform: rotate(-22deg) scale(1.05); }
  70%      { transform: rotate(22deg) scale(1.05); }
}

/* tooltip gesture name */
#hand-mascot::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: #222;
  color: #fff;
  font-size: 10px;
  font-family: var(--font);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
#hand-mascot:hover::after { opacity: 1; }

/* ── Artefatti ───────────────────────────────────────────────── */
.artifact {
  margin: 8px 0;
  border-left: 2px solid var(--green);
  padding-left: 14px;
  opacity: .9;
}
.artifact-label {
  font-size: 11px;
  color: var(--green);
  opacity: .6;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.artifact canvas { max-width: 100%; max-height: 260px; }
.map-container   { height: 240px; }
.slide-card      { display: none; }
.slide-card.active { display: block; }
.slide-card h3   { font-weight: 600; margin-bottom: 3px; color: var(--green); }
.slides-nav { display: flex; gap: 8px; margin-top: 6px; font-size: 12px; }
.slides-nav button {
  background: none;
  border: 1px solid #a5d6a7;
  padding: 1px 8px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  color: var(--green);
}
.data-warning { font-size: 11px; color: #e65100; margin-top: 3px; }
