/* Order flow layout (PL-05). Phone: one column. Desktop: the step on the left (max 560 px),
   a sticky summary on the right. Tokens only. */

.flow {
  padding-bottom: var(--space-7);
}

.flow__grid {
  display: grid;
  gap: var(--space-6);
  padding-top: var(--space-5);
}

.flow__main {
  min-width: 0;
}

@media (min-width: 1080px) {
  .flow__grid {
    grid-template-columns: minmax(0, 560px) minmax(280px, 380px);
    justify-content: space-between;
    align-items: start;
  }

  .flow__aside {
    position: sticky;
    top: var(--space-5);
  }
}

.flow__title {
  font-size: var(--type-h1-size);
  line-height: var(--type-h1-lh);
}

.flow__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-top: var(--space-2);
}

.flow__figure {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stage--flow {
  height: 300px;
}

.stage--flow .statue {
  width: 230px;
}

.privacy-line {
  display: flex;
  gap: 10px;
  font-size: var(--type-small-size);
  line-height: var(--type-small-lh);
  color: var(--color-ink-muted);
}

.privacy-line .icon {
  flex: none;
  color: var(--color-accent);
}

[data-look='c'] .privacy-line .icon {
  color: var(--color-ink);
}

.check__more {
  padding-left: 36px;
}

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--type-small-size);
}

.upload-progress progress {
  width: 100%;
  height: 8px;
  accent-color: var(--color-accent);
}

.filepick__js-thumb {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: var(--radius-tile);
}

.field-pair {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.input--caps {
  text-transform: uppercase;
}

.finish-notes {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--type-small-size);
  line-height: var(--type-small-lh);
}

.finish-notes__row dt {
  font-weight: 600;
}

.finish-notes__row dd {
  color: var(--color-ink-muted);
}

/* With the script on, only the chosen finish's note shows. */
.js .finish-notes__row {
  display: none;
}

.js .finish-notes__row.is-current {
  display: block;
}

.review {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.review__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.review__head a {
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.notice-plain {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-tile);
  background: var(--color-surface-alt);
}

.cf-turnstile {
  min-height: 0;
}

/* The photo editor: move, zoom and crop before the photo is sent. */
.cropper__canvas {
  display: block;
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-tile);
  background: var(--color-surface-alt);
  /* One finger up or down scrolls the page; sideways and two fingers move the photo (photo.js). */
  touch-action: pan-y;
  cursor: grab;
}

.cropper__canvas:active {
  cursor: grabbing;
}

.cropper__canvas:focus-visible {
  outline: 3px solid var(--color-focus, currentColor);
  outline-offset: 2px;
}

.cropper__zoom {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 520px;
  min-height: 44px;
  font-weight: 600;
}

.cropper__zoom input {
  accent-color: var(--color-accent);
  flex: 1;
  min-height: 44px;
}

/* While the editor shows the photo, the picker's own thumbnail steps aside. */
.filepick.is-editing .filepick__thumb,
.filepick.is-editing .filepick__js-thumb,
.filepick.is-editing .filepick__empty {
  display: none;
}

/* The chosen ornament shape with the photo inside (views/flow.tsx OrnamentDrawing). */
.ornament {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius-tile);
  background: var(--color-surface-alt);
  text-align: center;
}

.ornament[hidden] {
  display: none;
}

/* The drawing already shows the stored photo: the picker keeps its bar, not a second picture. */
.ornament:not([hidden]) + .filepick .filepick__thumb img {
  display: none;
}

.ornament__art {
  display: block;
  width: min(100%, 260px);
  height: auto;
}

