/* Mini Crossword. */

.mc { container-type: inline-size; display: grid; justify-content: center; }

/* The grid is square. It is as wide as its column, but never so tall that the clue and the keys
   under it are pushed off the screen: the bars above it and what lies below take about 434px.
   That room and the 220px floor (44px squares) are in fixed units, so that a visitor who sets
   larger text does not get a smaller grid for it; the page then scrolls a little instead. */
.mc-grid {
  --side: max(min(100cqw, 220px), min(100cqw, calc(100vh - 434px), 22rem));
  --side: max(min(100cqw, 220px), min(100cqw, calc(100svh - 434px), 22rem));
  width: var(--side); height: var(--side);
  display: grid; grid-template-rows: repeat(5, 1fr);
  border: 2px solid var(--ink); border-radius: 3px; background: var(--sheet); overflow: hidden;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.mc-row { display: grid; grid-template-columns: repeat(5, 1fr); min-height: 0; }
.mc-gc { display: block; min-width: 0; min-height: 0; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.mc-gc:nth-child(5) { border-right: 0; }
.mc-row:nth-child(5) > .mc-gc { border-bottom: 0; }
.mc-gc.black { background: var(--ink); }

.mc-sq {
  position: relative; width: 100%; height: 100%; padding: 14% 0 0; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
  font: 600 calc(var(--side) / 5 * 0.52)/1 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
.mc-sq:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; z-index: 1; }
/* the clue number, in the corner */
.mc-n { position: absolute; top: 3px; left: 4px; color: var(--stone); font: 600 max(15px, calc(var(--side) / 5 * 0.22))/1 var(--sans); }
.mc-n::before { content: attr(data-n); }   /* drawn from data: the square's visible text is its letter alone */

/* the word being filled, and the square the cursor is on */
.mc-sq.in { background: color-mix(in srgb, var(--c) 14%, transparent); }
.mc-sq.sel { background: color-mix(in srgb, var(--c) 32%, transparent); box-shadow: inset 0 0 0 3px var(--c); }

/* a revealed letter is in the game's ink, with a dot in its corner: it is fixed */
.mc-sq.shown .mc-l { color: var(--c); }
.mc-sq.shown::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* a letter a check found wrong: a red stroke through the corner of its square */
.mc-sq.bad::before {
  content: ""; position: absolute; top: 0; right: 0; width: 46%; height: 46%; pointer-events: none;
  background: linear-gradient(to top right, transparent calc(50% - 1.5px), #A3261D calc(50% - 1.5px), #A3261D calc(50% + 1.5px), transparent calc(50% + 1.5px));
}

/* The two kinds of help, in a row under the grid. On a short screen the clue and the keys lie over
   this row until the page is scrolled: the grid, the clue and the keys are what must be seen together. */
.mc-helpbox { max-width: 22rem; margin: 1.25rem auto 0; padding-bottom: 0.5rem; }
.mc-help { display: flex; gap: min(0.5rem, 10px); }
.mc-help .btn { flex: 1 1 0; min-width: 0; min-height: min(2.75rem, 48px); padding: 0 0.5rem; gap: min(0.5rem, 8px); font-size: clamp(15px, 0.9375rem, 18px); }
.mc-help .btn .ic { flex: none; width: min(1.1875rem, 22px); height: min(1.1875rem, 22px); }
/* what the help found, said where the eye is */
.mc-said { min-height: 1.35em; margin: 0.375rem 0 0; color: var(--stone); font: 400 clamp(15px, 0.9375rem, 18px)/1.35 var(--sans); text-align: center; }

/* The clue and the letter keys stay at the foot of the screen. */
.mc-pad {
  position: sticky; bottom: 0; z-index: 2; padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--paper); border-top: 1px solid var(--hair);
}
.mc-clue { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.125rem; padding-top: 0.125rem; }
/* Room for two lines, so the keys do not jump as the clues change. The size is capped: at very
   large text the block would cover the grid, and every clue is in the lists below at full size. */
/* the two arrows stop growing at 48px, so that the clue between them keeps its room however large the text */
.mc-clue .iconbtn { width: min(2.75rem, 48px); height: min(2.75rem, 48px); }
.mc-now { margin: 0; min-width: 0; overflow-wrap: anywhere; min-height: 2.6em; display: flex; align-items: center; font: 500 clamp(15px, 1.0625rem, 20px)/1.3 var(--sans); }
.mc-now b { color: var(--c); font-weight: 700; }
/* the keys sit inside the board's own gutters, and stay a fixed height however large the text is set */
.mc-pad .keys { padding: 0.375rem 0 0.5rem; }
.mc-pad .key { min-height: min(2.75rem, 56px); }

/* every clue, across and down */
.mc-lists { display: grid; gap: 1.25rem 2rem; padding: 1.25rem 0 0.5rem; }
@media (min-width: 40rem) { .mc-lists { grid-template-columns: 1fr 1fr; } }
.mc-h { margin: 0 0 0.25rem; color: var(--stone); font: 600 0.9375rem/1.2 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; }
.mc-list { list-style: none; margin: 0; padding: 0; }
.mc-item {
  width: 100%; min-height: 2.75rem; padding: 0.5rem; border: 0; border-bottom: 1px solid var(--hair); border-radius: 0; background: none; cursor: pointer;
  display: grid; grid-template-columns: 1.5rem 1fr; gap: 0.5rem; align-items: baseline; text-align: left; color: var(--ink); font: 400 1.0625rem/1.35 var(--sans);
}
.mc-num { color: var(--c); font-weight: 700; }
.mc-num::before { content: attr(data-n); }   /* drawn from data: the clue, the button's visible text, is inside its name */
.mc-item[aria-current="true"] { background: color-mix(in srgb, var(--c) 12%, transparent); box-shadow: inset 3px 0 0 var(--c); }
.mc-item.done { color: var(--stone); }
.mc-item:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }

/* the finished grid on the answers page: a real table, read row by row, and the words under it */
.mc-answer {
  width: 100%; max-width: 16rem; margin: 1rem 0 1.25rem; border-collapse: collapse; table-layout: fixed;
  background: var(--sheet); border: 2px solid var(--ink);
}
.mc-answer caption { caption-side: bottom; padding-top: 0.5rem; text-align: left; color: var(--stone); font-size: 0.9375rem; }
.mc-answer td { position: relative; padding: 0; border: 1px solid var(--ink); color: var(--c); font: 600 1.375rem/1 var(--sans); }
/* a table cell takes its height from its content: this makes each one as tall as it is wide */
.mc-answer td::before { content: ""; display: block; padding-top: 100%; }
.mc-answer td.black { background: var(--ink); }
.mc-al { position: absolute; inset: 22% 0 0; display: grid; place-items: center; }
.mc-an { position: absolute; top: 2px; left: 3px; color: var(--stone); font: 600 0.9375rem/1 var(--sans); }
.mc-words { display: grid; grid-template-columns: repeat(2, minmax(0, 8rem)); gap: 0 2rem; margin-bottom: 1.5rem; }
.mc-words h3 { margin: 0 0 0.25rem; color: var(--stone); font: 600 0.9375rem/1.2 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; }
.mc-words ul { list-style: none; margin: 0; padding: 0; }
.mc-words li { padding: 0.1875rem 0; font: 400 1.0625rem/1.35 var(--sans); }
.mc-words b { display: inline-block; min-width: 1.5rem; color: var(--c); font-weight: 700; }

/* Where the system sets the colours, tints are dropped: the word, the cursor and the marks keep a sign. */
@media (forced-colors: active) {
  .mc-gc.black { background: CanvasText; }
  .mc-sq.in { outline: 1px solid Highlight; outline-offset: -2px; }
  .mc-sq.sel { outline: 4px solid Highlight; outline-offset: -4px; }
  .mc-sq.shown::after { background: Highlight; }
  .mc-sq.bad::before { background: linear-gradient(to top right, transparent calc(50% - 1.5px), CanvasText calc(50% - 1.5px), CanvasText calc(50% + 1.5px), transparent calc(50% + 1.5px)); }
  .mc-item[aria-current="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .mc-answer td.black { background: CanvasText; }
}


/* While the board loads, about the room it will take (game.css): the drawn board measured 1114 to 1187px while the clue
   lists stand one above the other, 925 to 944 once they stand side by side (40rem). */
#board { --board-wait: 1160px; }
@media (min-width: 40rem) { #board { --board-wait: 944px; } }
