/* Knowdle Daily Word FX (v62): styles for fx/wordfx.js.
   Colour tokens and the results sheet work on their own; everything that changes layout or hides
   tiles before a reveal is gated behind html.wfx-on (set by wordfx.js), so if the module fails to
   load the game looks and plays exactly as before. Transform and opacity only; no blur, no
   will-change on repeated elements. */

/* ---------- tile + key colours (light) ---------- */
.word-shell, .multi-shell, .wfx-coach, .word-results {
  --wt-c: var(--mint);         --wt-c-deep: var(--mint-deep);     --wt-c-ink: var(--tile-ink);
  --wt-p: var(--yellow);       --wt-p-deep: var(--yellow-deep);   --wt-p-ink: var(--tile-ink);
  --wt-a: #7e6f9b;             --wt-a-deep: #66587f;              --wt-a-ink: #ffffff;
  --wk-a: #ddd5e8;             --wk-a-ink: #5b4b7a;               --wk-a-edge: #c9bfd8;
}
html[data-theme="dark"] .word-shell, html[data-theme="dark"] .multi-shell,
html[data-theme="dark"] .wfx-coach, html[data-theme="dark"] .word-results {
  --wt-a: #625399;             --wt-a-deep: #463a74;              --wt-a-ink: #f4eeff;
  --wk-a: #1a1136;             --wk-a-ink: #8a7bb6;               --wk-a-edge: #120b26;
}
/* Clear colors: orange = right spot, blue = in the word, each with its own mark */
html.wfx-clear .word-shell, html.wfx-clear .multi-shell, html.wfx-clear .wfx-coach, html.wfx-clear .word-results {
  --wt-c: #ff8a3d;  --wt-c-deep: #c9621f;  --wt-c-ink: #1f1440;
  --wt-p: #5fb8ff;  --wt-p-deep: #2f86cc;  --wt-p-ink: #1f1440;
}

.word-shell .word-tile.correct, .wfx-coach .word-tile.correct { background: var(--wt-c); border-color: var(--wt-c); color: var(--wt-c-ink); box-shadow: inset 0 -3px 0 var(--wt-c-deep); }
.word-shell .word-tile.present, .wfx-coach .word-tile.present { background: var(--wt-p); border-color: var(--wt-p); color: var(--wt-p-ink); box-shadow: inset 0 -3px 0 var(--wt-p-deep); }
.word-shell .word-tile.absent,  .wfx-coach .word-tile.absent  { background: var(--wt-a); border-color: var(--wt-a); color: var(--wt-a-ink); box-shadow: inset 0 -3px 0 var(--wt-a-deep); }
.multi-shell .multi-tile.correct { background: var(--wt-c); border-color: var(--wt-c); color: var(--wt-c-ink); }
.multi-shell .multi-tile.present { background: var(--wt-p); border-color: var(--wt-p); color: var(--wt-p-ink); }
.multi-shell .multi-tile.absent  { background: var(--wt-a); border-color: var(--wt-a); color: var(--wt-a-ink); }
.word-shell .word-kb-key.correct, .multi-shell .word-kb-key.correct { background: var(--wt-c); color: var(--wt-c-ink); box-shadow: 0 3px 0 var(--wt-c-deep); }
.word-shell .word-kb-key.present, .multi-shell .word-kb-key.present { background: var(--wt-p); color: var(--wt-p-ink); box-shadow: 0 3px 0 var(--wt-p-deep); }
.word-shell .word-kb-key.absent,  .multi-shell .word-kb-key.absent  { background: var(--wk-a); color: var(--wk-a-ink); box-shadow: 0 3px 0 var(--wk-a-edge); }
.word-shell .wl-tile.correct { background: var(--wt-c); box-shadow: inset 0 -2px 0 var(--wt-c-deep); color: var(--wt-c-ink); }
.word-shell .wl-tile.present { background: var(--wt-p); box-shadow: inset 0 -2px 0 var(--wt-p-deep); color: var(--wt-p-ink); }

