/* The build-it question types: atom, molecule, lewis.
 *
 * One sheet for the three because they share their parts — a stepper, a tile,
 * a "yours beside the right one" review. Loaded by the quiz player through
 * the types' `css` (science/question_types/molecule.py and lewis.py name it).
 * The Bohr picture itself is styled by science/bohr.css, which the atom type
 * names.
 *
 * Tokens only (.hdwk, science/tokens.css + the house tokens in theme.css).
 * Colour says what a thing IS, the same way everywhere on the page:
 *   tangerine  the nucleus, a charge, a cross, "not yet"
 *   teal/mint  electrons, "right"
 *   gold       where you are: the running count, a pressed control
 *   ink        outlines and dots
 * Every target is at least 44px and every word a student reads at least 16px.
 */

/* ------------------------------ shared ------------------------------ */

.hdwk .quiz-build__hint { font-size: 16px; color: var(--ink); margin: 0 0 14px; line-height: 1.45; }

.hdwk .quiz-build__count {
  margin: 14px 0 0; padding: 10px 14px; font-size: 17px; font-weight: 700; line-height: 1.4; color: var(--ink);
  background: var(--gold-soft); border: 2px solid var(--gold-line); border-radius: 12px;
}
.hdwk .quiz-build__count span { font-weight: 800; }
.hdwk .quiz-tiles__sym { white-space: nowrap; }

