/* Double Double (js/arcade/doubledouble.js). Every class starts with .dd- */

.dd-wrap { position: relative; display: grid; gap: 8px; width: min(100%, 600px); margin: 0 auto; padding-bottom: 14px; }

/* ---------- HUD: the question she is on, the stars she can win, the score ---------- */
.dd-hud { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 14px; font: 700 14px var(--font-ui); color: var(--muted); }
.dd-hud b { color: var(--ink); font-size: 19px; }
.dd-stars { display: inline-flex; gap: 3px; }
.dd-star {
  --f: 0%; width: 24px; height: 24px;
  clip-path: polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 80% 94%, 50% 73%, 20% 94%, 31% 59%, 2% 37%, 38% 36%);
  background: linear-gradient(90deg, var(--sun) var(--f), var(--tile-shadow) var(--f));
}
.dd-star.dd-half { --f: 50%; }
.dd-star.dd-full { --f: 100%; animation: dd-pop 0.45s; }
@keyframes dd-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: none; } }

/* ---------- the question ---------- */
.dd-ask { display: grid; justify-items: center; gap: 2px; padding: 6px 14px 8px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-soft); text-align: center; }
.dd-q { font: 900 42px/1.2 var(--font-ui); color: var(--grape-d); white-space: nowrap; }
.dd-box {
  display: inline-block; min-width: 1.3em; padding: 0 8px; border-radius: 12px; text-align: center;
  border: 3px dashed var(--grape); color: var(--grape); background: color-mix(in srgb, var(--grape) 8%, white);
}
.dd-box.dd-filled { border-style: solid; border-color: var(--green-d); color: var(--green-d); background: color-mix(in srgb, var(--green) 18%, white); animation: dd-pop 0.45s; }
.dd-words { margin: 0; font: 700 17px/1.3 var(--font-read); color: var(--ink); }

/* ---------- the board: the bar of blocks, drawn to scale, with its number at its end ---------- */
.dd-board { display: grid; gap: 4px; padding: 10px 14px 8px; border-radius: var(--radius); background: color-mix(in srgb, var(--sun) 16%, white); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--sun) 60%, white), var(--shadow-soft); }
.dd-board.dd-right { background: color-mix(in srgb, var(--green) 20%, white); box-shadow: inset 0 0 0 4px var(--green-d), var(--shadow-soft); }
.dd-lane { position: relative; height: 44px; }
.dd-tag {
  position: absolute; bottom: 4px; left: clamp(26px, var(--at, 0%), calc(100% - 26px)); transform: translateX(-50%); min-width: 52px; padding: 0 8px; border-radius: 12px; text-align: center;
  font: 900 28px/38px var(--font-ui); color: var(--card); background: var(--grape); box-shadow: 0 3px 0 var(--grape-d); transition: left 0.42s ease-in-out;
}
.dd-tag::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--grape-d); border-bottom: 0; }
.dd-track { position: relative; height: 58px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 6%, white); }
.dd-bar {
  --cells: 1;
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 8px; overflow: hidden; transition: width 0.42s ease-in-out;
  background:
    linear-gradient(90deg, transparent calc(100% - 2px), color-mix(in srgb, var(--card) 80%, transparent) calc(100% - 2px)) 0 0 / calc(100% / var(--cells)) 100%,
    var(--sky);
  box-shadow: inset 0 0 0 3px var(--sky-d);
}
/* over 50 a block is a ten: wider blocks, a deeper colour */
.dd-bar.dd-tens { background-color: var(--teal); box-shadow: inset 0 0 0 3px var(--teal-d); }
/* just doubled: the new half is lighter for a moment, so the two halves show */
.dd-bar.dd-doubled::after { content: ''; position: absolute; inset: 0 0 0 50%; background: var(--card); opacity: 0; border-left: 3px solid var(--ink); animation: dd-new 1.4s ease-out; }
@keyframes dd-new { 0%, 60% { opacity: 0.45; } 100% { opacity: 0; } }
/* what the bar was before it was halved */
.dd-ghost { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 8px; border: 3px dashed var(--sky-d); opacity: 0; box-sizing: border-box; transition: width 0.42s ease-in-out; }
.dd-ghost.dd-on { opacity: 0.7; }
.dd-still .dd-bar, .dd-still .dd-ghost, .dd-still .dd-tag { transition: none; }
.dd-ruler { display: flex; justify-content: space-between; font: 700 13px var(--font-ui); color: var(--muted); }

/* ---------- the trail of steps ---------- */
.dd-trail { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 2px 10px; min-height: 44px; margin: 0; padding: 4px 12px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-soft); }
.dd-trail-name { font: 700 14px var(--font-ui); color: var(--muted); }
.dd-trail b { font: 900 24px/1.3 var(--font-ui); color: var(--green-d); text-align: center; }

.dd-msg { min-height: 46px; margin: 0; display: grid; place-items: center; text-align: center; font: 700 16px/1.35 var(--font-read); color: var(--ink); }

/* ---------- the buttons ---------- */
.dd-ops { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dd-ops.dd-n3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dd-op { display: grid; justify-items: center; gap: 0; min-height: 64px; padding: 8px 4px; color: var(--ink); white-space: nowrap; touch-action: manipulation; }
.dd-op b { font: 900 24px/1.1 var(--font-ui); }
.dd-op small { font: 700 14px/1.2 var(--font-ui); opacity: 0.75; }
.dd-op-ten { background: var(--sun); box-shadow: 0 5px 0 var(--sun-d); }
.dd-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.dd-again { padding: 10px 6px; font-size: 17px; white-space: nowrap; touch-action: manipulation; }
.dd-check { touch-action: manipulation; }
.dd-off { opacity: 0.45; }

/* a button that can't be pressed, and a Check that is not right yet: a little shake */
.dd-no { animation: dd-no 0.32s; }
@keyframes dd-no { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* iPad: more room */
@media (min-width: 700px) {
  .dd-wrap { gap: 12px; }
  .dd-q { font-size: 58px; }
  .dd-words { font-size: 21px; }
  .dd-track { height: 76px; }
  .dd-trail b { font-size: 30px; }
  .dd-msg { font-size: 19px; }
  .dd-op { min-height: 76px; }
  .dd-op b { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .dd-star.dd-full, .dd-box.dd-filled, .dd-no, .dd-bar.dd-doubled::after { animation: none; }
  .dd-bar, .dd-ghost, .dd-tag { transition: none; }
}
