/* !
 * Revise Science quiz engine — rs-dotcross.css v2.0.1
 * v2.0.1 (5 Dec 2026): section 9, the fit layout (rs-dotcross.js v2.0.1, cfg.fit): quiz questions and the
 * Dot-and-cross explorer.
 * Styles for the dot-and-cross diagram builder (quiz questions and revision pages).
 * Order: desktop first, then tablet (≤900px), phone (≤600px), very narrow (≤340px).
 * © 2026 revisescience.org.uk | All rights reserved.
 * This code, its question banks and the dot-and-cross builder are licensed
 * for use only on revisescience.org.uk. Copying, redistribution or reuse
 * elsewhere is not permitted without written permission. */

/* ===== 1. Colours (electron and region colours carry meaning) ========= */

.dac {
  --ink: #1f2937;
  --muted: #5b6475;
  --line: #dce1ea;
  --ring: #93c5fd;
  --dot: #111827;
  --cross: #111827;
  --over: rgba(59, 130, 246, 0.20);
  --focus: #185abc;
  font-family: var(--font-sans, "ABeeZee", "Lexend", Calibri, sans-serif);
  color: var(--ink);
}

.dac[hidden], .dac [hidden] {
  display: none !important;
}

/* Two-atom diagrams: atom A red, atom B blue, shared region lilac */

.dac[data-binary="true"] {
  --dot: #991b1b;
  --cross: #1e40af;
  --ringA: #991b1b;
  --ringB: #1e40af;
  --over: #ede9fe;
}

.dac[data-binary="true"] .zone.zone-a {
  background: #fee2e2;
}

.dac[data-binary="true"] .zone.zone-b {
  background: #dbeafe;
}

.dac[data-binary="true"] .zone.zone-shared {
  background: #ede9fe;
}

/* Polyatomic templates: central atom red, outer atoms blue, shared purple */

.dac[data-poly="true"] {
  --over: rgba(147, 51, 234, 0.18);
  --panel-shared: rgba(147, 51, 234, 0.12);
  --elA: #991b1b;
  --elB: #1e40af;
  --elN: #1e40af;
  --ringCentral: #b91c1c;
  --ringTerm: #1d4ed8;
  --panel-central: rgba(248, 113, 113, 0.18);
  --panel-term: rgba(191, 219, 254, 0.18);
}

.dac[data-poly="true"] .zone.central {
  background-color: var(--panel-central);
}

.dac[data-poly="true"] .zone.terminal {
  background-color: var(--panel-term);
}

.dac[data-poly="true"] .zone.shared {
  background-color: var(--panel-shared);
}

/* HCN has two different shared regions: controls match the diagram colours */

.dac[data-template="HCN"][data-poly="true"] {
  --over-hc: var(--over);
  --over-cn: rgba(250, 204, 21, 0.28);
  --panel-hc: var(--panel-shared);
  --panel-cn: rgba(250, 204, 21, 0.18);
}

.dac[data-template="HCN"][data-poly="true"] .zone.shared.pair-hc {
  background: var(--panel-hc);
  border: 1px solid rgba(99, 102, 241, .28);
}

.dac[data-template="HCN"][data-poly="true"] .zone.shared.pair-cn {
  background: var(--panel-cn);
  border: 1px solid rgba(202, 138, 4, .32);
}

/* ===== 2. Model choice bar ============================================ */

.dac-step1 {
  margin: 0 0 10px;
}

.dac .bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
}

.dac .toggle, .dac .hintbtn {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.2;
  cursor: pointer;
}

.dac .toggle[aria-pressed="true"] {
  background: #eff6ff;
  border-color: #2b6cb0;
  box-shadow: inset 0 0 0 1px #2b6cb0;
}

.dac .hintbtn {
  border-color: #c2410c;
  color: #9a3412;
}

.dac .hintbtn[disabled] {
  cursor: default;
  background: #fde68a;
  border-color: #f59e0b;
  color: #000;
}

.dac :is(button, input):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Waiting for a model to be chosen */

.dac.is-waiting .result {
  background: #e8f5ec;
  border: 1px solid #1b7a3d;
  color: #102a43;
  text-align: center;
  font-size: 1.05rem;
  padding: 16px;
}