.ornament__rim {
  fill: var(--color-surface);
  stroke: var(--color-ink);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.ornament__edge {
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 0.8;
  stroke-linejoin: round;
}

.ornament__cap {
  fill: var(--color-surface);
  stroke: var(--color-ink);
  stroke-width: 1.5;
}

.ornament__loop {
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 2.5;
}

/* Automatic 3D first look (D-31): the steps after the photo, the review step and the order page. */
.preview3d__stage {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  border-radius: var(--radius-tile);
  background: var(--color-surface-alt);
  overflow: hidden;
}

.preview3d__loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: var(--space-4);
  text-align: center;
  font-weight: 600;
}

.preview3d__still {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview3d__stage.is-3d .preview3d__still {
  display: none;
}

.preview3d__canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* One finger up or down scrolls the page; sideways turns the model, two fingers move it (the viewer). */
  touch-action: pan-y;
  cursor: grab;
}

.preview3d__canvas:active {
  cursor: grabbing;
}

.preview3d__canvas:focus-visible {
  outline: 3px solid var(--color-focus, currentColor);
  outline-offset: -3px;
}

.preview3d__progress {
  width: 100%;
  max-width: 420px;
}

/* Making a model: what is being done now, how far along, and the steps around it. */
.making {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-tile);
  background: var(--color-surface-alt);
}

.making__now {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0;
  font-size: 1.25rem;
}

.making__percent {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.making .preview3d__progress {
  max-width: none;
  height: 14px;
  accent-color: var(--color-accent);
}

.making__steps {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.making__steps li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-ink-muted);
}

.making__steps li::before {
  content: '';
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
}

.making__steps .is-done::before {
  content: '\2713' / 'Done: ';
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-surface);
}

.making__steps .is-now {
  color: var(--color-ink);
  font-weight: 700;
}

.making__steps .is-now::before {
  border-right-color: transparent;
  animation: making-turn 1.1s linear infinite;
}

@keyframes making-turn {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .making__steps .is-now::before {
    animation: none;
  }
}

@media (max-width: 719px) {
  .studio .making__steps {
    gap: var(--space-0);
  }
}

