/* Loomwork's own colours (src/ui/palettes.ts in the app): Linen, and Indigo Night in dark mode. */
:root {
  color-scheme: light dark;
  --bg: #f3eee3;
  --surface: #faf7f0;
  --ink: #22243a;
  --muted: #595b70;
  --line: #ddd5c3;
  --grid: #d6cdb9;
  --major: #a89e88;
  --accent: #2e3a6b;
  --accent-ink: #f6f2e8;
  --accent-soft: #dedfe9;
  --thread: #2e3a6b;
  --weave: #44528c;
  --shade: #232d56;
  --cross: #b4553a;
  --clue: #22243a;
  --clue-done: #a9a495;
  --clue-active: #e2e1ea;
  --cell: 24px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14172a;
    --surface: #1b1f36;
    --ink: #ece6d8;
    --muted: #a9abc1;
    --line: #2a2f4e;
    --grid: #2d3253;
    --major: #5a6089;
    --accent: #e8e1d3;
    --accent-ink: #14172a;
    --accent-soft: #272c4d;
    --thread: #e8e1d3;
    --weave: #f6f1e6;
    --shade: #cbc2ae;
    --cross: #e58b73;
    --clue: #ece6d8;
    --clue-done: #5f6486;
    --clue-active: #262b4d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 'Atkinson Hyperlegible', system-ui, -apple-system, sans-serif;
}
main { max-width: 680px; margin: 0 auto; padding: 24px 8px 56px; }
main > :not(.board) { margin-left: 8px; margin-right: 8px; }
h1, h2 { font-family: 'Young Serif', Georgia, serif; font-weight: 400; line-height: 1.2; }
h1 { font-size: 2rem; margin: 0 0 4px; }
h2 { font-size: 1.35rem; margin: 0 0 6px; }
section { margin-top: 36px; }
p { margin: 0 0 12px; color: var(--muted); }
a { color: inherit; }
.crumbs { font-size: 0.95rem; margin-bottom: 16px; color: var(--muted); }
.meta { margin-bottom: 16px; font-variant-numeric: tabular-nums; }
footer { margin-top: 40px; font-size: 0.9rem; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }

.board {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
.cols { display: grid; grid-template-columns: repeat(15, var(--cell)); align-items: end; }
.rows { display: grid; grid-template-rows: repeat(15, var(--cell)); justify-items: end; }
.clue {
  display: flex;
  color: var(--clue);
  font-weight: 700;
  font-size: calc(var(--cell) * 0.6);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  border-radius: 3px;
}
.cols .clue { flex-direction: column; align-items: center; padding-bottom: 3px; height: 100%; justify-content: flex-end; }
.cols .clue span { padding: 1px 0; }
.rows .clue { align-items: center; padding-right: 4px; height: 100%; width: 100%; justify-content: flex-end; }
.rows .clue span { padding: 0 calc(var(--cell) * 0.1); }
.clue.done { color: var(--clue-done); }
.clue.active { background: var(--clue-active); }

.cells {
  display: grid;
  grid-template-columns: repeat(15, var(--cell));
  grid-template-rows: repeat(15, var(--cell));
  background: var(--surface);
  outline: 1px solid var(--major);
  touch-action: none;
  cursor: pointer;
}
.cells:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.c {
  position: relative;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
}
.c.mx { border-right-color: var(--major); }
.c.my { border-bottom-color: var(--major); }
.c.hl { background: var(--clue-active); }
.c.f {
  background: repeating-linear-gradient(135deg, var(--thread) 0 3px, var(--weave) 3px 4px, var(--thread) 4px 7px, var(--shade) 7px 8px);
}
.c.x::before, .c.x::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  top: calc(50% - 1px);
  height: 2px;
  border-radius: 1px;
  background: var(--cross);
  transform: rotate(45deg);
}
.c.x::after { transform: rotate(-45deg); }
.c.cur { box-shadow: inset 0 0 0 2px var(--cross); }

/* The finish: the marks and the chart lift away, in a wave from the top left. */
.solved .cells { cursor: default; outline-color: var(--line); }
.solved .c { border-color: transparent; transition: border-color 0.5s; transition-delay: var(--d); }
.solved .c.x::before, .solved .c.x::after { opacity: 0; transition: opacity 0.4s; transition-delay: var(--d); }
.solved .clue { color: var(--clue-done); }
@media (prefers-reduced-motion: reduce) {
  .solved .c, .solved .c.x::before, .solved .c.x::after { transition: none; }
}

.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }
.solved .tools { display: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.switch { display: flex; padding: 3px; border-radius: 14px; background: var(--accent-soft); }
.switch button {
  min-width: 88px;
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  font-weight: 700;
}
.switch button[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); }
.plain { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.plain:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--cross); outline-offset: 2px; }

.panel { margin-top: 20px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.cta {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}
.cta.quiet { background: var(--accent-soft); color: var(--ink); }