.dac.is-waiting .bar .toggle {
  border-color: #2b6cb0;
  color: #1d4f8a;
  animation: dac-pulse 2s infinite;
}

.dac.is-waiting .bar .toggle:nth-child(2) {
  animation-delay: .3s;
}

.dac-wait-note {
  font-size: .9em;
  color: var(--muted);
}

@keyframes dac-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(43, 108, 176, .4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(43, 108, 176, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(43, 108, 176, 0);
  }
}

/* In-page "Change bonding model?" confirmation */

.dac .mode-switch-confirm {
  margin: 8px 0 10px;
  padding: 11px 12px;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  background: #fffbeb;
  line-height: 1.35;
}

.dac .mode-switch-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 9px;
}

.dac .mode-switch-action {
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #102a43;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.dac .mode-switch-continue {
  border-color: #d97706;
  color: #9a3412;
  background: #fff7ed;
}

.dac .mode-switch-cancel {
  border-color: #93c5fd;
  background: #eff6ff;
}

/* ===== 3. Diagram ===================================================== */

.dac-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.dac .arena {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.dac svg {
  width: 100%;
  height: auto;
  display: block;
}

.dac .atom-label {
  font-size: 22px;
  font-weight: 600;
}

.dac .legend {
  margin: 6px 0 4px;
  font-size: .9rem;
  color: #374151;
}

.dac .legend .dot {
  color: var(--dot);
}

.dac .legend .cross {
  color: var(--cross);
}

/* Ion charge and number boxes inside the SVG (desktop) */

.dac input.charge, .dac input.countBox {
  height: 28px;
  box-sizing: border-box;
  border: 2px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.dac input.charge {
  width: 34px;
}

.dac input.countBox {
  width: 42px;
}

.dac input.charge::placeholder {
  color: #64748b;
}

/* An outline would be clipped by the SVG edge, so focus is drawn inside the box */

.dac .arena input.charge:focus-visible, .dac .arena input.countBox:focus-visible {
  outline: none;
  border-color: var(--focus);
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px var(--focus);
}

/* Large HTML ion fields replace the SVG boxes on tablets and phones */

.dac .ionic-mobile-fields {
  display: none;
}

/* ===== 4. Electron counters ============================================ */

.dac .controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
}

.dac .controls > div:not(.dac-step2) {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.dac .dac-step2 {
  width: 100%;
  margin-bottom: 4px;
  color: var(--muted);
  text-align: center;
}

.dac .zone {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7fafc;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06) inset;
}

.dac .zone h3 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--ink);
}

.dac .count {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dac .dac-step-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.dac .dac-step-btn:hover {
  background: #eff6ff;
  border-color: #2b6cb0;
}

.dac .dac-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eef2f7;
  color: var(--ink);
  font-weight: 700;
}

/* ===== 5. Feedback and credit ========================================= */

.dac .result {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: #111827;
}

.dac .result.is-ok {
  border: 2px solid #1b7a3d;
}

.dac .result.is-bad {
  border: 2px solid var(--rs-wrong-line,#d9534f);
}

.dac-result-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.dac-result-list {
  margin: 0;
  padding-left: 1.2em;
}

.dac-credit {
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* Brief cue on the charge and number boxes when Ionic is first chosen */

@keyframes dac-ionic-field-cue {
  0%, 100% {
    border-color: #94a3b8;
    background-color: #fff;
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
  }
  28%, 68% {
    border-color: #d97706;
    background-color: #fffaf0;
    box-shadow: 0 0 0 4px rgba(217, 119, 6, .16);
  }
}

.dac.ionic-fields-cue .arena input.charge, .dac.ionic-fields-cue .arena input.countBox, .dac.ionic-fields-cue .ionic-mobile-input {
  animation: dac-ionic-field-cue 1.55s ease-out 1;
}

/* ===== 6. Tablet (≤900px) ============================================= */

@media (max-width: 900px) {
  .dac .atom-label {
    font-size: 28px;
  }
}

@media (max-width: 900px) {
  .dac .electron-glyph {
    font-size: 38px;
  }
}

@media (max-width: 900px) {
  .dac .arena svg circle, .dac .arena svg .ion-bracket {
    stroke-width: 2.6px;
  }
}

@media (max-width: 900px) {
  .dac[data-binary="true"][data-mode="ionic"] .arena foreignObject, .dac[data-binary="true"][data-mode="ionic"] .arena .ion-multiplier {
    display: none;
  }
}

@media (max-width: 900px) {
  .dac[data-binary="true"][data-mode="ionic"] .ionic-mobile-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 6px 2px 8px;
  }
}

@media (max-width: 900px) {
  .dac .ionic-mobile-ion {
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #dce4ee;
    border-radius: 10px;
    background: #f8fbff;
  }
}

@media (max-width: 900px) {
  .dac .ionic-mobile-ion.ion-a {
    background: #fff1f2;
    border-color: #fecdd3;
  }
}

@media (max-width: 900px) {
  .dac .ionic-mobile-ion.ion-b {
    background: #eff6ff;
    border-color: #bfdbfe;
  }
}

@media (max-width: 900px) {
  .dac .ionic-mobile-ion-title {
    margin-bottom: 5px;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
  }
}

@media (max-width: 900px) {
  .dac .ionic-mobile-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    font-size: 13px;
    line-height: 1.15;
  }
}

