/* Mini crossword (js/crossword.js). Colours come from the --bia-* tokens where a
   token exists so high-contrast mode swaps them for free; the greens and the
   error red below are the audited values already used elsewhere in the app. */

.cwGameContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 8px;
    max-width: 560px;
    margin: 0 auto;
}

/* ── Current clue ───────────────────────────────────────────────────────── */

.cwClueBar {
    display: flex;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 440px;
    background: #f2f0fb;
    border-radius: 12px;
    overflow: hidden;
}

.cwClueText {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 8px 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--bia-fg, #1f2937);
    text-align: center;
}

.cwClueNav {
    flex: 0 0 auto;
    width: 40px;
    min-height: 48px;
    background: transparent;
    border: none;
    color: var(--bia-link, #5b4fb8);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cwClueNav:hover {
    background: #e6e2f7;
}

/* ── The grid ───────────────────────────────────────────────────────────── */

.cwGrid {
    display: grid;
    gap: 2px;
    width: 100%;
    max-width: 360px;
    background: #2d2a45;
    border: 2px solid #2d2a45;
    border-radius: 4px;
}

.cwCell {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.14s ease;
}

.cwCell.cwBlock {
    background: #2d2a45;
    cursor: default;
}

.cwNum {
    position: absolute;
    top: 1px;
    left: 3px;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
    color: var(--bia-muted, #595959);
}

.cwLetter {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--bia-fg, #1f2937);
    text-transform: none;
}

/* The word you are on, and the single cell inside it that the next letter lands
   in. The selected cell also keeps a ring, so which cell is active is not carried
   by the fill colour alone. */
.cwCell.cwInWord {
    background: #dce9fb;
}

.cwCell.cwSelected {
    background: #f7d774;
    box-shadow: inset 0 0 0 3px #8a6d0b;
}

.cwCell.cwCorrect {
    background: #cdeadd;
}

.cwCell.cwCorrect .cwLetter {
    color: #14513c;
}

/* Check marked this letter as wrong. The corner wedge means it does not read as
   colour alone. */
.cwCell.cwWrong .cwLetter {
    color: #b3261e;
}

.cwCell.cwWrong::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-top: 10px solid #b3261e;
    border-left: 10px solid transparent;
}

.cwCell.cwJustSolved {
    animation: cwPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cwPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.14); }
    100% { transform: scale(1); }
}

/* ── On-screen keyboard ─────────────────────────────────────────────────── */

.cwKeyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    max-width: 440px;
}

.cwKeyRow {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.cwKey {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    background: #e6e2f7;
    color: var(--bia-fg, #1f2937);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease;
}

.cwKey:hover {
    background: #d5cff0;
}

.cwKey:active {
    background: #c3bbe8;
}

.cwKeyWide {
    flex: 1.5 1 auto;
    color: var(--bia-link, #5b4fb8);
}

/* ── Tools ──────────────────────────────────────────────────────────────── */

.cwToolBar {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.cwToolBtn {
    min-height: 44px;
    padding: 9px 18px;
    background: transparent;
    color: var(--bia-link, #5b4fb8);
    border: 2px solid var(--bia-border, #767676);
    border-radius: 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.cwToolBtn:hover:not(:disabled) {
    background: #f2f0fb;
    border-color: var(--bia-link, #5b4fb8);
}

.cwToolBtn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ── Clue lists ─────────────────────────────────────────────────────────── */

.cwClueLists {
    display: flex;
    gap: 18px;
    width: 100%;
    max-width: 440px;
    flex-wrap: wrap;
}

.cwClueList {
    flex: 1 1 180px;
    min-width: 0;
}

.cwClueHeading {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--bia-muted, #595959);
}

.cwClueUl {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cwClueUl li {
    margin: 0;
}

.cwClueItem {
    display: flex;
    gap: 8px;
    width: 100%;
    padding: 6px 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--bia-fg, #1f2937);
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cwClueItem:hover {
    background: #f2f0fb;
}

/* The clue you are on. Bold plus the fill, so it is not colour alone. */
.cwClueItem.cwClueCurrent {
    background: #dce9fb;
    font-weight: 700;
}

.cwClueNum {
    flex: 0 0 auto;
    min-width: 16px;
    font-weight: 700;
    color: var(--bia-muted, #595959);
}

.cwClueItem.cwClueCurrent .cwClueNum {
    color: var(--bia-fg, #1f2937);
}

/* ── Done / complete ────────────────────────────────────────────────────── */

.cwDoneArea {
    min-height: 0;
}

.cwDoneBtn {
    min-height: 44px;
    padding: 11px 34px;
    background: #237355;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(35, 115, 85, 0.3);
    -webkit-tap-highlight-color: transparent;
}

.cwDoneBtn:hover {
    background: #1c6349;
}

.cwCompleteBox {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 16px;
    animation: cwFadeIn 0.35s ease;
}

.cwCompleteIcon svg {
    animation: cwSummaryPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cwCompleteText {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f6b50;
}

.cwCompleteSub {
    margin: 0;
    font-size: 14px;
    color: var(--bia-muted, #595959);
}

.cwError {
    color: #b3261e;
    text-align: center;
    padding: 24px;
}

@keyframes cwFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes cwSummaryPop {
    0%   { transform: scale(0.4); opacity: 0; }
    70%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── High contrast ──────────────────────────────────────────────────────── */

html[data-a11y-contrast="high"] .cwCell.cwInWord {
    background: #c3dcfa;
}

html[data-a11y-contrast="high"] .cwCell.cwSelected {
    background: #f5cd54;
    box-shadow: inset 0 0 0 3px #5a4705;
}

html[data-a11y-contrast="high"] .cwKey {
    background: #ddd7f4;
    color: #1a1626;
}

html[data-a11y-contrast="high"] .cwCell.cwWrong .cwLetter {
    color: #8c1d16;
}

/* ── Reduced motion (OS preference; the account toggle also neutralises motion
      globally via html[data-a11y-motion]) ───────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .cwCell, .cwKey, .cwToolBtn { transition: none; }
    .cwCell.cwJustSolved, .cwCompleteBox, .cwCompleteIcon svg { animation: none; }
}

@media only screen and (max-width: 480px) {
    .cwGrid { max-width: 300px; }
    .cwLetter { font-size: 17px; }
    .cwKey { height: 40px; font-size: 13px; }
    .cwClueText { font-size: 14px; }
    .cwClueLists { gap: 10px; }
}
