/* =========================================================
   Wordle Helper page. Load after styles.css and tool.css.
   Class names come from the original Beat the Bot app (wordle-helper.js
   builds them), restyled here with the site's theme variables.
   Everything is scoped to #wh so it can't leak into the rest of the page.
   ========================================================= */
#wh {
  --wh-green: #6aaa64;
  --wh-yellow: #c9b458;
  --wh-grey: #787c7e;
  --wh-good: #2e7d32;
  --wh-warn: #8a6100;
  --wh-err: #c5221f;
  --wh-used: #fbf3dd;
  --wh-usedline: #e3d4a3;
  --wh-usedfg: #7d6414;
}
html[data-mode="dark"] #wh { --wh-green: #538d4e; --wh-yellow: #b59f3b; --wh-grey: #3a3a3c; --wh-good: #7ec06f; --wh-warn: #e4a11b; --wh-err: #e06c6c; --wh-used: #332d22; --wh-usedline: #5a4a2c; --wh-usedfg: #c9ac68; }
@media (prefers-color-scheme: dark) {
  html[data-mode="auto"] #wh { --wh-green: #538d4e; --wh-yellow: #b59f3b; --wh-grey: #3a3a3c; --wh-good: #7ec06f; --wh-warn: #e4a11b; --wh-err: #e06c6c; --wh-used: #332d22; --wh-usedline: #5a4a2c; --wh-usedfg: #c9ac68; }
}