@media (max-width: 900px) {
  .dac .ionic-mobile-input {
    width: 64px;
    min-width: 0;
    height: 44px;
    border: 1px solid #94a3b8;
    border-radius: 8px;
    background: #fff;
    color: #102a43;
    text-align: center;
    font: inherit;
    font-size: 16px;
  }
}

/* ===== 7. Phone (≤600px) ============================================== */

@media (max-width: 600px) {
  .dac-step1 {
    margin: 4px 0 8px;
  }
}

@media (max-width: 600px) {
  .dac .bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
  }
}

@media (max-width: 600px) {
  .dac .bar .toggle, .dac .bar .hintbtn {
    width: 100%;
    min-height: 44px;
    padding: 8px 7px;
    font-size: 15px;
  }
}

@media (max-width: 600px) {
  .dac .bar .hintbtn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .dac-card {
    padding: 6px;
    overflow: visible;
  }
}

/* The diagram stays in view while the counters below it are used */

@media (max-width: 600px) {
  .dac .arena {
    max-width: none;
    background: #fff;
    position: sticky;
    top: var(--dac-sticky-top, 8px);
    z-index: 4;
    padding: 4px 0 6px;
    border-bottom: 1px solid #eef2f7;
  }
}

@media (max-width: 600px) {
  .dac .atom-label {
    font-size: 34px;
  }
}

@media (max-width: 600px) {
  .dac .electron-glyph {
    font-size: 44px;
  }
}

@media (max-width: 600px) {
  .dac .arena svg circle, .dac .arena svg .ion-bracket {
    stroke-width: 3px;
  }
}

@media (max-width: 600px) {
  .dac .legend {
    margin: 6px 2px 2px;
    font-size: 14px;
  }
}

@media (max-width: 600px) {
  .dac .controls {
    gap: 8px !important;
    margin-top: 8px;
    align-items: stretch;
  }
}

@media (max-width: 600px) {
  .dac .controls > .dac-step2 {
    padding: 8px 10px;
    margin: 0;
    border: 1px solid #dce4ee;
    border-radius: 10px;
    background: #f8fbff;
    text-align: left;
    font-size: .92rem;
    line-height: 1.35;
  }
}

@media (max-width: 600px) {
  .dac .controls > div:not(.dac-step2) {
    width: 100%;
    gap: 8px;
  }
}

/* Each counter becomes one compact full-width row */

@media (max-width: 600px) {
  .dac .zone {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: none;
    padding: 8px 10px;
    border-radius: 10px;
  }
}

@media (max-width: 600px) {
  .dac .zone h3 {
    margin: 0;
    text-align: left;
    font-size: 15px;
  }
}

@media (max-width: 600px) {
  .dac .count {
    gap: 6px;
  }
}

@media (max-width: 600px) {
  .dac .dac-step-btn {
    width: 44px;
    height: 44px;
    font-size: 21px;
  }
}

@media (max-width: 600px) {
  .dac .dac-count {
    min-width: 44px;
    height: 44px;
    padding: 0 6px;
    font-size: 17px;
  }
}