@media (min-width: 720px) {
  .studio .making__steps {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* The pretend workshop while a model is made (views/play.tsx, public/js/play.js), after the owner's
   picture: a room in 3D with the words and wooden buttons on its wall. Where the room is as wide as
   in the picture, everything is measured in parts of its width (1702 dots). */
@font-face {
  font-family: 'Workshop';
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-opsz-normal.woff2') format('woff2');
}

.play {
  position: relative;
  display: grid;
  padding: var(--space-3) 0 0;
  border-radius: var(--radius-tile);
  overflow: hidden;
  background: var(--play-wall);
  color: var(--play-ink);
  container-type: inline-size;
}

/* The room's own wall, until it is drawn and behind the puzzle on a phone. */
.play:not(.is-over) {
  background: var(--play-room);
}

.play.is-over {
  padding-bottom: var(--space-3);
}

.play[hidden] {
  display: none;
}

.play__head,
.play__bar {
  position: relative;
  z-index: 1;
  padding-inline: var(--space-3);
  font-family: 'Workshop', var(--font-body);
  font-variation-settings: 'opsz' 24;
}

.play__head {
  display: grid;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.4;
  pointer-events: none;
}

.play__head .small {
  color: inherit;
  font-size: 1em;
}

/* Room for two rows on a phone, so nothing under a longer line jumps. */
.play__line {
  min-height: 2.5em;
  font-variation-settings: 'opsz' 22;
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.25;
}

/* White wooden buttons that stand out of the wall. */
.play__bar {
  display: flex;
  gap: 12px;
  padding-top: var(--space-2);
}

.play__button {
  min-height: 46px;
  padding: 0 18px 3px;
  border: 0;
  border-radius: 999px;
  background: var(--play-button) url('/img/workshop/button.webp') center / calc(100% + 3px) calc(100% + 3px);
  box-shadow:
    10px 7px 10px var(--play-shadow),
    12px 14px 26px var(--play-far-shadow);
  color: var(--play-letters);
  white-space: nowrap;
  font: 600 1rem / 1.2 'Workshop', var(--font-body);
  cursor: pointer;
}

.play__button[hidden] {
  display: none;
}

.play__button:active {
  transform: translate(1px, 2px);
}

@container (max-width: 270px) {
  .play__bar {
    flex-wrap: wrap;
  }

  .play__button {
    padding-inline: 13px;
    font-size: 0.9375rem;
  }
}

/* Behind the words and buttons, up to the edges. */
.play__scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

.play__scene:focus-visible {
  outline-offset: -4px;
}

.play__scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.play__game {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.play__game[hidden] {
  display: none;
}

.play__game p {
  margin: 0;
  text-align: center;
}

@media (max-width: 719px) {
  .play__room {
    order: 1;
    min-height: 85cqw;
  }

  /* On a phone the puzzle takes the workshop's place. */
  .play.is-game .play__scene {
    display: none;
  }

  .play__game {
    padding: var(--space-3) var(--space-3) var(--space-4);
  }
}

@media (min-width: 720px) {
  .play:not(.is-over) {
    display: block;
    padding: 0;
    aspect-ratio: 1702 / 942;
  }

  .play:not(.is-over) .play__room {
    position: absolute;
    inset: 0;
  }

  .play__head {
    position: absolute;
    top: 2.56cqw;
    left: 2.47cqw;
    width: 62cqw;
    padding: 0;
    font-size: max(13px, 1.7cqw);
    line-height: 1.32;
  }

  .play__line {
    min-height: 0;
    margin-top: 0.47cqw;
    font-size: max(16px, 2.11cqw);
    line-height: 1.5;
  }

  .play__bar {
    position: absolute;
    top: 2.5cqw;
    right: 2.3cqw;
    gap: 1.35cqw;
    padding: 0;
  }

  .play__button {
    height: 5.5cqw;
    min-height: 44px;
    padding: 0 1.92cqw 0.25cqw;
    font-size: max(13px, 1.73cqw);
  }

  /* The puzzle lies in front of the workshop, under the buttons. */
  .play:not(.is-over) .play__game .puzzle {
    width: 26cqw;
  }

  .play:not(.is-over) .play__game {
    position: absolute;
    top: 10.2cqw;
    right: 2.2cqw;
    width: 31cqw;
    padding: 1.2cqw;
    border-radius: var(--radius-tile);
    background: var(--play-paper);
    box-shadow:
      2px 3px 8px var(--play-shadow),
      12px 16px 34px var(--play-far-shadow);
  }
}

.puzzle {
    grid-row: span 2;
    width: calc(var(--play-tall) - var(--space-2));
  }

  .play__game p {
    text-align: left;
  }
}

@media (min-width: 1080px) {
  .play {
    --play-tall: clamp(252px, calc(62vh - 304px), 330px);
  }
}

.puzzle {
  display: grid;
  width: min(100%, 320px);
  aspect-ratio: 1;
  gap: 3px;
}

.puzzle[data-side='3'] {
  grid-template-columns: repeat(3, 1fr);
}

.puzzle[data-side='4'] {
  grid-template-columns: repeat(4, 1fr);
}

.puzzle[data-side='5'] {
  grid-template-columns: repeat(5, 1fr);
}

.puzzle__piece {
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

.puzzle__piece canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.puzzle__piece[aria-pressed='true'] {
  box-shadow:
    0 0 0 3px var(--color-surface),
    0 0 0 6px var(--color-ink);
  position: relative;
  z-index: 1;
}

.puzzle__piece.is-home {
  border-radius: 0;
  cursor: default;
}

.puzzle.is-done {
  gap: 0;
}

.play__ready {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--play-wall);
}

.play__ready[hidden] {
  display: none;
}

/* The measures over the 3D view (viewer/measure.js): light around dark, to be read on any background. */
.measure {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.measure__under,
.measure__line {
  fill: none;
  stroke: var(--color-surface);
  stroke-width: 5;
  stroke-linecap: round;
}

.measure__line {
  stroke: var(--color-ink);
  stroke-width: 2;
}

.measure__text {
  fill: var(--color-ink);
  stroke: var(--color-surface);
  stroke-width: 6;
  stroke-linejoin: round;
  paint-order: stroke;
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
}

.measure__name .measure__text {
  stroke-width: 4;
  font-size: 12px;
  font-weight: 600;
}

/* The model's window with its controls: below it, or beside it where there is room. */
[data-p3d='ready'] {
  container-type: inline-size;
}

.preview3d__look {
  display: grid;
  gap: var(--space-4) var(--space-6);
}

@container (min-width: 700px) {
  .preview3d__look {
    grid-template-columns: min(56cqw, var(--model, min(68vh, 520px))) minmax(0, 1fr);
  }
}

.preview3d__views {
  display: grid;
  gap: var(--space-4);
}

.preview3d__views[hidden] {
  display: none;
}

.preview3d__views .cluster {
  gap: var(--space-2);
}

/* Four arrows to turn and four to move, each around their word. */
.camera {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
}

.camera__pad {
  display: grid;
  grid-template: repeat(3, 44px) / repeat(3, 44px);
  gap: 2px;
  place-items: stretch;
}

.camera__pad span {
  grid-area: 2 / 2;
  place-self: center;
  font-size: 13px;
  font-weight: 700;
}

.camera .btn {
  min-width: 0;
  min-height: 0;
  padding: 0;
}

.camera__up {
  grid-area: 1 / 2;
}

.camera__left {
  grid-area: 2 / 1;
}

.camera__right {
  grid-area: 2 / 3;
}

.camera__down {
  grid-area: 3 / 2;
}

.btn--compact {
  padding: 0 var(--space-4);
  font-size: 15px;
}

.btn--secondary[aria-pressed='true'] {
  background: var(--color-surface-alt);
  box-shadow: inset 0 0 0 2px currentColor;
}

/* The size slider under the 3D model, with the piece beside everyday things at the same scale. */
.sizer {
  display: grid;
  gap: var(--space-2);
  max-width: 560px;
  padding: var(--space-3) 0;
}

.sizer__label {
  font-weight: 600;
}

.sizer input[type='range'] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--color-accent);
  outline-offset: -3px; /* the studio window cuts off what sticks out of it */
}

/* Two lines of room, so nothing below moves while the slider does. */
.sizer__now {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3em;
}

.sizer__things {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.sizer__piece {
  fill: var(--color-accent);
}

.sizer__thing {
  fill: var(--color-surface-alt);
  stroke: var(--color-ink-muted);
  stroke-width: 1.5;
}

.sizer__thing.is-near {
  stroke: var(--color-ink);
  stroke-width: 3.5;
}

.sizer__line {
  fill: none;
}

.sizer__floor {
  stroke: var(--color-line-strong);
  stroke-width: 2;
}

.sizer__names {
  fill: var(--color-ink);
  font-size: 15px;
  text-anchor: middle;
}

/* Without a model the slider has the whole width: the drawing goes beside it. */
@media (min-width: 1080px) {
  .studio__view > .sizer {
    grid-template-columns: 1fr 300px;
    column-gap: var(--space-6);
    align-content: start;
    max-width: none;
    padding: 0;
  }

  .studio__view > .sizer > * {
    grid-column: 1;
  }

  .studio__view > .sizer .sizer__things {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
}

/* A different delivery address: shown once its box is ticked (views/delivery.tsx). */
@supports selector(:has(*)) {
  .delivery:not(:has(#elsewhere:checked)) .delivery__other {
    display: none;
  }
}

/* The colors a piece can be made in now. */
.colors-now__title {
  font-weight: 600;
}

.colors-now__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.colors-now__list li {
  display: flex;
  align-items: center;
  gap: 6px;
}