.hdwk .quiz-build__clear {
  appearance: none; cursor: pointer; margin-top: 12px; min-height: 44px; padding: 0 16px;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 12px;
}
.hdwk .quiz-build__clear:hover:not(:disabled) { background: var(--accent-soft); }
.hdwk .quiz-build__clear:disabled { opacity: .35; cursor: default; }
.hdwk .quiz-build__clear:focus-visible,
.hdwk .quiz-step__btn:focus-visible,
.hdwk .quiz-tiles__tile:focus-visible,
.hdwk .quiz-lewis__zone:focus-visible,
.hdwk .quiz-lewis__btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* A number with a minus and a plus either side: tap, or type it. */
.hdwk .quiz-step { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.hdwk .quiz-step + .quiz-step { margin-top: 8px; }
.hdwk .quiz-step__label { flex: 1 1 auto; font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.hdwk .quiz-step__label small { display: block; font-size: 16px; font-weight: 400; color: var(--muted); }
.hdwk .quiz-step__btn {
  appearance: none; cursor: pointer; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 12px;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  font-family: var(--font-display); font-size: 26px; font-weight: 800; line-height: 1;
  touch-action: manipulation;
}
.hdwk .quiz-step__btn:hover:not(:disabled) { background: var(--gold); }
.hdwk .quiz-step__btn:active:not(:disabled) { transform: translate(1px, 1px); }
.hdwk .quiz-step__btn:disabled { opacity: .3; cursor: default; }
.hdwk .quiz-step__value {
  flex: 0 0 auto; width: 64px; height: 48px; text-align: center; padding: 0 4px;
  font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 12px;
  -moz-appearance: textfield; appearance: textfield;
}
.hdwk .quiz-step__value::-webkit-outer-spin-button,
.hdwk .quiz-step__value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hdwk .quiz-step__value:focus { outline: none; box-shadow: 4px 4px 0 var(--gold); }

/* -------------------------------- atom -------------------------------- */

.hdwk .quiz-atom { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 860px) {
  .hdwk .quiz-atom { grid-template-columns: minmax(0, 1.1fr) minmax(300px, 1fr); gap: 24px; }
}
.hdwk .quiz-atom__stage {
  background: var(--cream); border: 2px solid var(--ink); border-radius: 18px; padding: 8px;
  max-width: 460px; width: 100%; justify-self: center;
}
/* In a question the picture is tapped, never dragged: a finger on it must
   still scroll the page, and a spinning electron is a moving target. */
.hdwk .quiz-atom .bohr-svg,
.hdwk .quiz-build-review .bohr-svg { touch-action: manipulation; cursor: pointer; }
.hdwk .quiz-atom .bohr-orbit,
.hdwk .quiz-build-review .bohr-orbit { animation: none; }
.hdwk .quiz-atom .bohr-electron { cursor: pointer; }
.hdwk .quiz-build-review .bohr-svg,
.hdwk .quiz-build-review .bohr-electron { cursor: default; }

.hdwk .quiz-atom__group { margin: 0 0 12px; padding: 12px 14px 14px; border-radius: 16px; border: 2px solid var(--line); min-width: 0; }
.hdwk .quiz-atom__group legend {
  float: none; width: auto; margin: 0; padding: 2px 12px; font-family: var(--font-mono); font-size: 16px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px;
  border: 2px solid var(--ink); color: var(--ink); background: var(--paper);
}
.hdwk .quiz-atom__group--nucleus { background: var(--accent-soft); border-color: var(--accent-line); }
.hdwk .quiz-atom__group--nucleus legend { background: var(--accent); }
.hdwk .quiz-atom__group--shells { background: var(--mint); border-color: var(--teal2); }
.hdwk .quiz-atom__group--shells legend { background: var(--color-primary-light); }

/* ------------------------------ molecule ------------------------------ */

.hdwk .quiz-tiles__target {
  display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin: 0 0 14px; padding: 8px 18px;
  font-family: var(--font-display); font-size: 34px; font-weight: 800; line-height: 1.2; color: var(--ink);
  background: var(--cream); border: 2px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--gold);
}
.hdwk .quiz-tiles__target small { font-family: var(--font-body); font-size: 17px; font-weight: 600; color: var(--muted); }
.hdwk .quiz-tiles__label { font-family: var(--font-mono); font-size: 16px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }

.hdwk .quiz-tiles__palette, .hdwk .quiz-tiles__tray { display: flex; flex-wrap: wrap; gap: 10px; }
.hdwk .quiz-tiles__palette { margin-bottom: 18px; }
.hdwk .quiz-tiles__tray {
  min-height: 84px; padding: 12px; align-content: flex-start;
  background: var(--soft); border: 2px dashed var(--ink); border-radius: 16px;
}
.hdwk .quiz-tiles__empty { margin: 0; align-self: center; font-size: 16px; color: var(--muted); }

.hdwk .quiz-tiles__tile {
  --tile: var(--gold);
  appearance: none; cursor: pointer; flex: 0 0 auto; min-width: 60px; height: 60px; padding: 0 12px;
  display: inline-grid; place-items: center; border-radius: 14px;
  border: 2px solid var(--ink); background: var(--tile); color: var(--ink);
  font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1;
  box-shadow: 3px 3px 0 var(--ink); touch-action: manipulation;
  transition: transform .1s ease, box-shadow .1s ease;
}
.hdwk .quiz-tiles__tile:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.hdwk .quiz-tiles__tile:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.hdwk .quiz-tiles__tile sub, .hdwk .quiz-tiles__tile sup,
.hdwk .quiz-tiles__target sub, .hdwk .quiz-tiles__target sup { font-size: .62em; font-weight: 800; }
/* A colour per tile so "the gold one" is a thing a pupil can say. Position
   in the palette decides it, so a distractor cannot be told by its colour. */
.hdwk .quiz-tiles__tile--c1 { --tile: var(--gold); }
.hdwk .quiz-tiles__tile--c2 { --tile: var(--cyan); }
.hdwk .quiz-tiles__tile--c3 { --tile: var(--accent); }
.hdwk .quiz-tiles__tile--c4 { --tile: var(--color-primary-light); }
.hdwk .quiz-tiles__tile--c5 { --tile: var(--cream); }
.hdwk .quiz-tiles__tile--c6 { --tile: var(--mint2); }
.hdwk .quiz-tiles__tile.is-placed { min-width: 52px; height: 52px; font-size: 21px; box-shadow: 2px 2px 0 var(--ink); }
.hdwk span.quiz-tiles__tile { cursor: default; }
.hdwk span.quiz-tiles__tile:hover, .hdwk span.quiz-tiles__tile:active { transform: none; box-shadow: 2px 2px 0 var(--ink); }

/* ------------------------------- lewis -------------------------------- */

.hdwk .quiz-lewis__row { margin: 0 0 16px; }
.hdwk .quiz-lewis__rowname {
  display: inline-block; margin: 0 0 10px; padding: 2px 14px; font-family: var(--font-mono); font-size: 16px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink);
  background: var(--cyan); border: 2px solid var(--ink); border-radius: 999px;
}
.hdwk .quiz-lewis__row--after .quiz-lewis__rowname { background: var(--gold); }
.hdwk .quiz-lewis__cards { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.hdwk .quiz-lewis__card {
  flex: 0 1 auto; min-width: 0; padding: 12px; text-align: center;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 18px;
}
.hdwk .quiz-lewis__name { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--muted); }