#wh .wh-layout {
  display: grid;
  grid-template-columns: minmax(0, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
#wh .wh-layout > * { min-width: 0; }
@media (min-width: 901px) { #wh .wh-play { position: sticky; top: 76px; } }
@media (max-width: 900px) { #wh .wh-layout { grid-template-columns: minmax(0, 1fr); } }
#wh .wh-play { user-select: none; -webkit-user-select: none; }

/* Toolbar */
#wh .wh-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
#wh .wh-count { flex: 1; color: var(--muted); font-size: 0.92rem; }
#wh .wh-count b { color: var(--text); font-size: 1.05rem; }
#wh .wh-bar .btn { height: 34px; }

/* Loading */
#wh #boot { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 0; }
#wh #boot .bt { font-size: 0.85rem; color: var(--muted); }
#wh #boot .track { width: 200px; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
#wh #boot .track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* Board */
#wh #board { display: flex; flex-direction: column; gap: 6px; align-items: center; }
#wh .row { display: flex; gap: 6px; align-items: center; }
#wh .rowtag { width: 22px; font-size: 0.72rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
#wh .tile {
  width: 52px; height: 52px;
  border: 2px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; text-transform: uppercase;
  background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s, transform .08s;
}
#wh .tile.filled { border-color: var(--muted); }
#wh .tile.g0, #wh .tile.g1, #wh .tile.g2 { color: #fff; }
#wh .tile.g0 { background: var(--wh-grey); border-color: var(--wh-grey); }
#wh .tile.g1 { background: var(--wh-yellow); border-color: var(--wh-yellow); }
#wh .tile.g2 { background: var(--wh-green); border-color: var(--wh-green); }
#wh .row.active .tile.filled { cursor: pointer; }
#wh .row.active .tile.filled:hover { filter: brightness(1.08); }
#wh .row.active .tile:active { transform: scale(.94); }
#wh .row:not(.active) .rowtag + .tile { margin-left: 0; }
#wh #hint { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 10px 0 12px; line-height: 1.45; min-height: 1.2em; }

/* On-screen keyboard */
#wh #wh-kb { padding-top: 4px; }
#wh .krow { display: flex; justify-content: center; gap: 5px; margin-bottom: 6px; }
#wh .k {
  height: 52px; min-width: 0; flex: 1;
  border-radius: 6px; border: 0;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 0.95rem; font-weight: 700; text-transform: uppercase;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#wh .k:hover { filter: brightness(0.96); }
#wh .k:active { transform: translateY(1px); }
#wh .k:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#wh .k.wide { flex: 1.6; font-size: 0.72rem; letter-spacing: .03em; }
#wh .k.dead { background: var(--wh-grey); color: #fff; opacity: .55; }
#wh .k.k1 { background: var(--wh-yellow); color: #fff; }
#wh .k.k2 { background: var(--wh-green); color: #fff; }

/* Results column (built by wordle-helper.js) */
#wh #out .panel + .panel, #wh #out .solvedbtn + .panel { margin-top: 16px; }
#wh #out .panel h2 { font-size: 0.95rem; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
#wh .big { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--text); }
#wh .sub { font-size: 0.85rem; color: var(--muted); margin-top: 6px; line-height: 1.5; }
#wh .seg { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
#wh .wordwrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; max-height: 260px; overflow-y: auto; padding: 2px; }
#wh .w {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.15;
  padding: 5px 9px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  -webkit-touch-callout: none;
}
#wh .w b { font-size: 0.88rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
#wh .w u { text-decoration: none; font-size: 0.66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#wh .w.tap { cursor: pointer; }
#wh .w.tap:hover { border-color: var(--accent); }
#wh .w.used { background: var(--wh-used); border-color: var(--wh-usedline); }
#wh .w.used u { color: var(--wh-usedfg); }
#wh .w.more { justify-content: center; color: var(--muted); font-size: 0.85rem; }
#wh .w.picked { outline: 2px solid var(--accent); outline-offset: 1px; }

#wh .sug { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-top: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
#wh .sug:first-of-type { border-top: 0; }
#wh .sug:hover { background: var(--surface-2); }
#wh .sug .rank { width: 22px; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
#wh .sug .word { font-size: 1.1rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; width: 86px; flex: none; }
#wh .sug.best .word { color: var(--wh-good); }
#wh .sug .meta { flex: 1; min-width: 0; font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
#wh .sug .meta b { color: var(--text); }
#wh .sug .bar { display: block; height: 5px; background: var(--surface-2); border-radius: 3px; margin-top: 5px; overflow: hidden; }
#wh .sug .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
#wh .sug .go { font-size: 0.75rem; color: var(--accent); font-weight: 700; border: 1px solid var(--accent); border-radius: 6px; padding: 4px 8px; }
#wh .sug.mine { background: var(--accent-soft); }
#wh .sug .rank.pick { color: var(--accent); font-weight: 800; width: 42px; line-height: 1.15; }
#wh .sug .rank .tag { display: block; font-style: normal; font-size: 0.55rem; letter-spacing: .1em; }
#wh .sug .can { color: var(--wh-good); }
#wh .sug .cant { color: var(--muted); }
#wh .warn { color: var(--wh-warn); }
#wh .err { color: var(--wh-err); }

#wh .grp { border-top: 1px solid var(--border); padding: 9px 0; }
#wh .grp:first-of-type { border-top: 0; }
#wh .grphead { display: flex; align-items: center; gap: 10px; cursor: pointer; }
#wh .mini { display: flex; gap: 2px; }
#wh .mini i { width: 18px; height: 18px; border-radius: 3px; display: block; background: var(--wh-grey); font-style: normal; font-size: 0.62rem; font-weight: 700; color: #fff; text-align: center; line-height: 18px; text-transform: uppercase; }
#wh .mini i.g1 { background: var(--wh-yellow); }
#wh .mini i.g2 { background: var(--wh-green); }
#wh .grphead .n { font-size: 0.85rem; color: var(--muted); flex: 1; }
#wh .grphead .n b { color: var(--text); }
#wh .grphead .caret { color: var(--muted); font-size: 0.75rem; }
#wh .grpbody { display: none; margin-top: 6px; }
#wh .grp.open .grpbody { display: block; }

#wh button.primary { width: 100%; padding: 12px; border-radius: 10px; border: 0; font: inherit; font-size: 0.95rem; font-weight: 700; background: var(--wh-green); color: #fff; cursor: pointer; }
#wh button.primary:hover { filter: brightness(1.05); }
#wh button.solvedbtn { background: transparent; border: 1.5px solid var(--wh-green); color: var(--wh-good); margin-bottom: 16px; }
#wh button.solvedbtn:hover { background: var(--surface-2); }
#wh button.ghost { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--border); font: inherit; font-size: 0.88rem; font-weight: 600; background: transparent; color: var(--muted); cursor: pointer; margin-top: 10px; }

/* Title row with the Settings button, right-aligned with the results column */
.wh-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wh-head-row h1 { margin: 0; }
.wh-gear { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; }
.wh-gear.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.wh-head p { margin-top: 8px; }

/* Settings panel */
#wh .wh-settings { margin-bottom: 16px; }
#wh .wh-settings .panel-head { margin-bottom: 0; }
#wh .wh-settings .sgroup:first-of-type { margin-top: 4px; }
#wh .sgroup { border-top: 1px solid var(--border); padding: 14px 0 4px; margin-top: 12px; }
#wh .sttl, #wh .histttl { display: block; font-size: 0.95rem; font-weight: 700; }
#wh .ssub, #wh .histsub { display: block; font-size: 0.82rem; color: var(--muted); line-height: 1.5; margin-top: 3px; }
#wh .opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
#wh .opt:first-child { border-top: 0; margin-top: 6px; }
#wh .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); flex: none; margin-top: 2px; position: relative; }
#wh .opt.on .radio { border-color: var(--accent); }
#wh .opt.on .radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
#wh .optlab { flex: 1; }
#wh .optlab b { display: block; font-size: 0.9rem; font-weight: 600; }
#wh .optlab i { display: block; font-style: normal; font-size: 0.8rem; color: var(--muted); line-height: 1.45; margin-top: 2px; }
#wh .histrow { display: flex; align-items: center; gap: 14px; }
#wh .histlab { flex: 1; min-width: 0; }
#wh .switch { width: 46px; height: 27px; border-radius: 999px; background: var(--border); border: 0; padding: 0; position: relative; flex: none; cursor: pointer; transition: background .15s; }
#wh .switch i { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .15s; display: block; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
#wh .switch.on { background: var(--accent); }
#wh .switch.on i { transform: translateX(19px); }
#wh .switch.off { opacity: .4; }
#wh .switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#wh .sseg { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin: 14px 0 4px; }
#wh .sliderow { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
#wh .slab { font-size: 0.82rem; color: var(--muted); flex: 1; }
#wh .sval { font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#wh .sliderow input[type=range] { width: 100%; accent-color: var(--accent); }
#wh .histnote { font-size: 0.8rem; color: var(--muted); line-height: 1.5; margin-top: 8px; }
#wh .histmsg { font-size: 0.85rem; line-height: 1.5; margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); }
#wh .histmsg.bad { background: color-mix(in srgb, var(--wh-err) 12%, transparent); color: var(--wh-err); }

/* Solved card */
#wh #overlay { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.45); }
#wh #overlay.show { display: flex; }
#wh #overlay .wh-card { background: var(--surface); color: var(--text); border-radius: 18px; padding: 28px 26px 24px; width: min(340px, 100%); text-align: center; box-shadow: var(--shadow); }
#wh #overlay .t { font-size: 2rem; font-weight: 800; letter-spacing: .12em; color: var(--wh-good); margin-bottom: 6px; }
#wh #overlay .s { color: var(--muted); margin-bottom: 20px; }

@media (max-width: 420px) {
  #wh .tile { width: 48px; height: 48px; font-size: 1.45rem; }
  #wh .k { height: 50px; font-size: 0.85rem; }
  #wh .krow { gap: 4px; }
  #wh .sug .word { width: 74px; font-size: 1rem; }
}

/* A typed word that isn't in Wordle's list: red ring, red hint, shake on Enter. */
#wh .row.invalid .tile.filled { box-shadow: 0 0 0 2px #dc2626; }
#wh #hint.bad { color: #dc2626; }
#wh .row.shake { animation: wh-shake .35s; }
@keyframes wh-shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { #wh .row.shake { animation: none; } }
#wh button.solvedbtn[hidden] { display: none; }