@media (max-width: 600px) {
  .dac[data-binary="true"][data-mode="ionic"] .ionic-mobile-fields {
    gap: 8px;
    margin: 5px 0 8px;
  }
}

@media (max-width: 600px) {
  .dac .ionic-mobile-ion {
    padding: 7px 8px;
  }
}

@media (max-width: 600px) {
  .dac .ionic-mobile-field {
    grid-template-columns: minmax(0, 1fr) 58px;
    font-size: 12.5px;
    line-height: 1.2;
  }
}

@media (max-width: 600px) {
  .dac .ionic-mobile-input {
    width: 58px;
  }
}

@media (max-width: 600px) {
  .dac .result {
    font-size: .92rem;
    line-height: 1.4;
  }
}

@media (max-width: 600px) {
  .dac.is-waiting .result {
    padding: 11px 12px;
    font-size: .98rem;
    line-height: 1.35;
  }
}

@media (max-width: 600px) {
  .dac .mode-switch-confirm {
    margin-top: 7px;
    padding: 10px;
    font-size: .93rem;
  }
}

@media (max-width: 600px) {
  .dac .mode-switch-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .dac .mode-switch-action {
    width: 100%;
    min-height: 44px;
    padding: 8px 7px;
    font-size: 14px;
  }
}

/* Very narrow phones: one ion card per row */

@media (max-width: 340px) {
  .dac[data-binary="true"][data-mode="ionic"] .ionic-mobile-fields {
    grid-template-columns: 1fr;
  }
}

/* Landscape phones: a sticky diagram would take too much height */

@media (max-width: 600px) and (max-height: 560px) {
  .dac .arena {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dac.is-waiting .bar .toggle, .dac.ionic-fields-cue .arena input.charge, .dac.ionic-fields-cue .arena input.countBox, .dac.ionic-fields-cue .ionic-mobile-input {
    animation: none;
  }
}

/* ===== 9. Fit layout (cfg.fit, v2.0.1) ================================
   The drawing is laid out in CSS pixels for the builder's width (rs-dotcross.js). Ion charge and number boxes are
   40 × 36 px beside the brackets when there is room (.dac-fit without .dac-fit-fields), otherwise the larger fields
   under the drawing are used (.dac-fit-fields), whatever the screen width. */

.dac.dac-fit .arena svg {
  height: auto;
}

.dac.dac-fit .legend {
  margin: 4px 0 0;
  text-align: center;
}

.dac.dac-fit[data-binary="true"][data-mode="ionic"]:not(.dac-fit-fields) .arena foreignObject, .dac.dac-fit[data-binary="true"][data-mode="ionic"]:not(.dac-fit-fields) .arena .ion-multiplier {
  display: inline;
}

.dac.dac-fit .arena input.charge, .dac.dac-fit .arena input.countBox {
  width: 100%;
  height: 100%;
  padding: 0;
  font-size: 17px;
}

.dac.dac-fit:not(.dac-fit-fields) .ionic-mobile-fields {
  display: none;
}

.dac.dac-fit.dac-fit-fields[data-mode="ionic"] .arena foreignObject, .dac.dac-fit.dac-fit-fields[data-mode="ionic"] .arena .ion-multiplier {
  display: none;
}

.dac.dac-fit-fields[data-binary="true"][data-mode="ionic"] .ionic-mobile-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 6px 0 4px;
}

.dac.dac-fit-fields .ionic-mobile-ion {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #dce4ee;
  border-radius: 10px;
  background: #f8fbff;
}

.dac.dac-fit-fields .ionic-mobile-ion.ion-a {
  background: #fff1f2;
  border-color: #fecdd3;
}

.dac.dac-fit-fields .ionic-mobile-ion.ion-b {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.dac.dac-fit-fields .ionic-mobile-ion-title {
  margin-bottom: 4px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
}

.dac.dac-fit-fields .ionic-mobile-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.2;
}

.dac.dac-fit-fields .ionic-mobile-input {
  width: 58px;
  min-width: 0;
  height: 40px;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  background: #fff;
  color: #102a43;
  text-align: center;
  font: inherit;
  font-size: 16px;
}

@media (max-width: 340px) {
  .dac.dac-fit-fields[data-binary="true"][data-mode="ionic"] .ionic-mobile-fields {
    grid-template-columns: 1fr;
  }
}

