/* LEGO World workbench, laid out as a LEGO.com product page: yellow navigation
   bar, white page, the model as the product gallery and the set's facts and
   components in an information column on the right. See docs/design.md. */
:root {
  color-scheme: light;
  --yellow: #ffcf00;
  --ink: #000;
  --ink-2: #4d4d4d;
  --paper: #fff;
  --mist: #f4f4f4;
  --line: #e0e0e0;
  --line-strong: #bdbdbd;
  --blue: #006cb7;
  --blue-dark: #00508a;
  --blue-wash: #e8f2fa;
  --stage: #e2e6e8;
  --radius: 4px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font:
    15px/1.45 Figtree,
    'Avenir Next',
    'Segoe UI',
    sans-serif;
  font-variant-numeric: tabular-nums;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button,
select {
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 600;
}
button:hover,
select:hover {
  border-color: var(--ink);
}
button:disabled,
select:disabled,
input:disabled {
  cursor: default;
  opacity: 0.4;
}
button:disabled:hover {
  border-color: var(--line-strong);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
#viewport:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
a {
  color: var(--blue);
}
h1,
h2 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* Navigation bar */
header {
  display: flex;
  align-items: stretch;
  gap: 40px;
  height: 64px;
  flex-shrink: 0;
  padding: 0 24px;
  background: var(--yellow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
}
.emblem {
  width: 34px;
  height: 31px;
  fill: var(--ink);
}
header nav {
  display: flex;
  gap: 28px;
}
header nav button {
  position: relative;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 16px;
  font-weight: 700;
}
header nav button::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--ink);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.15s;
}
header nav button:hover::after {
  transform: scaleY(0.5);
}
header nav button[aria-pressed='true']::after {
  transform: none;
}
.header-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
}
.header-links button {
  padding: 0;
  border: 0;
  background: none;
}
.header-links a {
  color: var(--ink);
  text-decoration: none;
}
.header-links button:hover,
.header-links a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

main {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 340px;
  flex: 1;
  min-height: 0;
}
.rail-title {
  font-size: 18px;
}

/* Sets: product tiles */
.manifest {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.manifest .rail-title {
  padding: 20px 20px 12px;
}
.set-library {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 0 16px 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.set-choice {
  display: block;
  width: 100%;
  padding: 0 0 12px;
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  background: none;
  font-weight: 400;
}
.set-choice:hover {
  border-color: transparent;
}
.set-choice img,
.set-placeholder {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 272 / 216;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--stage);
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color 0.15s;
}
.set-choice:hover img {
  outline-color: var(--line-strong);
}
.set-choice[aria-pressed='true'] img,
.set-choice[aria-pressed='true'] .set-placeholder {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}
.set-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  font-weight: 700;
}
.set-copy {
  display: block;
  padding: 10px 2px 0;
}
.set-choice strong {
  display: block;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
}
.set-choice small {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
  margin-top: 2px;
}
.set-choice small + small {
  margin-top: 0;
}
.badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 1px 7px;
  border-radius: 2px;
  background: var(--mist);
  border: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 700;
}

/* Stage */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.toolbar > span {
  margin-right: auto;
  font-size: 14px;
  font-weight: 700;
}
.toolbar button,
.toolbar select {
  font-size: 13px;
  padding: 7px 12px;
}
.zoom {
  display: flex;
  gap: 4px;
}
.zoom button:not(#fit) {
  width: 34px;
  padding: 7px 0;
}
#viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--stage);
}
#viewport canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.stage-foot {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 16px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
  color: var(--ink-2);
  font-size: 13px;
}
#view-label {
  color: var(--ink);
  font-weight: 700;
}
/* Build: the step's parts, as the callout box of an instruction booklet */
.step-parts {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1;
  max-width: min(300px, calc(100% - 32px));
  padding: 10px 14px 12px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 1px 3px #0002;
  pointer-events: none;
  font-size: 13px;
}
.step-parts p {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 800;
}
.step-parts .more {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}
.step-parts ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.step-parts li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.step-parts li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.step-parts .swatch {
  margin-right: 0;
  flex-shrink: 0;
}
.step-parts b {
  min-width: 26px;
  font-weight: 800;
}
#turntable[aria-pressed='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--stage);
  text-align: center;
  z-index: 2;
  font-weight: 600;
}
.adjustments {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 20px;
  align-items: end;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.adjust-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
}
.adjust-head select {
  min-width: 0;
  max-width: 240px;
  padding: 5px 8px;
  font-size: 13px;
}
.adjust-head output {
  margin-left: auto;
  color: var(--ink-2);
  font-weight: 500;
}
.adjust-actions {
  display: flex;
  gap: 8px;
  grid-row: 1 / 3;
  grid-column: 2;
}
#explode-quick {
  min-width: 92px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
