/* Take 01: Laptops should stay laptops. */

:root {
  --tape: #f2b42a;
  --device: #c4c3c8;
  --device-deep: #aeadb3;
  --device-edge: #8e8d94;
  --touch: var(--rec);
  --trackpad: var(--pen);
}

@media (prefers-color-scheme: dark) {
  :root {
    --device: #4a4950;
    --device-deep: #3a393f;
    --device-edge: #6a6970;
  }
}

/* Fold: where touch makes sense. */

.fold__modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.fold__mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fold__mode:has(input:focus-visible) {
  outline: 3px solid var(--pen);
  outline-offset: 3px;
}

/* On phones, four equal keys in two rows instead of three and a stray. */
@media (max-width: 30rem) {
  .fold__modes {
    display: grid;
    /* Two per row, or one per row when text is large. */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  }
}

.fold__picture {
  margin-top: 1rem;
}

.fold__drawing {
  display: block;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  overflow: visible;
}

.fold__ground {
  stroke: var(--line);
  stroke-width: 2;
}

/* Same device family as the race and wobble drawings: grey shell, black bezel, lit screen. */
.fold__shell {
  fill: var(--device);
  stroke: var(--device-edge);
  stroke-width: 1;
}

.fold__keyboard { fill: var(--device-deep); }
.fold__foot { fill: #2a292e; }
.fold__bezel { fill: #0b0b0d; }
.fold__glass { fill: var(--tape); }

.fold__hinge {
  fill: var(--device-deep);
  stroke: var(--device-edge);
  stroke-width: 1;
  transition: opacity 400ms ease;
}

.fold[data-mode="detached"] .fold__hinge { opacity: 0; }

.fold__device,
.fold__base,
.fold__lid {
  transition:
    transform 800ms cubic-bezier(0.65, 0, 0.25, 1),
    opacity 400ms ease;
}

.fold[data-mode="laptop"] .fold__device { transform: translate(-10px, 50px) rotate(0deg); }
.fold[data-mode="laptop"] .fold__lid { transform: translate(0px, 0px) rotate(105deg); }

.fold[data-mode="tent"] .fold__device { transform: translate(-58px, -98px) rotate(-58deg); }
.fold[data-mode="tent"] .fold__lid { transform: translate(0px, 10px) rotate(299deg); }

.fold[data-mode="tablet"] .fold__device { transform: translate(-150px, 60px) rotate(180deg); }
.fold[data-mode="tablet"] .fold__lid { transform: translate(0px, 17px) rotate(360deg); }

.fold[data-mode="detached"] .fold__device { transform: translate(70px, 50px) rotate(0deg); }
.fold[data-mode="detached"] .fold__lid { transform: translate(0px, 10px) rotate(90deg); }
.fold[data-mode="detached"] .fold__base { transform: translate(-90px, 0px); opacity: 0.3; }

.fold__base { transform: translate(0px, 0px); }

.fold__status {
  display: grid;
  gap: 0.25rem;
  min-height: 4.5em;
}

.fold__verdict {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-stretch: 85%;
  font-weight: 750;
  color: var(--ink);
}

/* Wobble: the screen rocks every time you tap it, and the picture loses tracking. */

.wobble__laptop {
  width: min(100%, 34rem);
  margin: 0 auto;
  perspective: 900px;
}

.wobble__screen {
  /* A thin metal edge, so the black bezel doesn't vanish against a dark page. */
  box-shadow: 0 0 0 1.5px var(--device-edge);
  display: block;
  width: 100%;
  min-height: 12rem;
  aspect-ratio: 16 / 10.4;
  padding: 0;
  border: 0.6rem solid #0b0b0d;
  border-bottom-width: 1rem;
  border-radius: 1rem 1rem 0.375rem 0.375rem;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgb(0 0 0 / 0.55)),
    repeating-linear-gradient(to bottom, rgb(255 255 255 / 0.03) 0 1px, transparent 1px 3px),
    var(--screen);
  color: var(--screen-ink);
  font: inherit;
  cursor: pointer;
  transform-origin: 50% 100%;
  --tracking-color: #fff;
}

.wobble__picture {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  padding: 0.9rem 1.1rem;
}

/* Text on the laptop screen is capped by the screen width, so it fits at large text sizes. */
.wobble__osd {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  font-size: min(1rem, 4.5vw);
  text-shadow: 0 0 0.3em rgb(255 255 255 / 0.4);
}

.wobble__label {
  align-self: center;
  font-family: var(--font-display);
  font-size: min(clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem), 7vw);
  font-stretch: 85%;
  font-weight: 750;
}

