/* Six by Six in the app and on the launch page: the tester page's style.css (web/static/), copied
   because that page can't change during the tester week, in the art direction's paper and ink
   (docs/art/style.md, task 048). Fold the two back together after 16 Nov. Sizes are for a 390 px
   wide phone and up. */

:root {
  --paper: #faf7f0;
  --panel: #eee9dc;
  --linen: #e2dbcb;
  --line: #d8d2c4;
  --ink: #222;
  --muted: #5c574f;
  --thread: #2c3e73;
  --wrong: #b4432f;
  --good: #1e7d4f;
  --rim: #00000022;
  --cross: 48px;
  --edge: 18px;
  /* The target picture's cells and the key's swatches (064: smaller than 048's 26 and 30 px, so the
     picture, the loom and the bar fit one phone screen). */
  --cell: 20px;
  --swatch: 26px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 560px;
  padding: 12px 16px 40px;
  line-height: 1.4;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
}

h1 { font-size: 1.4rem; font-weight: 600; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 8px 0; }

button { font: inherit; }
:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }

/* Buttons: secondary is an Ink outline, primary an Ink fill (one per screen). */
button.primary, button.secondary {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

button.primary { background: var(--ink); color: var(--paper); }
button:disabled { opacity: 0.5; cursor: default; }

#message { font-size: 1.1rem; margin-top: 32px; }

.rules { padding-left: 1.2em; color: var(--muted); font-size: 0.95rem; }
.rules li { margin-bottom: 4px; }

/* The target picture: small flat squares, not buttons, in a Panel frame; beside it the key, then
   Show letters and Rules (064). */
.target-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

#target {
  flex: none;
  display: grid;
  grid-template-columns: repeat(6, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}

#target .cell {
  background: var(--c);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

#target .cell.pin, .swatch.pin { background: var(--panel); }

.peg {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #b9b9b9, #444);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* The key: swatches big enough to show each colour's texture (teal's dots included). */
#legend { display: grid; grid-template-columns: repeat(2, max-content); gap: 4px 16px; font-size: 0.9rem; }
.key { display: flex; align-items: center; gap: 8px; }
.swatch { width: var(--swatch); height: var(--swatch); background: var(--c); border: 1px solid var(--rim); display: grid; place-items: center; }
.swatch .peg { width: 10px; height: 10px; }

.toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--thread); }

/* Letters show only in the letter grid. */
.letter { display: none; }
body.letters .letter { display: inline; }
body.letters #target .cell:not(.pin) { background: #fff; outline: 1px solid var(--line); }

/* The loom: strips on a linen table, edge colours, then 36 crossings that are buttons. No frame. */
#loom {
  display: grid;
  grid-template-columns: var(--edge) repeat(6, var(--cross));
  grid-template-rows: var(--edge) repeat(6, var(--cross));
  margin: 8px 0 0;
  width: max-content;
  padding: 6px;
  background: var(--linen);
  border-radius: 4px;
}

.edge { position: relative; display: grid; place-items: center; }
.edge .band { position: absolute; background: var(--c); }
.edge.row .band { left: 0; right: 0; top: 22%; bottom: 22%; }
.edge.col .band { top: 0; bottom: 0; left: 22%; right: 22%; }
.edge .letter { position: relative; color: var(--on); font-size: 0.75rem; font-weight: 700; }

/* A light strip (cream, undyed) has a hairline along both its sides so it never melts into the linen. */
.band { --sides: 0 0 transparent; }
.band.light.h, .edge.row .band.light { --sides: inset 0 1px var(--rim), inset 0 -1px var(--rim); }
.band.light.v, .edge.col .band.light { --sides: inset 1px 0 var(--rim), inset -1px 0 var(--rim); }
.edge .band, .crossing .band { box-shadow: var(--sides); }
#target .cell.light:not(.pin) { box-shadow: inset 0 0 0 1px var(--rim); }

.crossing {
  position: relative;
  width: var(--cross);
  height: var(--cross);
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.crossing .band { position: absolute; background: var(--c); }
.crossing .h { left: 0; right: 0; top: 22%; bottom: 22%; }
.crossing .v { top: 0; bottom: 0; left: 22%; right: 22%; }

/* Unset: both strips flat and faded, neither on top; a dashed square says "choose". */
.crossing[data-top=""] .band { opacity: 0.35; }
.crossing[data-top=""]::after {
  content: "";
  position: absolute;
  inset: 22%;
  border: 2px dashed rgba(0, 0, 0, 0.35);
  border-radius: 3px;
}

/* Set: the strip on top runs across with a shadow; the one underneath is darker and passes under. */
.crossing[data-top="H"] .h,
.crossing[data-top="V"] .v {
  z-index: 2;
  box-shadow: var(--sides), 0 2px 3px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.4s ease-out;
}
.crossing[data-top="H"] .v,
.crossing[data-top="V"] .h {
  z-index: 1;
  filter: brightness(0.62);
}

.crossing .mark {
  display: none;
  position: absolute;
  z-index: 3;
  right: 1px;
  top: 0;
  color: var(--wrong);
  font-weight: 900;
  font-size: 1rem;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}
.crossing[data-wrong="true"] { outline: 3px solid var(--wrong); outline-offset: -3px; }
.crossing[data-wrong="true"] .mark { display: block; }

.crossing:disabled { cursor: default; opacity: 1; }

#status { min-height: 1.4em; margin: 6px 0 0; font-weight: 600; }

/* Solved: the finished weave lifts off the linen (062: clearer than 048's 4 px shadow), like a
   finished mat. Every strip, its ends at the edge included, rises 3 px off the bed, and the strips
   on top cast a deeper, wider shadow onto it. No glow. With reduced motion the raised end state
   shows at once. */
#play.solved .band {
  transform: translateY(-3px);
  transition: transform 0.7s ease-out, box-shadow 0.7s ease-out;
}
#play.solved .crossing[data-top="H"] .h,
#play.solved .crossing[data-top="V"] .v {
  box-shadow: var(--sides), 0 9px 14px rgba(0, 0, 0, 0.5);
}
@media (prefers-reduced-motion: reduce) {
  #play.solved .band { transition: none; }
}
#play.solved #status { color: var(--good); font-size: 1.3rem; }

/* Under 360 px (iPhone SE 1st gen, small Androids) the 334 px page would make the browser zoom out
   or scroll sideways. Crossings keep their 48 px; the edges, the loom's padding and the page's side
   padding give way: 14 + 6 × 48 + 2 × 3 = 308 px of loom, 6 px of page on each side at 320. */
@media (max-width: 359.98px) {
  :root { --edge: 14px; }
  body { padding-left: 6px; padding-right: 6px; }
  #loom { padding: 3px; }
}