#explode-quick:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}
input[type='range'] {
  display: block;
  width: 100%;
  accent-color: var(--blue);
  cursor: pointer;
  margin: 8px 0 0;
}
.help {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 13px;
}

/* Build: the step number is set like an instruction booklet's */
#build-controls {
  padding: 14px 20px 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.build-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#step-label {
  min-width: 132px;
  margin-right: 8px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}
#play {
  min-width: 112px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
#play:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}
#build-controls p {
  font-size: 13px;
  color: var(--ink-2);
  margin: 6px 0 0;
}
#build-controls #assembly-status {
  color: var(--ink);
  font-weight: 600;
}
.speed-control,
.follow-control {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}
.speed-control {
  margin-left: auto;
}
.speed-control select {
  padding: 6px 8px;
}
.follow-control input {
  accent-color: var(--blue);
}

/* Phone-only line above the stage (see the max-width: 860px block). */
.scene-intro {
  display: none;
}

/* Information column */
.details {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
}
.product {
  flex-shrink: 0;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
}
h1 {
  font-size: 26px;
  line-height: 1.15;
}
.tagline {
  margin: 6px 0 0;
  color: var(--ink-2);
}
.facts {
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: start;
  gap: 0;
  margin: 16px 0 0;
}
.facts div {
  display: flex;
  flex-direction: column-reverse;
  padding: 0 16px;
  border-left: 1px solid var(--line);
}
.facts div:first-child {
  padding-left: 0;
  border-left: 0;
}
.facts dt {
  color: var(--ink-2);
  font-size: 13px;
}
.facts dd {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}
.display-size {
  margin: 10px 0 0;
  font-size: 14px;
}
.instructions-link {
  display: inline-block;
  margin-top: 16px;
  font-weight: 700;
  text-underline-offset: 3px;
}
.accuracy {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}
.inspection {
  display: none;
}
body.inspecting .accuracy {
  display: none;
}
body.inspecting .inspection {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 46%;
  margin: 14px 16px 0;
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 14px;
  background: var(--blue-wash);
  font-size: 14px;
  font-weight: 700;
}
#inspection-content {
  padding: 4px 14px 14px;
  overflow-y: auto;
  min-height: 0;
}
.brick-number {
  margin: 8px 0 2px;
  color: var(--ink-2);
  font-size: 13px;
}
.selected-name {
  font-size: 19px;
  line-height: 1.25;
}
.color-chip {
  height: 22px;
  border-radius: 2px;
  border: 1px solid #0002;
  margin: 12px 0 8px;
}
#inspection-content p:not(.brick-number) {
  margin: 0;
  font-size: 14px;
}
.part-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.part-actions button {
  font-size: 13px;
  padding: 5px 8px;
}
.components {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 18px 16px 12px;
}
.components .rail-title {
  padding: 0 6px;
}
.tabs {
  display: flex;
  gap: 22px;
  margin-top: 8px;
  padding: 0 6px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  padding: 8px 0;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  font-size: 14px;
  color: var(--ink-2);
}
.tabs button[aria-pressed='true'] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.search {
  display: block;
  margin: 12px 0 8px;
}
.search input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
}
.whole {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 14px;
}
.whole span {
  color: var(--ink-2);
  font-weight: 500;
}
.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  margin: 6px 0;
}
.list button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  background: none;
  padding: 7px 6px;
  font-size: 14px;
  font-weight: 500;
}
.list button:hover {
  background: var(--mist);
}
.list button[aria-pressed='true'] {
  background: var(--blue-wash);
  color: var(--blue-dark);
  font-weight: 700;
}
.list button > span:last-child {
  flex-shrink: 0;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.manifest-subsection h3 {
  margin: 14px 6px 4px;
  font-size: 13px;
  font-weight: 800;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 8px;
  border: 1px solid #0003;
  vertical-align: -1px;
}
.manifest-foot {
  flex-shrink: 0;
  padding: 8px 6px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
}

footer {
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
  padding: 8px 24px;
  background: var(--mist);
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
}
dialog {
  width: min(620px, calc(100% - 32px));
  max-height: 85dvh;
  overflow: auto;
  border: 0;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 28px 32px;
  line-height: 1.6;
  box-shadow: 0 12px 48px #0004;
}
dialog h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
dialog::backdrop {
  background: #0008;
}
#close-credits,
#close-inspection {
  float: right;
  padding: 0 8px;
  font-size: 24px;
  line-height: 28px;
  border: 0;
  background: none;
}
#close-inspection {
  float: none;
}
.pending-model {
  max-width: 460px;
  text-align: left;
}
.pending-model h2 {
  font-size: 28px;
  line-height: 1.2;
}
.pending-model p {
  color: var(--ink-2);
  font-weight: 400;
}
.pending-model a {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--blue);
  font-weight: 700;
  text-decoration: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.skip {
  position: absolute;
  top: -100px;
  z-index: 9;
  padding: 10px;
  background: var(--paper);
}
.skip:focus {
  top: 0;
}
[hidden] {
  display: none !important;
}
noscript {
  position: absolute;
  top: 40%;
  left: 35%;
  z-index: 4;
  background: var(--paper);
  padding: 20px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 1240px) {
  main {
    grid-template-columns: 208px minmax(0, 1fr) 300px;
  }
  header {
    gap: 28px;
  }
  .toolbar > span {
    display: none;
  }
  .zoom {
    margin-right: auto;
  }
}

