/* keymorse: the daily five (five.js). Loaded after morse.css and built on its
   colours and type. The five letters of MORSE are the loud thing: they are
   lamps, lit one by one. Everything round them stays quiet. */

.five, .paddle.next, .hints.for-ask, .hints.for-next { display: none; }

/* ---------- what the trainer shows while the game is on ---------- */
.app.is-five > .config, .app.is-five > .text, .app.is-five > .results { display: none; }
.app.is-five .hints { display: none; }
.app.is-five .say, .app.is-five .counter, .app.is-five #hearBtn { display: none; }
.app.is-five .modes button[data-mode][aria-pressed="true"] { background: none; color: var(--silk-dim); }
/* The chart is part of the game: it shows even when settings hide it. */
.app.is-five .board { display: flex; }
.app.is-five[data-tree="hide"] .keys { flex: none; height: 104px; min-height: 0; }
.app.is-five > .five { display: flex; flex-direction: column; flex: none; gap: 10px; min-height: 0; }

/* The door, the result and a wait have the page to themselves. */
.app[data-five="load"] > :is(.readout, .board, .keys),
.app[data-five="door"] > :is(.readout, .board, .keys),
.app[data-five="result"] > :is(.readout, .board, .keys),
.app[data-five="reveal"] > :is(.readout, .board) { display: none; }
.app[data-five="load"] > .five, .app[data-five="door"] > .five, .app[data-five="result"] > .five {
  flex: 1 1 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-mid) transparent;
  /* Out to the window's edges, like the board and stats pages. */
  margin-left: calc(-1 * var(--edge-l));
  margin-right: calc(-1 * var(--edge-r));
  padding-left: var(--edge-l);
  padding-right: var(--edge-r);
}
.app[data-five="reveal"] > .five { flex: 1 1 0; }
/* The door sits a little above the middle of a tall window. */
.app[data-five="door"] > .five { padding-bottom: 9vh; }
.app[data-five="door"] .five-bar { margin-top: auto; }
.app[data-five="door"] .five-stage { margin-bottom: auto; }
.app[data-five="reveal"] #keys > :not(.next) { display: none; }
.app[data-five="reveal"] #keys > .next { display: flex; touch-action: manipulation; border-color: var(--gold-hot); }
.paddle.next .cap { font-size: 1.1rem; font-weight: 700; color: var(--gold-hot); }

@media (hover: hover) and (pointer: fine) {
  .app[data-five="ask"] .hints.for-ask, .app[data-five="warm"] .hints.for-ask { display: flex; }
  .app[data-five="reveal"] .hints.for-next { display: flex; }
}

