/* Word Wheel's look: a photograph behind the board, glossy tiles, a white
   wheel, and the pieces of the show (js/games/wordWheel/fx.js).

   Unlike the rest of the game's styles this does NOT follow the site themes
   inside the shell, and cannot: what is behind everything is a photograph of
   any brightness, so each piece carries its own ground, dark glass or white,
   and reads on all of them. The one thing that changes is --ww-hue, the tiles'
   colour, set by main.js for each ten levels. The dialogs are left to the
   theme.

   Linked after wordWheel.css; handheld.css and screens.css come in before or
   after it, so the selectors here are weighted to win either way. */

.word-wheel-page .ww-shell {
  --ww-hue: 208;
  --ww-tile: hsl(var(--ww-hue) 72% 44%);
  --ww-tile-light: hsl(var(--ww-hue) 82% 60%);
  --ww-tile-dark: hsl(var(--ww-hue) 74% 30%);
  --ww-glass: rgba(10, 16, 34, 0.58);
  --ww-white: rgba(255, 255, 255, 0.93);
  --ww-deep: #14203a;
}


/* ---------------------------------------------------------------- the scene */

.ww-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #1b2c4d;
}

.ww-scene > div {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 700ms ease;
}

.ww-scene > div.is-on { opacity: 1; }

/* A soft shade top and bottom, where the numbers and the buttons are. The
   middle of the picture is left alone. */
.ww-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 10, 24, 0.42) 0, rgba(6, 10, 24, 0.08) 22%,
      rgba(6, 10, 24, 0.08) 70%, rgba(6, 10, 24, 0.46) 100%);
}

.word-wheel-page .ww-shell > .ww-readout,
.word-wheel-page .ww-shell > .ww-main {
  position: relative;
  z-index: 1;
}


/* ------------------------------------------------------------- the numbers */

.word-wheel-page .ww-shell > .ww-readout {
  align-self: center;
  align-items: center;
  max-width: 100%;
  padding: 6px 20px;
  border-radius: 999px;
  background: var(--ww-glass);
  color: rgba(255, 255, 255, 0.82);
  box-sizing: border-box;
}