/* Clear colors marks: a bar under the letter = right spot, a dot in the corner = in the word */
html.wfx-clear .word-tile.correct, html.wfx-clear .word-tile.present,
html.wfx-clear .word-kb-key.correct, html.wfx-clear .word-kb-key.present,
html.wfx-clear .wr-sq.correct, html.wfx-clear .wr-sq.present { position: relative; }
html.wfx-clear .word-tile.correct::after, html.wfx-clear .word-kb-key.correct::after {
  content: ""; position: absolute; left: 30%; right: 30%; bottom: 14%; height: 3px; border-radius: 2px; background: currentColor; opacity: .75;
}
html.wfx-clear .word-tile.present::after, html.wfx-clear .word-kb-key.present::after {
  content: ""; position: absolute; top: 9%; right: 9%; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75;
}
html.wfx-clear .word-kb-key.correct::after { bottom: 10%; height: 2px; }
html.wfx-clear .word-kb-key.present::after { width: 5px; height: 5px; top: 8%; right: 10%; }

/* ---------- reveal (only when wordfx.js runs it) ---------- */
html.wfx-on .word-shell .word-row { perspective: 640px; }
html.wfx-on .word-shell .word-tile.correct,
html.wfx-on .word-shell .word-tile.present,
html.wfx-on .word-shell .word-tile.absent,
html.wfx-on .word-shell .word-tile.tile-pop { animation: none; }
html.wfx-on .word-shell .word-row.shake { animation: none; }
/* the row being revealed looks typed-but-unscored until each tile turns */
html.wfx-on .word-shell .word-row[data-reveal] .word-tile:not(.wfx-shown) {
  background: var(--surface); border-color: var(--ink-faint); color: var(--ink); box-shadow: inset 0 -2px 0 var(--card-edge);
}
html.wfx-on .word-shell .word-row[data-reveal] .word-tile:not(.wfx-shown)::after { display: none; }
html.wfx-on .word-shell .word-row[data-reveal] .word-tile { transition: none; }
.word-shell .word-tile.filled { border-color: var(--ink-dim); }