/* ---------- the lamps ---------- */
.five-bar { display: flex; align-items: center; gap: 12px; flex: none; }
.five-tiles { display: flex; gap: 6px; }
.ft {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--gold-mid);
  border-radius: 9px;
  background: #181c1a;
  color: #6f5a2d;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.ft.lit {
  background: linear-gradient(#f6d27a, #d6ab52);
  border-color: var(--gold-hot);
  color: var(--mask);
  box-shadow: 0 0 22px -5px var(--gold-hot);
}
.ft.dark { border-color: #33372f; color: #4a4a42; background: none; }
.ft.now { border-color: var(--gold-hot); color: var(--gold-hot); animation: ft-now 1.3s ease-in-out infinite; }
.ft.on { background: var(--gold-hot); border-color: #fff3cf; color: var(--mask); box-shadow: 0 0 30px -2px var(--gold-hot); transition: none; }
.ft.flip { animation: ft-flip 0.62s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
.ft.drop { animation: ft-drop 0.5s ease both; }
@keyframes ft-now { 50% { box-shadow: 0 0 20px -4px var(--gold-hot); } }
@keyframes ft-flip {
  0% { transform: rotateX(0) scale(1); }
  45% { transform: rotateX(90deg) scale(1.12); }
  75% { transform: rotateX(0) scale(1.18); }
  100% { transform: rotateX(0) scale(1); }
}
@keyframes ft-drop { 20%, 60% { transform: translateX(-3px); } 40%, 80% { transform: translateX(3px); } }

.five-score { margin-left: auto; display: flex; align-items: baseline; gap: 6px; }
.five-score b { font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--silk); }
.five-score span { color: var(--silk-dim); font-size: 0.85rem; }

.five-stage { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.five-note { margin: 12vh 0 0; text-align: center; color: var(--silk-dim); }
.five-stage > .btn[data-do="retry"] { align-self: center; }

/* ---------- the door and the result: tall lamps, centred ---------- */
.app:is([data-five="door"], [data-five="result"], [data-five="load"]) .five-bar { justify-content: center; padding-top: clamp(6px, 4vh, 38px); }
.app:is([data-five="door"], [data-five="result"], [data-five="load"]) .five-score { display: none; }
.app:is([data-five="door"], [data-five="result"], [data-five="load"]) .five-tiles { gap: clamp(6px, 2vw, 12px); }
.app:is([data-five="door"], [data-five="result"], [data-five="load"]) .ft {
  width: clamp(50px, 16.5vw, 96px);
  height: clamp(50px, 16.5vw, 96px);
  border-radius: clamp(12px, 3.4vw, 20px);
  font-size: clamp(1.7rem, 8.4vw, 3.2rem);
  border-width: 2px;
}
.app:is([data-five="door"], [data-five="result"]) .five-stage { align-items: center; text-align: center; gap: 14px; padding-bottom: 28px; }
.five-stage > * { max-width: 100%; }
/* Nothing on the door or the result is squeezed when the page has to scroll. */
.app:is([data-five="door"], [data-five="result"]) .five-stage { flex: none; }
.app:is([data-five="door"], [data-five="result"]) .five-stage > * { flex-shrink: 0; }

.five-title { margin: clamp(6px, 3vh, 26px) 0 0; font-size: clamp(1.45rem, 6.2vw, 2.3rem); line-height: 1.18; font-weight: 700; text-wrap: balance; max-width: 17em; }
.five-lead { margin: 0; color: var(--silk-dim); line-height: 1.5; max-width: 34em; text-wrap: pretty; }
.five-lead b { color: var(--silk); font-weight: 700; }
.five-go { height: 58px; min-width: min(100%, 280px); font-size: 1.2rem; border-radius: 14px; margin-top: 6px; }
.five-go:not(:disabled):active { transform: translateY(1px); }
.five-facts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 26px; color: var(--silk-dim); font-size: 0.95rem; }
.five-facts b { color: var(--gold-hot); font-variant-numeric: tabular-nums; }
.five-links { margin: 10px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; font-size: 0.95rem; }
.five-links a, .five-yday summary { color: var(--gold); text-decoration: underline; text-decoration-color: var(--gold-mid); text-underline-offset: 4px; cursor: pointer; }
.five-yday { width: min(100%, 560px); text-align: left; }
.five-yday summary { text-align: center; font-size: 0.95rem; list-style: none; padding: 6px 0; }
.five-yday summary::-webkit-details-marker { display: none; }
.five-yday ol { margin: 8px 0 0; }

/* ---------- a question ---------- */
.five-ready { margin: 0; display: flex; align-items: baseline; gap: 12px; min-height: 52px; font-size: 1.15rem; font-weight: 700; color: var(--silk-dim); }
.five-ready b { color: var(--gold-hot); font-size: 1.6rem; }
.five-ask { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.five-q { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 1.16rem; line-height: 1.34; font-weight: 700; text-wrap: balance; }
.five-q.was { font-size: 0.98rem; color: var(--silk-dim); font-weight: 500; flex: none; }
.five-clock { position: relative; width: 52px; height: 52px; flex: none; }
.five-clock svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.five-clock circle { fill: none; stroke-width: 4; }
.five-clock .track { stroke: #262a27; }
.five-clock .left { stroke: var(--gold); stroke-dasharray: 100; stroke-linecap: round; }
.five-clock b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.five-clock.low .left { stroke: var(--red); }
.five-clock.low b { color: var(--red); }
.five-clock.beat { animation: five-beat 0.4s ease-out; }
@keyframes five-beat { 30% { transform: scale(1.22); } }

.five-answer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 8px 0 14px;
  background: var(--board);
  border: 1.5px solid var(--gold-mid);
  border-radius: 14px;
}
.five-typed { display: flex; align-items: center; font-family: var(--mono); font-size: 1.7rem; font-weight: 500; letter-spacing: 0.1em; line-height: 1; min-width: 0; }
.five-typed span { display: inline-block; animation: five-pop 0.3s cubic-bezier(0.2, 1.7, 0.4, 1) both; }
.five-typed span.bad { color: var(--red); animation: five-bad 0.5s ease both; }
@keyframes five-pop { from { transform: scale(0.3) translateY(8px); opacity: 0; color: var(--gold-hot); } }
@keyframes five-bad {
  0% { transform: translateX(0); opacity: 1; }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); opacity: 1; }
  100% { transform: translateX(0) scale(0.6); opacity: 0; }
}
.five-caret { flex: none; width: 2px; height: 1.7rem; background: var(--gold); animation: five-blink 1s steps(2, jump-none) infinite; }
@keyframes five-blink { to { opacity: 0; } }
/* The line under the box: how long an answer may be, then the word that is in. */
.five-held { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 2px 0 4px; color: var(--silk-dim); font-size: 0.88rem; line-height: 1.2; }
.five-held > span { flex: 1 1 auto; min-width: 0; text-wrap: balance; }
.five-held b { font-weight: 700; color: var(--silk); }
.five-held.on > span { color: var(--silk); }
.five-held.on b { color: var(--gold-hot); font-variant-numeric: tabular-nums; }
.five-held.on b:first-child { font-family: var(--mono); font-weight: 500; letter-spacing: 0.08em; }
.five-held.warn > span { color: var(--red); }
.five-held.pop > span { animation: five-pop 0.3s cubic-bezier(0.2, 1.7, 0.4, 1) both; transform-origin: left center; }
.five-held .wide { display: none; }
.five-lock { flex: none; }
.five-lock:not([hidden]) { color: var(--mask); background: var(--gold); border-color: var(--gold); font-weight: 700; }
.five-of { margin: 0; flex: none; color: var(--silk-dim); font-size: 0.84rem; }
@media (min-width: 560px) { .five-held .wide { display: inline; } }
.five-clear { margin-left: auto; flex: none; }
.five-answer.no { animation: five-no 0.3s ease; border-color: var(--red); }
@keyframes five-no { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.five-answer.locked { border-color: var(--green); }
.five-answer.locked .five-typed { color: var(--green); }
.five-answer.locked .five-caret, .five-answer.locked .five-clear, .five-answer.out .five-caret, .five-answer.out .five-clear { display: none; }
.five-answer.locked::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 15px;
  border: 2px solid var(--green);
  animation: five-ring 0.6s ease-out both;
  pointer-events: none;
}
@keyframes five-ring { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.06, 1.5); } }
.five-answer.out { border-color: #33372f; }
.five-answer.out .five-typed { color: var(--silk-dim); }

/* ---------- the reveal: every answer, longest first ---------- */
.app[data-five="reveal"] .five-stage { flex: 1 1 0; }
.five-won { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; flex: none; }
.five-won b { font-family: var(--mono); font-size: 1.7rem; font-weight: 500; letter-spacing: 0.1em; color: var(--gold-hot); }
.five-won span { color: var(--silk-dim); font-size: 0.95rem; }
.five-won strong { margin-left: auto; font-size: 1.7rem; font-variant-numeric: tabular-nums; color: var(--silk); }
.five-won.miss b { font-family: var(--ui); letter-spacing: 0; font-weight: 700; color: var(--silk-dim); }
.five-bars {
  list-style: none;
  margin: 0;
  padding: 0 2px 0 0;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-mid) transparent;
}
.five-bars li { position: relative; flex: none; height: 31px; display: flex; align-items: center; gap: 10px; padding: 0 10px; font-family: var(--mono); font-size: 0.98rem; }
.five-bars .bar { position: absolute; inset: 0 auto 0 0; width: var(--w); min-width: 7.2em; border-radius: 8px; background: #24281f; transform-origin: left; animation: five-grow 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: var(--d); }
.five-bars b, .five-bars i { position: relative; font-style: normal; font-weight: 500; animation: five-in 0.3s ease both; animation-delay: calc(var(--d) + 0.18s); }
.five-bars b { letter-spacing: 0.08em; }
.five-bars i { color: var(--silk-dim); }
.five-bars li.mine .bar { background: linear-gradient(90deg, #d6ab52, #f6d27a); box-shadow: 0 0 18px -6px var(--gold-hot); }
.five-bars li.mine b, .five-bars li.mine i { color: var(--mask); font-weight: 500; }
@keyframes five-grow { from { transform: scaleX(0); } }
@keyframes five-in { from { opacity: 0; } }

/* ---------- the result ---------- */
.five-total { margin: clamp(2px, 2vh, 16px) 0 0; display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.five-total b { font-size: clamp(4rem, 21vw, 7rem); line-height: 0.95; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--silk); }
.five-total span { font-size: clamp(1.2rem, 5vw, 1.8rem); color: var(--silk-dim); }
.five-better { margin: 0; font-size: clamp(1.05rem, 4.4vw, 1.35rem); }
.five-better b { color: var(--gold-hot); }
.five-curve { position: relative; width: min(100%, 560px); padding-top: 24px; margin-bottom: 20px; }
.five-curve svg { display: block; width: 100%; height: clamp(74px, 15vh, 120px); border-bottom: 1px solid var(--gold-mid); overflow: visible; }
.five-curve .all { fill: #2a2619; }
.five-curve .beat { fill: var(--gold); opacity: 0.85; }
.five-curve .line { fill: none; stroke: var(--gold); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.five-curve .you { position: absolute; left: var(--at); top: 6px; bottom: 0; width: 2px; margin-left: -1px; background: var(--silk); border-radius: 2px; }
.five-curve .you::before { content: ""; position: absolute; left: -4px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--silk); }
.five-curve .you b { position: absolute; top: -9px; left: 12px; font-size: 0.9rem; font-weight: 700; white-space: nowrap; }
.five-curve .you.far b { left: auto; right: 12px; }
.five-curve .ends { position: absolute; left: 0; right: 0; top: 100%; display: flex; justify-content: space-between; padding-top: 3px; font-family: var(--mono); font-size: 0.78rem; color: var(--silk-dim); }
.five-curve .ends i { font-style: normal; }
.five-stage.fresh .five-curve .beat { animation: five-wipe 0.9s 0.9s ease-out both; }
.five-stage.fresh .five-curve .line { stroke-dasharray: 1; animation: five-draw 0.9s 0.1s ease-out both; }
.five-stage.fresh .five-curve .all { animation: five-in 0.6s 0.5s ease both; }
.five-stage.fresh .five-curve .you { animation: five-land 0.55s 1.1s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.five-stage.fresh .five-better { animation: five-in 0.5s 1.5s ease both; }
@keyframes five-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes five-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes five-land { from { transform: translateY(-46px); opacity: 0; } }

.five-share { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: min(100%, 560px); margin-top: 4px; }
.five-share .btn { flex: 1 1 0; white-space: nowrap; padding: 0 12px; }
.five-share .btn.primary { flex: 1 1 100%; height: 56px; font-size: 1.15rem; border-radius: 14px; }
.five-said { margin: 0; min-height: 1.3em; color: var(--green); font-size: 0.95rem; }
.five-post { display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(100%, 560px); padding: 14px; border: 1px dashed var(--gold-mid); border-radius: 14px; }
.five-post p { margin: 0; color: var(--silk-dim); font-size: 0.9rem; }
/* A question of the player's own, for a later day. */
.five-suggest { align-self: stretch; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.five-suggest > p { margin: 0; color: var(--silk-dim); font-size: 0.9rem; line-height: 1.45; }
.five-suggest > div { display: flex; gap: 8px; }
.five-suggest input {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  background: var(--board);
  border: 1.5px solid var(--gold-mid);
  border-radius: 10px;
  color: var(--silk);
  font: inherit;
  font-size: 1rem;
}
.five-suggest input::placeholder { color: #6a6962; }
.five-suggest input:focus { outline: none; border-color: var(--gold); }
.five-suggest .btn { flex: none; }
.five-h { margin: 16px 0 0; font-size: 1.05rem; color: var(--gold); align-self: stretch; text-align: left; }
.five-stage .rank, .five-stage .sub.empty, .five-recap { align-self: stretch; text-align: left; }
.five-stage .sub.empty { text-align: center; }
.five-mini { display: inline-flex; gap: 3px; vertical-align: middle; }
.five-mini i { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--gold-mid); }
.five-mini i.lit { background: var(--gold); border-color: var(--gold); }

.five-recap { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.five-recap li { display: flex; gap: 12px; align-items: flex-start; }
.five-recap .ft { width: 34px; height: 34px; border-radius: 9px; font-size: 1.1rem; border-width: 1.5px; margin-top: 2px; }
.five-recap div { min-width: 0; flex: 1; }
.five-recap p { margin: 0 0 4px; line-height: 1.4; }
.five-recap .got { color: var(--silk-dim); font-size: 0.92rem; }
.five-recap .got b { color: var(--gold-hot); }
.five-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.five-chips i { font-style: normal; font-family: var(--mono); font-size: 0.8rem; padding: 3px 7px; border-radius: 6px; background: #1c201d; color: var(--silk-dim); white-space: nowrap; }
.five-chips i b { font-weight: 500; color: #6f6d66; }
.five-chips i.mine { background: var(--gold); color: var(--mask); }
.five-chips i.mine b { color: #5a4514; }
.five-chips .more { appearance: none; position: relative; font: 0.8rem var(--ui); padding: 2px 9px; border-radius: 6px; background: none; border: 1px solid var(--gold-mid); color: var(--gold); white-space: nowrap; cursor: pointer; }
.five-chips .more::after { content: ''; position: absolute; inset: -9px -6px; }
.five-chips .more:hover, .five-chips .more:focus-visible { border-color: var(--gold); color: var(--gold-hot); }
/* The sheet with every answer of one question. */
#fiveAll { width: min(92vw, 640px); }
#fiveAll .sheet-head h2 { font-size: 1.05rem; line-height: 1.3; text-wrap: balance; }
#fiveAll .sheet-head .btn { flex: none; }
.five-all-n { margin: 0; color: var(--silk-dim); font-size: 0.9rem; }
.five-group h3 { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; color: var(--gold); }
.five-group h3 span { color: var(--silk-dim); font-size: 0.82rem; font-weight: 400; }
.five-group .five-chips i { font-size: 0.85rem; }

@media (min-width: 760px) and (min-height: 700px) {
  .five-q { font-size: 1.4rem; }
  .ft { width: 38px; height: 38px; }
  .five-recap .ft { width: 38px; height: 38px; }
}
@media (max-width: 374px) {
  .ft { width: 30px; height: 30px; font-size: 1rem; }
  .five-q { font-size: 1.05rem; }
  .five-typed { font-size: 1.45rem; }
  .five-clock { width: 46px; height: 46px; }
  .five-share .btn { flex: 1 1 100%; }
}
@media (max-height: 640px) {
  .app.is-five[data-tree="hide"] .keys { height: 88px; }
  .app.is-five > .five, .five-stage { gap: 7px; }
  .five-answer { min-height: 46px; }
  .five-held { min-height: 30px; font-size: 0.84rem; }
  .five-ask, .five-ready { min-height: 46px; }
  .app[data-five="door"] > .five { padding-bottom: 0; }
  .app[data-five="door"] .five-bar { padding-top: 2px; }
  .five-title { margin-top: 2px; font-size: 1.3rem; }
  .five-lead { font-size: 0.9rem; line-height: 1.4; }
  .five-go { height: 52px; margin-top: 2px; }
}
@media (hover: hover) and (pointer: fine) {
  .five-links a:hover, .five-yday summary:hover { text-decoration-color: var(--gold); }
  .paddle.next:hover { background: #1b1e19; }
}

@media (prefers-reduced-motion: reduce) {
  .five *, .five *::after { animation: none !important; transition: none !important; }
}
