/* CROSSTHING.
 *
 * The palette and every rule that used to live as inline style objects in the
 * component. Cell state (cursor, active entry, wrong letter) is a class here
 * rather than a computed background, so the render pass only ever toggles
 * class names and never writes style strings.
 */

:root {
    --ground: #DCE3E0;      /* the page, and the gaps in the grid */
    --ink: #0E1618;
    --cell: #FBFAF7;
    --accent: #D81E5B;
    --muted: #6F8082;
    --entry-tint: #DEEDE8;  /* the entry the cursor is in */
    --cursor-tint: #FBD3E0; /* the cell the cursor is on */
    --block: #C7D1CE;       /* rules and hairlines */

    --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
    --mono: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

    --cell-size: 50px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 1rem;
    min-height: 100vh;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

main { max-width: 940px; margin: 0 auto; }

/* --- masthead --- */

header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--block);
}

.title { display: flex; align-items: baseline; gap: 0.75rem; }

/* Set in caps, so the tracking opens up slightly. The negative tracking that
   suited a lowercase wordmark closes caps into a block. */
h1 {
    margin: 0;
    font-size: 2.25rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.1;
}

.issue {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--muted);
}

.nav { display: flex; gap: 0.25rem; }

.chip {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.75rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.chip.on { border-color: var(--ink); background: var(--ink); color: var(--cell); }

/* --- layout --- */

.board {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 2rem;
}

.clues { flex: 1 1 260px; min-width: 260px; }

/* --- the grid --- */

/* The board's own ink shows through as the rules between cells: each cell
   draws a 1px border and the container a 2px one, so the outer edge reads
   heavier than the internal lines without any per-cell special casing. */
.grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 5), var(--cell-size));
    width: fit-content;
    background: var(--ink);
    border: 2px solid var(--ink);
}

.block {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--ground);
}

.cell {
    position: relative;
    width: var(--cell-size);
    height: var(--cell-size);
    margin: 0;
    padding: 0;
    border: 1px solid var(--ink);
    background: var(--cell);
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell.active { background: var(--entry-tint); }
.cell.sel    { background: var(--cursor-tint); }

.cell .num {
    position: absolute;
    top: 1px;
    left: 3px;
    font-family: var(--mono);
    font-size: 9px;
    line-height: 1;
    color: var(--muted);
}

.cell .letter {
    font-family: var(--mono);
    font-size: 23px;
    font-weight: 600;
    line-height: 1;
    padding-top: 4px;
    color: var(--ink);
}

.cell.wrong .letter { color: var(--accent); text-decoration: line-through; }

.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Off screen rather than display:none, because a hidden input cannot take
   focus and therefore cannot raise a keyboard. */
.capture {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* --- tools --- */

.tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tool {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--ink);
    border-radius: 2px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.tool:hover { background: var(--entry-tint); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.help {
    margin: 0.75rem 0 0;
    max-width: calc(var(--cell-size) * 5);
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
}

/* --- clues --- */

.clues section { margin-bottom: 1.5rem; }

.clues h2 {
    margin: 0 0 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--block);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.18em;
    color: var(--muted);
}

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

.clue {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.25rem 0.5rem;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 2px;
    background: transparent;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 17px;
    cursor: pointer;
}

.clue.on { background: var(--entry-tint); border-left-color: var(--accent); }
.clue:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.clue-num { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-right: 8px; }
.clue-len { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 6px; }

/* --- the reveal --- */

.result {
    margin-top: 0.5rem;
    padding: 1.25rem;
    border: 1px solid var(--ink);
    border-radius: 2px;
    background: var(--cell);
}

.result[hidden] { display: none; }

.result-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--muted);
}

.result-text {
    margin: 0.5rem 0 1rem;
    max-width: 60ch;
    font-size: 22px;
    line-height: 1.35;
    color: var(--accent);
}

.result-tally {
    margin: 0;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
}

@keyframes drop {
    0%   { transform: translateY(-6px) scale(.96); opacity: .4; }
    60%  { transform: translateY(2px) scale(1.03); }
    100% { transform: none; opacity: 1; }
}

.result.drop { animation: drop .45s cubic-bezier(.2,.9,.3,1.4) both; }

@media (prefers-reduced-motion: reduce) {
    .result.drop { animation: none; }
}

@media (min-width: 640px) {
    body { padding: 2rem; }
    h1 { font-size: 3rem; line-height: 1; }
}
