/* The workbench: source file on the left, settings and the run action on the right. */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 376px);
  gap: 20px;
  margin-top: 24px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px;
  animation: rise var(--settle) var(--ease) backwards;
}

.panel--settings {
  animation-delay: 60ms;
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 12px;
  margin-bottom: 16px;
}

.panel__head h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel__hint,
.panel__note {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.panel__note {
  margin-top: 14px;
}

/* Drop target */

.dropzone,
.preview {
  flex: 1;
  min-height: clamp(304px, 34vh, 460px);
  border-radius: var(--radius-lg);
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(6 38 59 / 0.028);
  box-shadow: inset 0 0 0 1px rgb(6 38 59 / 0.06), inset 0 2px 8px rgb(6 38 59 / 0.05);
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--medium) var(--ease),
    box-shadow var(--medium) var(--ease);
}

.dropzone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone input:disabled {
  cursor: not-allowed;
}

.dropzone:hover,
.is-dragging .dropzone {
  background: rgb(255 255 255 / 0.66);
  box-shadow: inset 0 0 0 2px var(--navy);
}

.dropzone:focus-within {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.dropzone__title {
  margin-top: 22px;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dropzone__hint {
  margin-top: 2px;
  color: var(--ink-muted);
}

.dropzone__browse {
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--tool-tint);
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
}

/* A fan of cards, the brand's stand-in for "your photos". It opens as a file nears. */

.fan {
  position: relative;
  display: block;
  width: 148px;
  height: 118px;
}

.fan__card {
  position: absolute;
  top: 6px;
  left: 37px;
  display: grid;
  place-items: center;
  width: 74px;
  height: 100px;
  border-radius: 14px;
  box-shadow: 0 10px 22px -12px rgb(6 38 59 / 0.4), inset 0 0 0 1px rgb(255 255 255 / 0.7);
  transform-origin: 50% 80%;
  transition: transform var(--settle) var(--ease-pop);
}

.fan__card--left {
  background: linear-gradient(160deg, var(--cyan), #d9fbff);
  transform: translateX(-30px) rotate(-11deg);
}

.fan__card--right {
  background: linear-gradient(200deg, var(--lime), #f6ffb4);
  transform: translateX(30px) rotate(10deg);
}

.fan__card--front {
  background: rgb(255 255 255 / 0.58);
  color: var(--navy);
  transform: translateY(-2px);
  -webkit-backdrop-filter: blur(12px) saturate(170%);
  backdrop-filter: blur(12px) saturate(170%);
}

.fan__card--front .icon {
  width: 30px;
  height: 30px;
}

.dropzone:hover .fan__card--left,
.is-dragging .fan__card--left {
  transform: translateX(-38px) rotate(-14deg);
}

.dropzone:hover .fan__card--right,
.is-dragging .fan__card--right {
  transform: translateX(38px) rotate(13deg);
}

.dropzone:hover .fan__card--front,
.is-dragging .fan__card--front {
  transform: translateY(-8px) scale(1.04);
}

/* Selected file: its details float on frosted glass so the media keeps the space */

.preview {
  position: relative;
  overflow: hidden;
  background: var(--navy);
  isolation: isolate;
}

.preview__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  animation: swap var(--medium) var(--ease) backwards;
}

.preview__ambient {
  position: absolute;
  inset: -48px;
  width: calc(100% + 96px);
  height: calc(100% + 96px);
  object-fit: cover;
  filter: blur(40px) saturate(1.5);
  opacity: 0.85;
}

.preview__media {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview__fallback {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: rgb(255 255 255 / 0.82);
  font-size: var(--text-sm);
}

.preview__fallback .icon {
  width: 44px;
  height: 44px;
  color: var(--lime);
}

.preview__mosaic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview__meta,
.preview__remove {
  position: absolute;
  top: 10px;
  background: rgb(255 255 255 / 0.66);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgb(255 255 255 / 0.5);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
}

.preview__meta {
  left: 10px;
  display: grid;
  max-width: calc(100% - 76px);
  margin: 0;
  padding: 7px 15px 8px;
  border-radius: var(--radius-md);
  line-height: 1.25;
}

.preview__remove {
  right: 10px;
}

.preview__meta strong {
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview__meta small {
  color: var(--ink-muted);
}

/* Settings */

.settings {
  display: grid;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 0;
  cursor: pointer;
}

.setting + .setting {
  border-top: 1px solid var(--hairline);
}

.setting__text {
  display: grid;
  gap: 1px;
  line-height: 1.3;
}

.setting__text strong {
  font-weight: 500;
}

.setting__text small {
  color: var(--ink-muted);
}

.switch {
  flex: none;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: var(--radius-full);
  background: rgb(6 38 59 / 0.16);
  box-shadow: inset 0 1px 3px rgb(6 38 59 / 0.14);
  cursor: pointer;
  appearance: none;
  transition: background-color var(--medium) var(--ease);
}

.switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(6 38 59 / 0.28);
  transition:
    transform var(--medium) var(--ease),
    background-color var(--medium) var(--ease);
}

.switch:checked {
  background: var(--navy);
}

.switch:checked::before {
  background: var(--lime);
  transform: translateX(20px);
}

.switch:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.choice {
  min-width: 0;
  margin: 0;
  padding: 6px 0 10px;
  border: 0;
}

.choice legend {
  padding: 0;
  font-weight: 500;
}

.segmented {
  position: relative;
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  margin-top: 10px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: rgb(6 38 59 / 0.07);
}

.segmented::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  transition: transform var(--medium) var(--ease);
}

.segmented:has(label:nth-child(2) input:checked)::before {
  transform: translateX(100%);
}

.segmented__option {
  position: relative;
  display: grid;
  place-items: center;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--fast) var(--ease);
}

.segmented__option:has(input:checked) {
  color: var(--ink);
  font-weight: 600;
}

.segmented__option:has(input:focus-visible) {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.segmented__option:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.6;
}

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

/* Run */

.run {
  margin-top: auto;
  padding-top: 16px;
}

.run__cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 14px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.run__cost strong {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-weight: 600;
  text-align: right;
}

.run__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 0 10px 0 24px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--navy);
  color: var(--on-navy);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 16px 30px -16px rgb(6 38 59 / 0.75);
  transition:
    background-color var(--fast) var(--ease),
    box-shadow var(--medium) var(--ease),
    transform var(--fast) var(--ease);
}