.hdwk .quiz-lewis__pic { position: relative; display: inline-flex; align-items: stretch; padding: 14px 26px 0 0; }
.hdwk .quiz-lewis__grid {
  display: grid; grid-template-columns: 52px 60px 52px; grid-template-rows: 52px 60px 52px;
  grid-template-areas: ". top ." "left symbol right" ". bottom ."; gap: 2px;
}
.hdwk .quiz-lewis__symbol {
  grid-area: symbol; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 36px; font-weight: 800; line-height: 1; color: var(--ink);
}
.hdwk .quiz-lewis__zone {
  appearance: none; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--paper); border: 2px dashed var(--line); border-radius: 14px; color: var(--ink);
  touch-action: manipulation;
}
.hdwk .quiz-lewis__zone:hover { background: var(--mint); border-color: var(--teal2); }
.hdwk .quiz-lewis__zone.has-marks { border-style: solid; border-color: var(--teal2); }
.hdwk .quiz-lewis__zone--top { grid-area: top; }
.hdwk .quiz-lewis__zone--bottom { grid-area: bottom; }
.hdwk .quiz-lewis__zone--left { grid-area: left; flex-direction: column; }
.hdwk .quiz-lewis__zone--right { grid-area: right; flex-direction: column; }
/* The same picture with nothing to tap: the review. */
.hdwk span.quiz-lewis__zone { cursor: default; border-color: transparent; background: transparent; }
.hdwk span.quiz-lewis__zone:hover { background: transparent; border-color: transparent; }

.hdwk .quiz-lewis__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); flex: 0 0 auto; }
.hdwk .quiz-lewis__cross {
  width: 14px; height: 14px; flex: 0 0 auto; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 24px; font-weight: 700; line-height: 1; color: var(--accent);
}

.hdwk .quiz-lewis__bracket { display: none; width: 12px; border: 4px solid var(--ink); flex: 0 0 auto; }
.hdwk .quiz-lewis__bracket--l { border-right: 0; margin-right: 4px; }
.hdwk .quiz-lewis__bracket--r { border-left: 0; margin-left: 4px; }
.hdwk .quiz-lewis__pic.is-bracketed .quiz-lewis__bracket { display: block; }
.hdwk .quiz-lewis__charge {
  position: absolute; top: 0; right: 0; min-width: 24px; text-align: left;
  font-family: var(--font-display); font-size: 22px; font-weight: 800; line-height: 1; color: var(--accent);
}

