/* Diagram drag & drop — styles for the public practice pages (copied from the ITTO styles).
   Everything is scoped under #itto so the site's own styles and these
   styles don't interfere with each other. */

#itto {
  --itto-purple: #800080;
  --itto-tray: #ffffdd;
  --itto-slot: #ffffcc;
  --itto-correct: #99ff33;
  --itto-wrong: #ff6b6b;
  max-width: 900px;
  margin: 0 auto;
  container-type: inline-size;       /* sizes below scale with this box */
  font-family: Verdana, "Lucida Grande", sans-serif;
  color: #333;
  text-align: left;
  line-height: 1.3;
}
#itto *, #itto *::before, #itto *::after { box-sizing: border-box; }

/* Neutralise site styles on the elements the exercise uses */
#itto h1, #itto h2, #itto p {
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.25;
  font-weight: bold;
}
#itto p { font-weight: normal; }
#itto button {
  font-family: Arial, sans-serif;
  text-transform: none;
  letter-spacing: normal;
  text-decoration: none;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}
#itto img { max-width: none; border: 0; }

/* ---- Header ---- */
#itto .itto-title {
  text-align: center;
  padding: 8px 12px;
  background: #ebedf2;
  border: 2px solid var(--itto-purple);
  margin: 0 0 12px;
}
#itto .itto-title h1 {
  margin: 8px 0;
  color: var(--itto-purple);
  font-size: 22px; font-size: clamp(16px, 3cqw, 24px);
}
#itto .itto-subtitle { font-size: 12px; color: #666; margin: 0 0 4px; font-weight: normal; }
#itto .itto-instructions {
  text-align: center;
  color: var(--itto-purple);
  font-size: 14px; font-size: clamp(12px, 1.8cqw, 15px);
  margin: 0 0 8px;
}
#itto .itto-status {
  text-align: center;
  min-height: 1.4em;
  font-size: 13px; font-size: clamp(12px, 1.6cqw, 14px);
  margin: 4px 0 8px;
}
#itto .itto-status.good { color: #2a7a00; }
#itto .itto-status.bad { color: #b00020; }

/* ---- Card tray ---- */
#itto .itto-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px; gap: 0.8cqw;
  justify-content: center;
  min-height: 50px; min-height: 6cqw;
  padding: 12px; padding: 1.5cqw;
  background: var(--itto-tray);
  border: 1px solid #333;
  border-radius: 10px;
  box-shadow: 0 0 .3em rgba(0,0,0,.6);
  margin: 0 0 12px; margin-bottom: 1.5cqw;
}

/* Card and space share one size. The engine sets --itto-w, --itto-h and
   --itto-fs as fractions of the diagram width, so they scale together. */
#itto .itto-card, #itto .itto-slot, .itto-ghost {
  width: 98px; height: 24px; font-size: 9.2px;          /* older browsers */
  width: calc(var(--itto-w, 0.1134) * 100cqw);
  height: calc(var(--itto-h, 0.0271) * 100cqw);
  font-size: calc(var(--itto-fs, 0.0106) * 100cqw);
  line-height: 1.1;
  font-family: Arial, sans-serif;
  font-weight: normal;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 2px;
  overflow: hidden;
  color: #000;
  white-space: pre-line;             /* keeps line breaks in multi-line answers */
}
#itto .itto-card.multi, #itto .itto-slot.multi, .itto-ghost.multi {
  justify-content: flex-start;
  text-align: left;
  padding: 0 4px;
}
#itto .itto-card {
  background: #fff;
  border: 1px solid #333;
  border-radius: 2px;
  cursor: grab;
  touch-action: none;                /* lets touch drag instead of scroll */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#itto .itto-card:focus-visible, #itto .itto-slot:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 1px;
}
#itto .itto-card.selected {
  outline: 3px solid var(--itto-purple);
  outline-offset: 1px;
  background: #f3e6f3;
}
#itto .itto-card.dragging-source { opacity: 0.3; }
#itto .itto-card.shake { animation: itto-shake 0.35s; }

