/* Emoji Colour by Sums.
   Screen: a fluid worksheet card. Print: a single A4 portrait page.
   The print sizing follows grid-9x9.html -- the grid is square, so its size is
   capped by the A4 short edge: 10 cells x 18mm = 180mm, i.e. ~86% of 210mm. */

:root {
  --ink: #000;
  --line: 1px;
  --outer: 2px;
  --paper: #fff;
  --ui-bg: #eef1f5;
  --ui-line: #c6ccd5;
  --accent: #2f6fd0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ui-bg);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: #1b1b1b;
}

/* ---------------------------------------------------------------- controls */

.controls {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 4px;
}

.control-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.control-label {
  flex: 0 0 auto;
  width: 64px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5b6673;
}

.picker, .buttons { display: flex; flex-wrap: wrap; gap: 6px; }

.picker button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  cursor: pointer;
}

.picker button .glyph { font-size: 18px; line-height: 1; }

.picker button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: #eaf1fc;
}

.buttons button {
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  cursor: pointer;
}

.buttons button:hover, .picker button:hover { border-color: #93a0b0; }

.buttons button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #5b6673;
}

/* ------------------------------------------------------------------- sheet */

.sheet {
  max-width: 820px;
  margin: 0 auto 32px;
  padding: 24px 24px 32px;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.sheet h1 {
  margin: 0 0 10px;
  text-align: center;
  font-size: clamp(18px, 3.4vw, 26px);
  line-height: 1.2;
}

.instructions {
  margin: 0 0 14px;
  font-size: clamp(13px, 1.9vw, 15px);
  line-height: 1.45;
}

/* --------------------------------------------------------------- colour key */

.key {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.key-box {
  flex: 1 1 160px;
  display: block;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  text-align: center;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
}

.key-box .key-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: clamp(14px, 2.1vw, 17px);
  font-weight: 700;
}

.key-box .swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 2px;
}

.key-box .key-numbers {
  margin-top: 2px;
  font-size: clamp(13px, 2vw, 16px);
}

.key-box[aria-pressed="true"] {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

.grid {
  --cell: min(8.6vw, 62px);
  margin: 0 auto;
  border-collapse: collapse;
  table-layout: fixed;
  border: var(--outer) solid var(--ink);
  touch-action: none;
}

.grid td {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  text-align: center;
  vertical-align: middle;
  border: var(--line) solid var(--ink);
  font-size: clamp(9px, 1.9vw, 14px);
  white-space: nowrap;
  user-select: none;
}

.grid td.sum { cursor: pointer; }

/* Background squares: fully drawn like every other square but left empty,
   exactly as on the original worksheet -- they are simply not part of the
   puzzle. The border is restated so no later rule can quietly drop it. */
.grid td.blank {
  cursor: default;
  border: var(--line) solid var(--ink);
}

.grid td.wrong { box-shadow: inset 0 0 0 3px #d81b2f; }

/* ------------------------------------------------------------------- print */

@page { size: A4 portrait; margin: 0; }

@media print {
  html, body { background: #fff; }
  .no-print { display: none !important; }

  .sheet {
    width: 210mm;
    height: 297mm;
    max-width: none;
    margin: 0 auto;
    padding: 12mm 15mm;
    box-shadow: none;
  }

  .sheet h1 { font-size: 20pt; }
  .instructions { font-size: 11pt; }

  .key-box .key-name { font-size: 12pt; }
  .key-box .key-numbers { font-size: 11pt; }
  .key-box[aria-pressed="true"] { outline: none; }

  .grid {
    --cell: 18mm;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .grid td { font-size: 10pt; }
}
