/*
 * Styles for the written-division "caja" worksheet (shared/division-grid.js,
 * DivisionGrid). Used by dividir/ and creador/. The digit boxes themselves
 * (.ws-input, .ws-good, .ws-bad...) live in shell.css.
 */
.dgrid {
  --digit: clamp(22px, 6vw, 38px);
  display: grid;
  grid-template-columns: repeat(var(--dcols, 3), var(--digit)) auto;
  grid-auto-rows: minmax(var(--digit), auto);
  gap: 6px 4px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .58);
  border: 2px solid #fff;
  border-radius: 18px;
  box-shadow: 0 6px 0 rgba(122, 67, 128, .18), inset 0 2px 6px rgba(0, 0, 0, .08);
  font-variant-numeric: tabular-nums;
}

.dg-dividend { display: contents; }
.dg-dcell {
  font: inherit;
  font-size: var(--digit);
  color: var(--purple-dark);
  text-shadow: 2px 2px 0 #fff;
  background: none;
  border: none;
  border-bottom: 4px solid transparent;
  padding: 0 0 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dg-dcell.dg-sel { border-bottom-color: var(--purple); }
.dg-dcell.dg-locked { border-bottom-color: var(--green); cursor: default; }
.dg-dcell:disabled { cursor: default; }
.dg-dcell.dg-nudge { animation: dg-nudge 0.5s ease-in-out 2; }
@keyframes dg-nudge {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) { .dg-dcell.dg-nudge { animation: none; border-bottom-color: var(--purple); } }

/* The divisor sits in an "L": a short vertical line beside it (as tall
   as the dividend row, not the whole worksheet) and a line under it that
   reaches over the full quotient, which is written below that line. */
.dg-bracket {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-left: 6px;
}
.dg-divisor {
  font-size: var(--digit);
  color: var(--purple-dark);
  text-shadow: 2px 2px 0 #fff;
  border-left: 4px solid var(--purple-dark);
  border-bottom: 4px solid var(--purple-dark);
  padding: 0 10px 4px 12px;
  letter-spacing: .12em;
  text-align: left;
}
.dg-vdigit { display: inline-block; }
.dg-qrow { display: flex; gap: 4px; padding-left: 16px; padding-right: 6px; }

.dg-row { display: flex; gap: 4px; align-items: center; }
.dg-bring {
  width: var(--digit);
  min-height: 1.34em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--digit);
  color: var(--purple-dark);
  text-shadow: 2px 2px 0 #fff;
}
/* "siempre subrayamos el que baja": the brought-down digit is underlined */
.dg-bring:not(:empty) { border-bottom: 3px solid var(--purple); }
.dg-bring.dg-drop { animation: dgDrop .35s ease-out; }
@keyframes dgDrop {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.dgrid .ws-input.dg-qbox { width: var(--digit); min-height: 1.34em; }
/* one column per possible remainder digit (the divisor's length), so
   remainder digits line up under the dividend's columns */
.dgrid .ws-input.dg-rembox {
  width: calc(var(--rdigits, 1) * var(--digit) + (var(--rdigits, 1) - 1) * 4px);
  min-height: 1.34em;
}
.dg-rdigit { flex: 1; text-align: center; }
.dgrid .ws-input.dg-qbox { background: #fff9ec; }

.dg-dim { opacity: .32; pointer-events: none; transition: opacity .3s; }

.dg-prueba {
  font-size: clamp(14px, 3vw, 18px);
  color: var(--green);
  font-weight: bold;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s, transform .3s;
}
.dg-prueba.show { opacity: 1; transform: translateY(0); }

/* Pizarra digital mode (shared/pizarra.js): grow with the board's height. */
html.is-pizarra .dgrid { --digit: calc(var(--pz-vh) * 6.5); }

/* Tutorial chalk circles (DivisionGrid ring*): the digits the teacher
   circles to estimate a quotient digit - the divisor's first digit and the
   front of the number being divided. */
.dg-ring {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
  border-radius: 999px;
}