.hdwk .quiz-lewis__dots { margin: 8px 0 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.hdwk .quiz-lewis__controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.hdwk .quiz-lewis__set {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px; border-radius: 14px;
  background: var(--paper); border: 2px solid var(--line);
}
.hdwk .quiz-lewis__set--charge { background: var(--accent-soft); border-color: var(--accent-line); }
.hdwk .quiz-lewis__set--draw { background: var(--mint); border-color: var(--teal2); }
.hdwk .quiz-lewis__setname { padding: 0 6px; font-size: 16px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.hdwk .quiz-lewis__btn {
  appearance: none; cursor: pointer; min-width: 44px; min-height: 44px; padding: 0 12px; border-radius: 10px;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 700; line-height: 1; touch-action: manipulation;
}
.hdwk .quiz-lewis__btn:hover:not(:disabled) { background: var(--gold-soft); }
.hdwk .quiz-lewis__btn:disabled { opacity: .3; cursor: default; }
.hdwk .quiz-lewis__btn[aria-pressed="true"] { background: var(--ink); color: var(--gold); box-shadow: 3px 3px 0 var(--gold); }
.hdwk .quiz-lewis__btn--sign { font-family: var(--font-display); font-size: 24px; font-weight: 800; padding: 0; }

/* ------------------------------- review ------------------------------- */

.hdwk .quiz-build-review { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 10px; }
.hdwk .quiz-build-review__fig { margin: 0; padding: 10px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); min-width: 0; }
.hdwk .quiz-build-review__fig--given { background: var(--accent-soft); border-color: var(--accent-line); }
.hdwk .quiz-build-review__fig--key { background: var(--mint); border-color: var(--teal2); }
.hdwk .quiz-build-review__fig.is-right { background: var(--mint); border-color: var(--teal2); }
.hdwk .quiz-build-review__fig figcaption {
  font-family: var(--font-mono); font-size: 16px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink); margin-bottom: 8px;
}
.hdwk .quiz-build-review__fig .bohr-svg { max-width: 240px; margin: 0 auto; background: var(--paper); border-radius: 12px; }
.hdwk .quiz-build-review__words { margin: 8px 0 0; font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.hdwk .quiz-build-review__tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.hdwk .quiz-build-review__lewis { display: flex; flex-wrap: wrap; gap: 10px; }
.hdwk .quiz-build-review__lewis .quiz-lewis__card { padding: 8px; background: var(--paper); border-color: var(--line); }
.hdwk .quiz-build-review__lewis .quiz-lewis__grid { grid-template-columns: 34px 44px 34px; grid-template-rows: 34px 44px 34px; }
.hdwk .quiz-build-review__lewis .quiz-lewis__symbol { font-size: 26px; }
.hdwk .quiz-build-review__lewis .quiz-lewis__dot { width: 9px; height: 9px; }
.hdwk .quiz-build-review__lewis .quiz-lewis__zone { gap: 5px; }

.hdwk .quiz-build-review__marks { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; padding: 0; }
.hdwk .quiz-build-review__marks li {
  padding: 4px 12px; font-size: 16px; font-weight: 700; color: var(--ink); border-radius: 999px;
  border: 2px solid var(--ink); background: var(--color-primary-light);
}
.hdwk .quiz-build-review__marks li.is-missed { background: var(--paper); border-color: var(--accent); border-style: dashed; }
.hdwk .quiz-build-review__notes { margin: 0 0 4px; padding: 0 0 0 20px; font-size: 16px; line-height: 1.5; color: var(--ink); }
.hdwk .quiz-build-review__notes li + li { margin-top: 4px; }
.hdwk .quiz-build-review__held { font-size: 16px; color: var(--muted); margin: 6px 0 0; }

@media (max-width: 600px) {
  .hdwk .quiz-tiles__target { font-size: 30px; }
  .hdwk .quiz-lewis__card { flex: 1 1 100%; }
  .hdwk .quiz-build-review { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .hdwk .quiz-tiles__tile, .hdwk .quiz-step__btn { transition: none; }
}

/* Board mode: the same question at projector size. */
.quiz-board .quiz-step__label, .quiz-board .quiz-build__hint, .quiz-board .quiz-build__count { font-size: 21px; }
.quiz-board .quiz-tiles__tile { min-width: 76px; height: 76px; font-size: 30px; }
.quiz-board .quiz-tiles__target { font-size: 46px; }

/* The numbers in the nucleus are read on a phone, where the picture is about
   half its drawn size. */
.hdwk .quiz-atom .bohr-nucleus text,
.hdwk .quiz-build-review .bohr-nucleus text { font-size: 26px; }