.word-wheel-page .ww-readout b,
.word-wheel-page .ww-readout__tag { color: #fff; }

.word-wheel-page .ww-readout__tag { font-weight: 700; }

.ww-purse > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.word-wheel-page .ww-purse b { color: #ffd45e; }

.ww-purse i,
.ww-coin {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c8 0 16%, #ffc83d 52%, #b87700 100%);
  box-shadow: 0 0 0 1px #8a5800, 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Room under the puzzle for the photographer's signature. */
.word-wheel-page .ww-play { padding-bottom: 2rem; }

/* The same hand as games/jigsaw/signature.js, with a soft ground of its own
   because the picture behind it can be any colour. */
.ww-credit {
  position: absolute;
  right: 6px;
  bottom: 2px;
  margin: 0;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(10, 16, 34, 0.34);
  color: rgba(255, 255, 255, 0.97);
  font-family: "Dancing Script", "Segoe Script", cursive;
  font-size: clamp(1.15rem, 2.4vw, 2rem);
  line-height: 1.4;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}


/* ------------------------------------------------------------------- tiles */

.word-wheel-page .ww-grid {
  gap: 4px;
  --ww-cell: clamp(1.4rem,
                   min(calc(46vw / var(--ww-cols)), calc(56vh / var(--ww-rows))),
                   4rem);
}

.word-wheel-page .ww-cell {
  border: 0;
  border-radius: 18%;
  background: var(--ww-white);
  box-shadow: inset 0 -3px 0 rgba(20, 32, 58, 0.16), 0 3px 8px rgba(4, 8, 20, 0.35);
}

.word-wheel-page .ww-cell--gap {
  background: none;
  box-shadow: none;
}

.word-wheel-page .ww-cell--shown,
.ww-fly {
  background: linear-gradient(165deg, var(--ww-tile-light), var(--ww-tile) 55%, var(--ww-tile-dark));
  color: #fff;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.22),
      0 3px 8px rgba(4, 8, 20, 0.35);
}

.word-wheel-page .ww-cell--hinted {
  background: linear-gradient(165deg, #ffe488, #f5b400 60%, #c98a00);
}

/* The bow a finished crossword takes, corner to corner. */
.is-solved .ww-cell--shown { animation: ww-bow 600ms ease 2; }

.is-solved .ww-cell:nth-child(3n + 2) { animation-delay: 90ms; }
.is-solved .ww-cell:nth-child(3n) { animation-delay: 180ms; }

@keyframes ww-bow {
  0%, 100% { transform: none; filter: none; }
  45%      { transform: translateY(-7px) scale(1.08); filter: brightness(1.45); }
}


/* --------------------------------------------------------- word and wheel */

.word-wheel-page .ww-staged {
  min-width: 5.5rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--ww-tile-light), var(--ww-tile-dark));
  color: #fff;
  text-align: center;
  box-shadow: 0 3px 10px rgba(4, 8, 20, 0.4);
}

.word-wheel-page .ww-staged--empty {
  background: rgba(10, 16, 34, 0.3);
  box-shadow: none;
}

/* The answer's colour, held for the length of its animation. */
.word-wheel-page .ww-staged.ww-wrong { animation: ww-shake 320ms ease, ww-red 600ms ease; }
.word-wheel-page .ww-staged.ww-bonus { animation: ww-pop 300ms ease, ww-gold 900ms ease; }
.word-wheel-page .ww-staged.ww-again { animation: ww-pop 300ms ease, ww-grey 600ms ease; }

@keyframes ww-red  { 0%, 70% { background: #d23b3b; } }
@keyframes ww-gold { 0%, 70% { background: #d28b00; } }
@keyframes ww-grey { 0%, 70% { background: #6b7385; } }

.word-wheel-page .ww-wheel {
  width: min(22rem, 76vw, 46vh);
  border: 6px solid rgba(255, 255, 255, 0.35);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.96) 0 55%, rgba(236, 242, 255, 0.9) 100%);
  background-clip: padding-box;
  box-shadow: 0 10px 30px rgba(4, 8, 20, 0.45);
  box-sizing: border-box;
}

.word-wheel-page .ww-wheel__trail {
  color: var(--ww-tile);
  opacity: 0.75;
}

.word-wheel-page .ww-letter {
  width: 3.8rem;
  height: 3.8rem;
  border: 0;
  background: transparent;
  color: var(--ww-deep);
  font-size: 2rem;
  font-weight: 900;
}

.word-wheel-page .ww-letter:hover { background: rgba(20, 32, 58, 0.09); }

.word-wheel-page .ww-letter--picked,
.word-wheel-page .ww-letter--picked:hover {
  background: linear-gradient(165deg, var(--ww-tile-light), var(--ww-tile-dark));
  color: #fff;
  box-shadow: 0 3px 10px rgba(4, 8, 20, 0.4);
}

.word-wheel-page .ww-status {
  padding: 3px 14px;
  border-radius: 999px;
  background: var(--ww-glass);
  color: #fff;
  font-size: 0.95rem;
}

.word-wheel-page .ww-status:empty { visibility: hidden; }

.word-wheel-page .ww-entry__btn {
  border: 0;
  background: var(--ww-white);
  color: var(--ww-deep);
  box-shadow: 0 3px 8px rgba(4, 8, 20, 0.35);
}

.word-wheel-page .ww-entry__btn--go:not(:disabled) {
  background: linear-gradient(180deg, #4fd36b, #1f9a41);
  color: #fff;
}

.word-wheel-page .ww-entry__btn:disabled { opacity: 0.55; }


/* ---------------------------------------------------------------- the dock */

.word-wheel-page .ww-shell .hh-dock button {
  flex: 0 0 5.2rem;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: linear-gradient(180deg, var(--ww-tile-light), var(--ww-tile-dark));
  color: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 10px rgba(4, 8, 20, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.word-wheel-page .ww-shell .hh-dock button:hover:not(:disabled) { filter: brightness(1.15); }

.word-wheel-page .ww-shell .hh-dock button:disabled {
  color: #fff;
  opacity: 0.5;
}


/* ----------------------------------------------- the screens over the scene */

/* While a screen is up the picture, and its signature, are all that show
   behind it. */
.word-wheel-page .ww-shell:has(.ar-screen:not([hidden])) .ww-play {
  visibility: hidden;
}

.word-wheel-page .ww-shell .ar-screen {
  background: transparent;
  backdrop-filter: none;
}

/* The menus: a card in the middle of the picture. */
.word-wheel-page .ww-shell .ar-screen.is-page .ar-screen__panel {
  padding: 0 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  box-shadow: 0 14px 40px rgba(4, 8, 20, 0.45);
  height: auto;
  max-height: 100%;
  margin-block: auto;
}

/* The results: gold round the edge, and room for the confetti to fall past. */
.word-wheel-page .ww-shell .ar-screen:not(.is-page) .ar-screen__panel {
  border: 3px solid #ffc83d;
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: 0 0 0 6px rgba(255, 200, 61, 0.28), 0 18px 50px rgba(4, 8, 20, 0.55);
}

.word-wheel-page .ww-shell .ar-tally__score b { font-size: 2.4rem; }
.word-wheel-page .ww-shell .ar-tally__stars .ar-star { width: 28px; height: 28px; }
.word-wheel-page .ww-shell .ar-tally__coins b { font-size: 1.6rem; }


/* ---------------------------------------------------------------- the show */

.ww-splash,
.ww-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ww-splash { z-index: 5; }
.ww-splash[hidden] { display: none; }

.ww-fx {
  z-index: 6;
  overflow: hidden;
}

.ww-fx > span {
  position: absolute;
  left: 0;
  top: 0;
}

.ww-fly {
  display: grid;
  place-items: center;
  border-radius: 18%;
  font-family: var(--font-head, inherit);
  font-weight: 700;
  line-height: 1;
}

.ww-spark {
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: #fff3a8;
  filter: drop-shadow(0 0 4px #ffb300);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%,
                     50% 100%, 39% 61%, 0 50%, 39% 39%);
}

.ww-praise {
  white-space: nowrap;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 2.4rem;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 6px var(--ww-deep);
  paint-order: stroke fill;
}

.ww-fx > .ww-coin {
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
}


/* ---------------------------------------------------------------- phones */

@media (max-width: 52rem) {
  /* The gaps come out of the width first: eleven columns of a seven letter
     wheel ran off the side of a phone without that. */
  .word-wheel-page .ww-grid {
    gap: 3px;
    --ww-cell: clamp(1.2rem,
                     min(calc((94vw - var(--ww-cols) * 3px) / var(--ww-cols)),
                         calc(36vh / var(--ww-rows))),
                     3.2rem);
  }

  .word-wheel-page .ww-letter { width: 3.1rem; height: 3.1rem; font-size: 1.6rem; }
  .word-wheel-page .ww-wheel { width: min(20rem, 76vw, 36vh); }
}

@media (pointer: coarse) and (max-width: 720px) {
  .word-wheel-page .ww-shell > .ww-readout {
    align-self: stretch;
    padding: 4px 8px;
    border-radius: 14px;
  }

  .word-wheel-page .hh-app .ww-grid {
    --ww-cell: clamp(1.2rem,
                     min(calc((94vw - var(--ww-cols) * 3px) / var(--ww-cols)),
                         calc(32dvh / var(--ww-rows))),
                     3rem);
  }

  .word-wheel-page .hh-app .ww-wheel { width: min(76vw, 30dvh); }
  .word-wheel-page .ww-status { font-size: 0.85rem; }
  .word-wheel-page .ww-shell .hh-dock button { flex: 0 1 5.2rem; }
}


/* A phone held upright: the signature stands up the left edge, beside the
   wheel, reading from the bottom. Along the bottom it ran into the line under
   the wheel and sat where a phone's own bars cover the page. */
@media (max-width: 52rem) and (orientation: portrait) {
  .word-wheel-page .ww-play { padding-bottom: 0; }

  /* The menus and results stand clear of it. */
  .word-wheel-page .ww-shell .ar-screen { padding-inline: 28px 4px; }

  .word-wheel-page .ww-credit {
    left: 0;
    right: auto;
    bottom: 3.5rem;
    padding: 10px 0;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 1.05rem;
  }
}


@media (prefers-reduced-motion: reduce) {
  .ww-scene > div { transition: none; }
  .is-solved .ww-cell--shown { animation: none; }
}


/* The results' buttons two abreast under the main one, so they are all in view
   with the stars and the coins above them. */
.word-wheel-page .ww-shell .ar-tally__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.word-wheel-page .ww-shell .ar-tally__actions .ar-primary {
  grid-column: 1 / -1;
  font-size: 1.1rem;
}