/* Phones and narrow windows: one scrolling column. One line naming the scene,
   then the model and its controls, the sets as a strip, then the information
   column (title, facts, components). The brick inspector becomes a bottom sheet. */
@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100dvh;
  }
  header {
    position: sticky;
    top: 0;
    z-index: 6;
    height: 56px;
    gap: 20px;
    padding: 0 16px;
  }
  .brand span,
  .header-links a {
    display: none;
  }
  main {
    display: flex;
    flex-direction: column;
  }
  .details {
    display: contents;
  }
  .scene-intro {
    display: block;
    order: 1;
    margin: 0;
    padding: 12px 16px;
    color: var(--ink-2);
    font-size: 15px;
    line-height: 1.35;
  }
  .scene-intro strong {
    color: var(--ink);
    font-weight: 700;
  }
  .workspace {
    order: 2;
  }
  .manifest {
    order: 3;
    border: 0;
    border-top: 1px solid var(--line);
  }
  .product {
    order: 4;
    padding: 18px 16px 14px;
    border-top: 1px solid var(--line);
    border-bottom: 0;
  }
  .components {
    order: 5;
    padding: 18px 10px 12px;
    border-top: 1px solid var(--line);
  }
  .manifest .rail-title {
    padding: 18px 16px 10px;
  }
  h1 {
    font-size: 24px;
  }
  .set-library {
    grid-auto-flow: column;
    grid-auto-columns: 168px;
    overflow-x: auto;
    padding: 0 16px 16px;
  }
  #viewport {
    flex: none;
    height: min(62vh, 520px);
  }
  .toolbar {
    padding: 8px 12px;
  }
  #capture {
    display: none;
  }
  .stage-foot {
    left: 14px;
    right: 14px;
    bottom: 12px;
    font-size: 12px;
  }
  .adjustments,
  #build-controls {
    padding: 12px 16px;
  }
  .speed-control {
    margin-left: 0;
  }
  .list {
    flex: none;
    max-height: 50vh;
  }
  body.inspecting .inspection {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    max-height: 52dvh;
    margin: 0;
    border-width: 2px 0 0;
    border-radius: 0;
    box-shadow: 0 -8px 32px #0003;
  }
  footer {
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
  }
}