/* ---------- message pill: floats just above the board instead of taking a row ---------- */
html.wfx-on .word-shell { position: relative; }
html.wfx-on .word-shell .word-msg {
  position: absolute; z-index: 6; left: 50%; top: var(--wfx-msg-top, 96px); bottom: auto;
  translate: -50% 0; min-height: 0; margin: 0; pointer-events: none; white-space: nowrap; max-width: calc(100% - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
html.wfx-on .word-shell .word-msg:not(.show) { visibility: hidden; }
.word-msg.show.win { background: var(--wt-c, var(--mint)); color: var(--wt-c-ink, #1f1440); box-shadow: 0 3px 0 var(--wt-c-deep, #2bb287); font-family: var(--font-display); font-size: 16px; padding: 7px 18px; }
html[data-theme="dark"] .word-msg.show.win { color: var(--wt-c-ink, #1f1440); }
.word-msg.show.reveal { font-family: var(--font-display); font-size: 17px; padding: 7px 18px; box-shadow: 0 3px 0 var(--purple-deep, #4a1ec1); }

/* ---------- board size: fits between header and keyboard (wordfx.js measures) ---------- */
html.wfx-on .word-shell .word-board { width: min(100%, 360px, var(--wfx-board, 360px)); gap: clamp(4px, 1.6vw, 6px); }
/* tall phones: the board sits in the middle of the free space instead of under the header */
@media (max-width: 719px) { html.wfx-on .word-shell:not(.is-ended) .word-board { margin-top: auto; } }
html.wfx-on .word-shell .word-row { gap: clamp(4px, 1.6vw, 6px); }
html.wfx-on .word-shell .word-tile { font-size: calc(var(--wfx-board, 340px) * .085); }
@media (min-width: 720px) { html.wfx-on .word-shell .word-tile { font-size: 30px; } }

/* ---------- keyboard ---------- */
.word-shell .word-kb-key, .multi-shell .word-kb-key { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.word-kb-key.wfx-down { transform: translateY(2px) scale(.95); box-shadow: 0 1px 0 var(--card-edge-strong); transition-duration: .04s; }
.word-kb-key:focus-visible { outline: 3px solid var(--focus-ring, #6b2eff); outline-offset: 2px; }
.word-kb-key[data-key="BACK"] { font-size: 18px; }
html.wfx-on .word-shell .word-kb-row { gap: 6px; }
html.wfx-on .word-shell .word-keyboard { gap: 8px; }
@media (max-width: 719px) {
  html.wfx-on .word-shell .word-kb-key { min-height: 54px; font-size: 15px; border-radius: 9px; }
  html.wfx-on .word-shell .word-kb-wide { font-size: 12px; letter-spacing: .02em; }
}
@media (max-width: 719px) and (max-height: 760px) { html.wfx-on .word-shell .word-kb-key { min-height: 48px; } }
@media (max-width: 719px) and (max-height: 640px) {
  html.wfx-on .word-shell .word-kb-key { min-height: 44px; }
  html.wfx-on .word-shell .word-keyboard { gap: 6px; padding-top: 6px; }
}
@media (max-width: 359px) { html.wfx-on .word-shell .word-kb-row { gap: 4px; } }
/* the game is over: the keyboard steps aside for the results */
.word-shell.is-ended .word-keyboard { display: none; }

/* ---------- header: one compact block on phones ---------- */
.wfx-opt-btn { width: 40px; height: 40px; min-width: 40px; padding: 0; display: inline-grid; place-items: center; border-radius: 12px; }
.wfx-opt-btn .kicon { width: 20px; height: 20px; }
@media (min-width: 720px) { .word-shell .play-actions { align-items: center; } .wfx-opt-btn { width: 46px; height: 46px; min-width: 46px; border-radius: 14px; } .wfx-opt-btn .kicon { width: 22px; height: 22px; } }
/* title row: back, title, owl; second row: legend on the left, Practice + options on the right */
html.wfx-on .word-shell > .play-head { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "back title nowl" "sub sub sub"; gap: 8px 12px; }
html.wfx-on .word-shell > .play-head.knowl-col { grid-template-columns: auto minmax(0, 1fr) var(--knowl-w); grid-template-areas: "back title nowl" "sub sub sub"; }
html.wfx-on .word-shell > .play-head .play-subtitle { min-height: 46px; display: flex; align-items: center; padding-right: 170px; }
html.wfx-on .word-shell > .play-head .play-actions { grid-area: sub; justify-self: end; align-self: center; gap: 6px; margin: 0; }
html.wfx-on .word-shell .word-legend { gap: 4px 12px; flex-wrap: nowrap; }
@media (max-width: 719px) {
  html.wfx-on .word-shell { gap: 10px; padding-top: 4px; }
  html.wfx-on .word-shell > .play-head { margin: 4px 0 2px; }
  html.wfx-on .word-shell > .play-head .play-title { font-size: 25px; }
  html.wfx-on .word-shell > .play-head .play-subtitle { font-size: 13px; min-height: 40px; padding-right: 150px; }
  html.wfx-on .word-shell > .play-head .play-actions .word-mode-link { min-height: 40px; padding: 0 14px; font-size: 14px; }
  html.wfx-on .word-shell .word-legend { gap: 4px 10px; }
  html.wfx-on .word-shell .word-legend .wl-tries { display: none; }
  html.wfx-on .word-shell .wl-tile { width: 20px; height: 20px; font-size: 12px; }
}
@media (min-width: 720px) { html.wfx-on .word-shell > .play-head .play-actions .word-mode-link { min-height: 46px; padding: 0 18px; } }
@media (max-width: 374px) {
  html.wfx-on .word-shell > .play-head .play-actions .word-mode-link { display: none; }
  html.wfx-on .word-shell > .play-head .play-subtitle { padding-right: 48px; }
  html.wfx-on .word-shell > .play-head .play-title { font-size: 22px; }
}
@media (max-width: 719px) and (max-height: 640px) {
  html.wfx-on .word-shell > .play-head .back-link { width: 40px; height: 40px; }
  html.wfx-on .word-shell > .play-head { gap: 4px 10px; }
}

/* ---------- options popover ---------- */
.wfx-pop {
  position: absolute; z-index: 30; right: 12px; top: var(--wfx-pop-top, 64px); width: min(300px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); border: 2px solid var(--card-edge); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 10px; text-align: left;
}
.wfx-pop[hidden] { display: none; }
.wfx-pop h2 { font: 700 15px/1.2 var(--font-display); margin: 4px 6px 8px; }
.wfx-opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; width: 100%; padding: 10px; border: 0; border-radius: 12px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.wfx-opt:hover { background: var(--surface-2); }
.wfx-opt:disabled { cursor: default; opacity: .6; }
.wfx-opt-name { font-weight: 800; font-size: 15px; }
.wfx-opt-note { grid-column: 1; font-size: 13px; font-weight: 600; color: var(--ink-dim); line-height: 1.35; }
.wfx-switch { grid-row: 1 / span 2; grid-column: 2; width: 44px; height: 26px; border-radius: 13px; background: var(--ink-faint); position: relative; transition: background .15s ease; }
.wfx-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .18s cubic-bezier(.3,1.4,.5,1); }
.wfx-opt[aria-checked="true"] .wfx-switch { background: var(--mint-deep, #2bb287); }
.wfx-opt[aria-checked="true"] .wfx-switch::after { transform: translateX(18px); }
.wfx-opt-link { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; text-decoration: none; color: inherit; }
.wfx-opt-link .kicon { width: 18px; height: 18px; }
.wfx-pop hr { border: 0; border-top: 2px solid var(--card-edge); margin: 6px 4px; }
.wl-hard { font-weight: 800; color: var(--pink); }

/* ---------- first-time how-to (sits over the empty board, never blocks typing) ---------- */
.wfx-coach {
  position: absolute; z-index: 7; left: 50%; translate: -50% 0; top: var(--wfx-coach-top, 120px);
  width: min(calc(100% - 24px), 380px); box-sizing: border-box;
  background: var(--surface); color: var(--ink); border: 2px solid var(--card-edge); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 16px 16px 14px; text-align: left;
}
.wfx-coach h2 { font: 700 20px/1.15 var(--font-display); margin: 0 0 4px; letter-spacing: -.01em; }
.wfx-coach p { margin: 0 0 10px; font-size: 14.5px; font-weight: 600; color: var(--ink-dim); line-height: 1.4; }
.wfx-coach .wfx-demo { display: grid; grid-template-columns: repeat(5, 40px); gap: 5px; margin: 6px 0 12px; perspective: 500px; }
.wfx-coach .word-tile { width: 40px; height: 40px; font-size: 20px; border-width: 2px; border-radius: 9px; box-sizing: border-box; }
.wfx-coach .word-tile:not(.correct):not(.present):not(.absent) { background: var(--surface); border-color: var(--ink-faint); }
.wfx-key { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 7px; }
.wfx-key li { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14.5px; }
.wfx-key .wl-tile { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 6px; font: 700 13px/1 var(--font-display); }
.wfx-key .wl-tile.correct { background: var(--wt-c); color: var(--wt-c-ink); box-shadow: inset 0 -2px 0 var(--wt-c-deep); }
.wfx-key .wl-tile.present { background: var(--wt-p); color: var(--wt-p-ink); box-shadow: inset 0 -2px 0 var(--wt-p-deep); }
.wfx-key .wl-tile.absent  { background: var(--wt-a); color: var(--wt-a-ink); box-shadow: inset 0 -2px 0 var(--wt-a-deep); }
.wfx-coach-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wfx-coach-foot span { font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.wfx-coach .btn { min-height: 44px; padding: 0 22px; }
@media (max-height: 640px) {
  .wfx-coach { padding: 12px 14px 12px; }
  .wfx-coach h2 { font-size: 18px; }
  .wfx-coach p { font-size: 13.5px; margin-bottom: 6px; }
  .wfx-coach .wfx-demo { grid-template-columns: repeat(5, 34px); margin: 4px 0 8px; }
  .wfx-coach .word-tile { width: 34px; height: 34px; font-size: 17px; }
  .wfx-key { gap: 5px; margin-bottom: 8px; }
}

/* ---------- results sheet ---------- */
.word-results { text-align: center; }
.results.word-results { padding: 20px 18px 22px; }
.word-results .wr-xp { display: inline-block; margin: 6px 0 0; padding: 3px 11px; font-size: 13px; }
.word-results .wr-head { display: flex; align-items: center; justify-content: center; gap: 14px; text-align: left; margin: 2px 0 6px; }
.word-results .wr-head .results-emoji { margin: 0; flex: none; font-size: 0; line-height: 0; }
.word-results .wr-head .results-emoji .kicon { width: 46px; height: 46px; }
.word-results .wr-head h3 { margin: 0; font-size: 28px; line-height: 1.1; outline: none; }
.word-results .wr-head .results-meta { margin: 2px 0 0; font-weight: 700; }
.wr-tiles { display: flex; justify-content: center; gap: 6px; margin: 10px 0 6px; perspective: 500px; }
.wr-tile { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: var(--wt-c); color: var(--wt-c-ink);
  box-shadow: inset 0 -3px 0 var(--wt-c-deep); font: 700 24px/1 var(--font-display); }
.word-definition .word-def-word { font-style: normal; font-weight: 800; letter-spacing: .08em; margin-right: 4px; }
.wr-share { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 14px 0 6px; }
.wr-share .btn { min-height: 52px; padding: 0 26px; font-size: 17px; }
.wr-share .btn.is-done { background: var(--mint); color: var(--tile-ink); box-shadow: 0 4px 0 var(--mint-deep); }
.wr-mini { display: grid; gap: 3px; }
.wr-mini-row { display: flex; gap: 3px; }
.wr-sq { width: 12px; height: 12px; border-radius: 3px; display: block; }
.wr-sq.correct { background: var(--wt-c); } .wr-sq.present { background: var(--wt-p); } .wr-sq.absent { background: var(--wt-a); }
html.wfx-clear .wr-sq.correct::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 2px; height: 2px; background: #1f1440; opacity: .7; }
html.wfx-clear .wr-sq.present::after { content: ""; position: absolute; right: 2px; top: 2px; width: 3px; height: 3px; border-radius: 50%; background: #1f1440; opacity: .7; }
.word-results .word-next-line { font-variant-numeric: tabular-nums; margin: 8px 0 2px; }
.word-results .word-next-line .btn { margin-top: 2px; }
.word-results .word-stats-row { gap: 0; background: var(--surface-2); border: 2px solid var(--card-edge); border-radius: 16px; padding: 10px 4px; margin: 14px 0 6px; }
.word-results .word-stats-row .word-stat { border: 0; box-shadow: none; background: transparent; padding: 2px 4px; }
.word-results .word-stats-row .word-stat + .word-stat { border-left: 2px solid var(--card-edge); border-radius: 0; }
.word-results .word-stat-num { font-size: 26px; font-variant-numeric: tabular-nums; }
.word-results .word-stat-label { font-size: 12px; letter-spacing: .03em; white-space: nowrap; }
.word-results .word-dist { max-width: 380px; gap: 6px; }
.word-results .word-dist-row { gap: 10px; }
.word-results .word-dist-num { font-family: var(--font-display); font-size: 15px; }
.word-results .word-dist-bar-wrap { position: relative; height: 24px; border-radius: 7px; background: color-mix(in srgb, var(--ink-faint) 22%, transparent); }
.word-results .word-dist-bar { position: absolute; inset: 0; width: auto; min-width: 0; padding: 0; height: auto; border-radius: 7px;
  background: var(--wt-a); transform-origin: 0 50%; transform: scaleX(max(var(--p), .035)); transition: none; }
.word-results .word-dist-bar.current { background: var(--wt-c); }
.word-results .word-dist-count { position: absolute; top: 50%; translate: 0 -50%; left: calc(max(var(--p), .035) * 100% + 8px); font-weight: 800; font-size: 13px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.word-results .word-dist-row.current .word-dist-count { color: var(--ink); }
/* a full bar keeps its count inside, on the bar */
.word-results .word-dist-bar-wrap[style*="--p:1.000"] .word-dist-count { left: auto; right: 10px; color: var(--wt-a-ink); }
.word-results .word-dist-row.current .word-dist-bar-wrap[style*="--p:1.000"] .word-dist-count { color: var(--wt-c-ink); }
.wr-practice-note { margin-top: 10px; }
@media (max-width: 380px) {
  .word-results .wr-head h3 { font-size: 24px; }
  .wr-tile { width: 40px; height: 40px; font-size: 22px; }
  .wr-share { gap: 12px; }
  .wr-sq { width: 10px; height: 10px; }
  .word-results .word-stat-num { font-size: 22px; }
}

/* ---------- reduced motion: instant states ---------- */
@media (prefers-reduced-motion: reduce) { .wfx-switch, .wfx-switch::after { transition: none; } }
body.reduced-motion .wfx-switch, body.reduced-motion .wfx-switch::after { transition: none; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