.run__button:hover:not(:disabled) {
  background: #0a3350;
  box-shadow: 0 20px 36px -16px rgb(6 38 59 / 0.85);
  transform: translateY(-1px);
}

.run__button:active:not(:disabled) {
  transform: scale(0.98);
}

.run__button:disabled {
  background: rgb(6 38 59 / 0.08);
  color: var(--ink-muted);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.run__button[aria-busy='true'] {
  background: var(--navy);
  color: var(--on-navy);
  cursor: progress;
}

.run__button:not(:has(.run__price:not([hidden]))) {
  justify-content: center;
  padding-inline: 24px;
}

.run__price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 0 14px 0 11px;
  border-radius: var(--radius-full);
  background: var(--lime);
  color: var(--navy);
  font-size: var(--text-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.run__action {
  position: relative;
}

.run__progress {
  position: absolute;
  right: 26px;
  bottom: 9px;
  left: 26px;
  width: calc(100% - 52px);
  height: 4px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-full);
  background: rgb(255 255 255 / 0.18);
  pointer-events: none;
  appearance: none;
}

.run__progress::-webkit-progress-bar {
  background: transparent;
}

.run__progress::-webkit-progress-value {
  border-radius: var(--radius-full);
  background: var(--lime);
  transition: width var(--fast) linear;
}

.run__progress::-moz-progress-bar {
  border-radius: var(--radius-full);
  background: var(--lime);
}

.run__help {
  margin-top: 12px;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
  text-align: center;
}

.run__message {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--busy-tint);
  color: var(--busy-ink);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* Stays in the page when empty: a live region that appears with its text can go unannounced. */
.run__message:empty {
  margin: 0;
  padding: 0;
}

/* Progress is already on the button, so this tone only reaches screen readers. */
.run__message[data-tone='quiet'] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.run__message[data-tone='error'] {
  background: var(--bad-tint);
  color: var(--bad-ink);
}

@media (max-width: 899px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .dropzone,
  .preview {
    min-height: 300px;
  }
}

@media (max-width: 719px) {
  .workbench {
    gap: 14px;
    margin-top: 18px;
  }

  .panel {
    padding: 16px;
    border-radius: 24px;
  }

  .dropzone,
  .preview {
    min-height: 268px;
  }

  .dropzone__title {
    font-size: var(--text-lg);
  }
}

/* Touch devices have no drop gesture, so the prompt says what a tap does. */
@media (hover: none) {
  .dropzone__hint {
    display: none;
  }
}
