/* View: knit1pearl2 — the knitting game, in its television set.
 *
 * The set is CSS: wood veneer, moulded bezel and control strip are all
 * gradients, so the whole page is two files and no images. The screen
 * itself is a 256x224 canvas blown up with image-rendering: pixelated —
 * never resample it, or every stitch turns to soup. */

.knit-page {
  --wood-1: #b98a4e;
  --wood-2: #8a6033;
  --wood-3: #6b4826;
  --case-1: #d8d5cc;
  --case-2: #a7a49b;
  --case-3: #77746c;
  --screen: #e569a3;

  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, .16) 0 2px, rgba(255, 255, 255, .05) 2px 5px,
      rgba(0, 0, 0, .10) 5px 9px, rgba(255, 255, 255, .03) 9px 14px),
    linear-gradient(180deg, var(--wood-1), var(--wood-2) 55%, var(--wood-3));
  margin-inline: -20px;                    /* main.css insets body by 20px */
  padding: clamp(12px, 4vw, 48px) 20px 40px;
  text-align: left;
  min-height: 100vh;
}

.knit-shell {
  max-width: 900px;
  margin: 0 auto;
}

/* ---------- the television ---------- */

.knit-tv {
  background: linear-gradient(160deg, var(--case-1), var(--case-2) 45%, var(--case-3));
  border-radius: 18px;
  padding: clamp(10px, 2.4vw, 22px);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, .5) inset,
    0 -3px 0 rgba(0, 0, 0, .28) inset,
    0 26px 46px rgba(0, 0, 0, .5);
}

.knit-bezel {
  background: linear-gradient(180deg, #4a4740, #2b2925);
  border-radius: 14px;
  padding: clamp(8px, 2vw, 18px);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35) inset;
}

.knit-screen {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--screen);
  aspect-ratio: 256 / 224;
  box-shadow: 0 0 0 3px #14120f, 0 0 34px rgba(229, 105, 163, .3);
}

#knitCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Scanlines and the bulge of the glass. Pointer-events off so taps on a
   dropped stitch still reach the canvas underneath. */
.knit-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255, 255, 255, .16), transparent 42%),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px);
}

@media (prefers-reduced-motion: reduce) {
  .knit-screen::after { background: radial-gradient(120% 100% at 50% 0%, rgba(255, 255, 255, .12), transparent 42%); }
}

/* ---------- the control strip under the screen ---------- */

.knit-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: clamp(10px, 2vw, 16px);
  padding: 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, #3a3833, #232120);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset;
}

.knit-btn {
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: clamp(11px, 1.6vw, 14px);
  font-weight: 700;
  letter-spacing: .06em;
  color: #101014;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 84px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background: linear-gradient(180deg, #f2f2ee, #c3c1b8);
  box-shadow: 0 3px 0 #6f6d66, 0 5px 8px rgba(0, 0, 0, .4);
  transition: transform .04s linear, box-shadow .04s linear;
}

.knit-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #6f6d66, 0 2px 4px rgba(0, 0, 0, .4);
}

.knit-btn small { display: block; font-weight: 400; opacity: .6; font-size: .78em; }

.knit-btn--knit  { background: linear-gradient(180deg, #cfe0fb, #93b3ea); }
.knit-btn--purl  { background: linear-gradient(180deg, #fbcfe6, #ea93c1); }
.knit-btn--tog   { background: linear-gradient(180deg, #cff5df, #86d9a9); }

/* PICK UP is dead until a stitch actually drops, then it will not shut up. */
.knit-btn--pick  { background: linear-gradient(180deg, #d8d5cc, #a7a49b); opacity: .5; }
.knit-btn--pick.is-live {
  opacity: 1;
  background: linear-gradient(180deg, #ffd9a8, #f09070);
  animation: knit-pulse .32s steps(2, end) infinite;
}

@keyframes knit-pulse {
  from { box-shadow: 0 3px 0 #6f6d66, 0 0 0 0 rgba(240, 144, 112, .9); }
  to   { box-shadow: 0 3px 0 #6f6d66, 0 0 0 9px rgba(240, 144, 112, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .knit-btn--pick.is-live { animation: none; }
}

.knit-btn--util {
  min-width: 0;
  padding: 9px 12px;
  font-size: 11px;
  background: linear-gradient(180deg, #6e6b64, #47443f);
  color: #efeee9;
  box-shadow: 0 3px 0 #24221f, 0 5px 8px rgba(0, 0, 0, .4);
}

.knit-spacer { flex: 1 1 12px; min-width: 0; }

/* ---------- copy below the set ---------- */

.knit-notes {
  margin: clamp(20px, 4vw, 36px) auto 0;
  max-width: 720px;
  color: #fdf6ea;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.65;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}

.knit-notes h2 {
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #ffe9a8;
  margin: 26px 0 8px;
}

.knit-notes h2:first-child { margin-top: 0; }
.knit-notes p { margin: 0 0 12px; }
.knit-notes ul { margin: 0 0 12px; padding-left: 20px; }
.knit-notes li { margin-bottom: 5px; }
.knit-notes b { color: #ffe9a8; }
.knit-notes code {
  background: rgba(0, 0, 0, .35);
  padding: 1px 5px;
  border-radius: 3px;
  color: #ffd9a8;
}

.knit-notes a { color: #ffd9a8; }
.knit-notes a:hover { color: #fff; }

.knit-dl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
  padding: 0;
  list-style: none;
}

.knit-dl a {
  display: inline-block;
  padding: 6px 11px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .38);
  border: 1px solid rgba(255, 217, 168, .35);
  text-decoration: none;
  font-size: 12.5px;
}

.knit-dl a:hover { background: rgba(0, 0, 0, .6); border-color: #ffd9a8; }

@media (max-width: 560px) {
  .knit-btn { min-width: 0; flex: 1 1 22%; padding: 13px 6px; }
  .knit-btn--util { flex: 0 0 auto; padding: 9px 14px; }
  .knit-spacer { flex-basis: 100%; height: 0; }
}