/* Floating copy that follows the finger or mouse (lives outside #itto) */
.itto-ghost {
  position: fixed;
  z-index: 100000;
  pointer-events: none;
  background: #fff;
  border: 1px solid #333;
  border-radius: 2px;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  margin: 0;
  box-sizing: border-box;
}

/* ---- Diagram ---- */
#itto .itto-stage {
  position: relative;
  width: 100%;
  height: 0;
  padding: 0;                        /* padding-top is set by the engine */
}
#itto .itto-stage img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}
#itto .itto-slot {
  position: absolute;
  background: var(--itto-slot);
  border: 1px dashed #c9c38a;
  border-radius: 0;
  cursor: pointer;
}
#itto .itto-slot.hovered { background: #bbb; }
#itto .itto-slot.filled {
  background: var(--itto-correct);
  border: 1px solid #333;
  cursor: default;
  opacity: 1;
}
#itto .itto-slot.flash-wrong { animation: itto-flash-wrong 0.5s; }

/* ---- Success message ---- */
#itto .itto-success {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: #ddffdd;
  border: 2px solid #333;
  border-radius: 10px;
  box-shadow: .3em .3em .5em rgba(0,0,0,.6);
  padding: 20px 28px;
  text-align: center;
  min-width: 260px;
}
#itto .itto-success[hidden] { display: none; }
#itto .itto-success h2 { margin: 0 0 6px; font-size: 22px; color: #333; }
#itto .itto-success p { margin: 0 0 14px; font-size: 14px; }
#itto .itto-success button, #itto .itto-panel button {
  font-family: Verdana, sans-serif;
  font-size: 15px;
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #fff;
  color: #000;
  cursor: pointer;
  width: auto;
  height: auto;
}

@keyframes itto-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@keyframes itto-flash-wrong {
  0%, 100% { background: var(--itto-slot); }
  30% { background: var(--itto-wrong); }
}
@media (prefers-reduced-motion: reduce) {
  #itto .itto-card.shake, #itto .itto-slot.flash-wrong { animation: none; }
}

/* ---- Layout mode (authors only: add #layout to the page address) ---- */
#itto .itto-mode-link { text-align: right; font-size: 12px; margin-top: 10px; }
#itto .itto-mode-link a { color: #666; }
#itto.layout .itto-tray, #itto.layout .itto-instructions, #itto.layout .itto-status { display: none; }
#itto .itto-panel { display: none; }
#itto.layout .itto-panel {
  display: block;
  border: 2px solid #1a73e8;
  background: #eef4ff;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
#itto .itto-panel h2 { font-size: 16px; margin: 0 0 6px; color: #1a4fa0; }
#itto .itto-panel p { margin: 4px 0; font-size: 13px; }
#itto .itto-panel .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
#itto .itto-panel button { font-size: 13px; padding: 6px 12px; border-color: #1a4fa0; }
#itto .itto-panel textarea {
  width: 100%; height: 110px; margin-top: 8px;
  font-family: Menlo, Consolas, monospace; font-size: 12px;
}
#itto .itto-sel-info { font-weight: bold; }
#itto.layout .itto-slot {
  background: rgba(255, 255, 204, 0.85);
  border: 1px solid #1a73e8;
  cursor: move;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  color: #1a3a6a;
}
#itto.layout .itto-slot.chosen { outline: 3px solid #d93025; outline-offset: 1px; z-index: 5; }
#itto.layout .itto-slot.moved { border-color: #d93025; }

/* ---- Public pages: footer and phone hint ---- */
#itto .itto-footer { margin-top: 22px; padding-top: 10px; border-top: 1px solid #ccc; text-align: center; font-size: 13px; }
#itto .itto-footer p { margin: 4px 0; font-weight: normal; }
#itto .itto-footer a { color: var(--itto-purple); }
#itto .itto-footer .itto-legal { font-size: 11px; color: #777; }
#itto .itto-rotate { display: none; text-align: center; font-size: 13px; color: #555; margin: 0 0 8px; }
@media (max-width: 600px) and (orientation: portrait) { #itto .itto-rotate { display: block; } }
