/* The demo page around the try-on: phone first, and side by side on a laptop. */
:root {
  --wine: #4a1024;
  --wine-deep: #2c0915;
  --gold: #c9973a;
  --gold-soft: #f1dfb4;
  --cream: #fbf6ee;
  --ink: #2a1a12;
  --ink-soft: #6d5a4f;
  --line: #e7dccb;
  --danger: #a3261f;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--wine-deep);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
}

/* ------------------------------------------------------------------ top bar */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--wine);
  color: var(--cream);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-gem {
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #f7e2a4, var(--gold));
  transform: rotate(45deg);
  border-radius: 2px;
}

.source {
  display: flex;
  gap: 6px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid rgba(251, 246, 238, 0.45);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-size: 14px;
}

.chip[aria-pressed='true'] {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--wine-deep);
  font-weight: 600;
}

/* -------------------------------------------------------------------- stage */

.stage {
  position: relative;
  overflow: hidden;
  background: #14090d;
  min-height: 0;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage.photo canvas {
  object-fit: contain;
}

/* The camera's own picture is only read from; the canvas is what is shown. */
.stage video {
  position: absolute;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

.stage.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  animation: flash 0.28s ease-out forwards;
  pointer-events: none;
}

@keyframes flash {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 0;
  }
}

.hint {
  position: absolute;
  top: 12px;
  left: 50%;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 7px 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(20, 9, 13, 0.72);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.numbers {
  position: absolute;
  left: 8px;
  bottom: 8px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #9fffcf;
  font: 11px/1.35 ui-monospace, Consolas, monospace;
  pointer-events: none;
}

.shutter {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 64px;
  height: 64px;
  padding: 0;
  transform: translateX(-50%);
  border: 4px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.shutter::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.1s;
}

.shutter:active::after {
  transform: scale(0.86);
}

.round {
  position: absolute;
  right: 12px;
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 9, 13, 0.6);
  color: #fff;
}

.welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: radial-gradient(circle at 50% 30%, #6a1a35, var(--wine-deep) 75%);
  color: var(--cream);
  text-align: center;
}

.welcome h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
}

.welcome p {
  max-width: 34ch;
  margin: 0 0 6px;
}

.small {
  font-size: 13px;
  opacity: 0.85;
}

.primary,
.secondary,
.button {
  display: inline-block;
  min-width: 200px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.primary {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: var(--wine-deep);
}

.secondary {
  border: 1px solid currentColor;
  background: transparent;
}

.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

/* --------------------------------------------------------------------- tray */

.tray {
  background: var(--cream);
  padding-bottom: env(safe-area-inset-bottom);
  min-width: 0;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  flex: 1 1 auto;
  padding: 15px 6px 9px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  white-space: nowrap;
}

.tab[aria-selected='true'] {
  border-bottom-color: var(--gold);
  color: var(--wine);
  font-weight: 600;
}

/* A dot on a group that has a piece on. */
.tab.wearing::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 50%;
  width: 6px;
  height: 6px;
  margin-right: -3px;
  border-radius: 50%;
  background: var(--gold);
}

.strip {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.strip::-webkit-scrollbar {
  display: none;
}

.piece {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 78px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink-soft);
  scroll-snap-align: start;
}

.piece-picture {
  position: relative;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.piece-picture img {
  max-width: 50px;
  max-height: 50px;
}

.piece[aria-selected='true'] {
  color: var(--wine);
  font-weight: 600;
}

.piece[aria-selected='true'] .piece-picture {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-soft);
}

.piece.own .piece-picture::after {
  content: 'Mine';
  position: absolute;
  top: -7px;
  right: -7px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--wine);
  color: var(--cream);
  font-size: 10px;
  font-weight: 600;
}

.piece.none .piece-picture,
.piece.add .piece-picture {
  color: var(--ink-soft);
  font-size: 26px;
}

.piece.add .piece-picture {
  border-style: dashed;
  border-color: var(--gold);
  color: var(--gold);
}

.piece-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- fit panel */

.fit {
  display: grid;
  gap: 4px;
  padding: 8px 14px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.fit-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fit-head strong {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slider {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.slider input {
  width: 100%;
  height: 28px;
  accent-color: var(--wine);
}

.fit-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  font-size: 13.5px;
}

.fit-options .link {
  margin-left: auto;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--wine);
}

.link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--wine);
  font-weight: 600;
  text-decoration: underline;
}

.link.danger {
  color: var(--danger);
}

/* ------------------------------------------------------------------ dialogs */

.sheet {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 18px;
  border: 0;
  border-radius: 18px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.sheet::backdrop {
  background: rgba(20, 9, 13, 0.6);
}

.sheet h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--wine);
}

.sheet .small {
  margin: 0 0 12px;
}

.preview {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 12px;
  border-radius: 12px;
  /* A chequered ground shows what is see-through. */
  background:
    conic-gradient(#e9e2d6 25%, #fff 0 50%, #e9e2d6 0 75%, #fff 0) 0 0 / 18px 18px;
}

.preview canvas {
  max-width: 100%;
  max-height: 200px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.preview .secondary {
  background: rgba(255, 255, 255, 0.85);
  color: var(--wine);
}

.note {
  min-height: 1.4em;
  margin: 8px 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.note.warn {
  color: var(--danger);
}

.sheet .check {
  margin: 0 0 12px;
  font-size: 13.5px;
}

.kinds {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.kinds legend {
  padding: 0;
  margin-bottom: 6px;
  font-weight: 600;
}

.kinds div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kind input {
  position: absolute;
  opacity: 0;
}

.kind span {
  display: block;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
}

.kind input:checked + span {
  border-color: var(--wine);
  background: var(--wine);
  color: var(--cream);
}

.kind input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  font-weight: 600;
}

.field input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-weight: 400;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.actions .primary,
.actions .secondary,
.actions .button {
  min-width: 0;
  padding: 10px 20px;
  font-size: 15px;
  color: var(--wine);
}

.actions .primary {
  color: var(--wine-deep);
}

#shotImage {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  margin: 0 auto 14px;
  border-radius: 12px;
}

/* ------------------------------------------------------------------- laptop */

@media (min-width: 900px) and (min-height: 520px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 400px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .bar {
    grid-column: 1 / -1;
    padding: 10px 20px;
  }

  .stage canvas {
    object-fit: contain;
  }

  .tray {
    overflow-y: auto;
    border-left: 1px solid var(--line);
  }

  .strip {
    flex-wrap: wrap;
    overflow: visible;
    padding: 16px;
    gap: 14px 10px;
  }

  .piece {
    width: 84px;
  }
}