.wobble__nice {
  display: block;
  font-family: var(--font-osd);
  font-size: 0.5em;
  font-weight: 400;
  color: var(--stamp);
}

.wobble__stamp {
  justify-self: end;
  font-size: min(1.125rem, 5vw);
  color: var(--stamp);
  text-shadow: 0 0 0.35em rgb(255 170 50 / 0.55);
}

.wobble__screen:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 4px;
}

.wobble__deck {
  height: 1.1rem;
  margin-inline: -5%;
  border-radius: 0 0 1.5rem 1.5rem;
  background: linear-gradient(to bottom, var(--device) 0 45%, var(--device-deep) 100%);
}

.wobble__caption {
  min-height: 3em;
  text-align: center;
}

/* Race: hand travel to open Spotlight. */

.race__layout {
  display: grid;
  grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
  align-items: center;
  gap: 2rem 3rem;
}

.race__drawing {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
}

/* The race laptop, from the side: the same device family as the fold drawing. */
.race__table { stroke: var(--line); stroke-width: 2; }
.race__shell { fill: var(--device); stroke: var(--device-edge); stroke-width: 1; }
.race__keys { fill: #2a292e; }
.race__pad { fill: var(--device-deep); }
.race__bezel { fill: #0b0b0d; }
.race__glass { fill: var(--tape); }
.race__hinge { fill: var(--device-deep); stroke: var(--device-edge); stroke-width: 1; }

.race__label {
  fill: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 12px;
}

.race__path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 6;
}

.race__path--touch { stroke: var(--touch); }
.race__path--trackpad { stroke: var(--trackpad); }

.race__hand {
  stroke: #fff;
  stroke-width: 2.5;
}

.race__hand--touch { fill: var(--touch); }
.race__hand--trackpad { fill: var(--trackpad); }

.race__readout {
  display: grid;
  justify-items: start;
  gap: 1.75rem;
}

.race__legend {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.race__entry {
  display: grid;
  padding-left: 0.75rem;
  border-left: 0.35rem solid var(--line);
}

.race__entry--touch { border-color: var(--touch); }
.race__entry--trackpad { border-color: var(--trackpad); }

.race__entry dt {
  font-size: 1rem;
  color: var(--ink-muted);
}

.race__entry dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.4rem + 1vw, 2.25rem);
  font-stretch: 85%;
  font-weight: 750;
  line-height: 1.1;
}

.race.is-playing .race__play .deck-key__light {
  background: var(--rec);
  box-shadow: 0 0 0.5rem rgb(255 70 50 / 0.8);
}

/* Race on phones: readout and Play key above a smaller drawing, so both stay on screen.
   These come after the base race rules so they take effect. */
@media (max-width: 48rem) {
  .race__layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .race__readout {
    order: -1;
    gap: 1rem;
  }

  .race__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
  }

  .race__entry dd {
    font-size: 1.375rem;
  }

  /* The side view is wide and short, so on phones it can use the full width. */
  .race__drawing {
    max-width: 100%;
  }
}

/* Piano: elbows out. */

.piano__drawing {
  display: block;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  /* The arms run off the bottom of the drawing; fade them out rather than cut them off. */
  mask-image: linear-gradient(#000 80%, transparent);
}

.piano__bezel { fill: #0b0b0d; stroke: var(--device-edge); stroke-width: 1.5; }
.piano__display { fill: var(--screen); }
.piano__white-keys rect { fill: #f2f1ee; stroke: var(--screen); stroke-width: 1.5; }
.piano__black-keys rect { fill: #0b0b0d; }
.piano__deck { fill: var(--device); }

/* Arms and hands are drawn as thick rounded strokes over a slightly wider
   outline, so joints and fingertips come out round. Fixed tones read in both themes. */
.piano__limb-edge,
.piano__limb,
.piano__finger-edge,
.piano__finger {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.piano__limb-edge { stroke: #2b2d33; stroke-width: 23; }
.piano__limb { stroke: #6b6e78; stroke-width: 20; }
.piano__finger-edge { stroke: #2b2d33; stroke-width: 11.5; }
.piano__finger { stroke: #9a9da6; stroke-width: 9; }

.piano__palm {
  fill: #9a9da6;
  stroke: #2b2d33;
  stroke-width: 1.5;
}

.piano__angles path {
  fill: none;
  stroke: var(--rec);
  stroke-width: 3;
  stroke-linejoin: miter;
}

.piano__label {
  fill: var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 750;
}

@media (prefers-reduced-motion: reduce) {
  .fold__device,
  .fold__base,
  .fold__lid {
    transition: none;
  }
}
