/* The secret-code wheel (Coding, Year 6): site/js/science/code-cipher.js. The wheel on one
   side, the key, the ◀ ▶ buttons and the message on the other; stacked when the iPad stands
   up, and on a phone the step scrolls. */

.cipher-act .map-ask { font-size: 24px; }
.cipher-act { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; height: 100%; min-height: 0; container-type: size; }
.ci-in { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; gap: 10px; min-height: 0; }

/* ---- The wheel ---- */

.ci-wheel-wrap { display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; }
.ci-wheel { width: auto; height: 100%; max-width: 100%; max-height: 380px; aspect-ratio: 1; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.ci-outer-disc { fill: #fff; stroke: var(--line); stroke-width: 2; }
.ci-inner-disc { fill: color-mix(in srgb, var(--subject, var(--accent)) 22%, #fff); stroke: var(--subject, var(--accent)); stroke-width: 2; }
.ci-hub { fill: #fff; stroke: var(--line); stroke-width: 2; }
.ci-hub-e { font: 34px/1 var(--emoji); text-anchor: middle; dominant-baseline: central; }
.ci-pointer { fill: var(--wrong); }
.ci-letter { font: 800 15px/1 var(--ui); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.ci-letter.real { fill: var(--ink); }
.ci-letter.secret { fill: var(--subject-dark, var(--accent)); opacity: 0.55; font-size: 12.5px; }
.ci-letter.secret.used { opacity: 1; }

/* ---- The key and the message ---- */

.ci-side { display: grid; justify-items: center; align-content: center; gap: 8px; width: 100%; min-width: 0; }
.ci-controls { display: flex; align-items: center; gap: 14px; }
.ci-turn.big { min-width: 76px; min-height: 64px; padding: 0 14px; font-size: 30px; }
.ci-key { display: grid; justify-items: center; min-width: 150px; padding: 4px 14px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.ci-key span { color: var(--muted); font: 700 15px/1.2 var(--ui); }
.ci-key-word { color: var(--subject-dark, var(--accent)); font: 800 28px/1.2 var(--ks-brand-font, var(--ui)); }
.ci-message { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px 10px; padding: 10px 14px; border-radius: 22px; background: #fff; box-shadow: var(--shadow); max-width: 100%; }
.ci-row-name { color: var(--muted); font: 700 15px/1.2 var(--ui); white-space: nowrap; }
.ci-real-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ci-row { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.ci-tile { display: grid; place-items: center; width: 34px; height: 40px; border-radius: 10px; font: 800 24px/1 var(--ui); }
.ci-tile.gap { width: 14px; }
.ci-row.secret .ci-tile:not(.gap) { background: color-mix(in srgb, var(--subject, var(--accent)) 22%, #fff); color: var(--subject-dark, var(--accent)); }
.ci-row.real .ci-tile:not(.gap) { border: 2px solid var(--line); background: #fff; color: var(--ink); }
.ci-row.real.cracked .ci-tile:not(.gap) { border-color: var(--right); background: var(--right-soft); color: #13643a; }
.ci-prize { font: 40px/1 var(--emoji); }
.ci-note { margin: 0; min-height: 1.3em; font: 400 20px/1.3 var(--book); text-align: center; }

/* ---- iPad on its side: the wheel on the left, the message on the right ---- */

@container (min-aspect-ratio: 4 / 3) {
  .ci-in { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
}

/* ---- Phones: one column, and the step scrolls ---- */

@media (max-width: 600px), (max-height: 500px) {
  .cipher-act { height: auto; container-type: normal; }
  .ci-in { grid-template-rows: none; }
  .ci-wheel { width: min(78vw, 300px); height: auto; }
  .cipher-act .map-ask { font-size: 20px; }
  .ci-tile { width: 26px; height: 32px; font-size: 19px; }
  .ci-tile.gap { width: 10px; }
  .ci-turn.big { min-width: 64px; min-height: 56px; font-size: 26px; }
  .ci-key-word { font-size: 24px; }
  .ci-note { font-size: 17px; }
}

/* A phone on its side: the wheel and the message side by side. */
@media (max-height: 500px) {
  .ci-in { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
  .ci-wheel { width: min(42vw, 72vh, 260px); }
}
