/* Photos Effect — the photo is the interface; everything else stays quiet. */

:root {
  --bg: #0d0d0c;
  --surface: #181816;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eceae4;
  --muted: #8f8c84;
  --accent: #e6b455;
  --danger: #f08a7b;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --pad: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ------------------------------------------------------------- header -- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--pad) 10px;
}

.brand {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.private {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.private svg {
  width: 13px;
  height: 13px;
}

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

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 4px var(--pad) 8px;
  container-type: size;
}

/* ---- empty state ---- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 440px;
  text-align: center;
  animation: rise 0.6s var(--ease) both;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.empty h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(32px, 8vw, 46px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.lede {
  margin: 14px 0 30px;
  color: var(--muted);
  font-size: 16px;
}

.hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-wrap: balance;
}

.error {
  margin: 18px 0 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: 10px;
  color: var(--danger);
  font-size: 14px;
}

@media (hover: none) {
  .desktop-only {
    display: none;
  }
}

/* ---- photo frame ---- */

.frame {
  --ratio: 1;
  --split: 50%;
  position: relative;
  display: none;
  width: min(100cqw, 100cqh * var(--ratio));
  aspect-ratio: var(--ratio);
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: ew-resize;
  animation: rise 0.5s var(--ease) both;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* The result sits above the original, revealed to the right of the divider.
   Intensity is simply its opacity — exactly what the download bakes in. */
.after {
  clip-path: inset(0 0 0 var(--split));
  opacity: var(--intensity, 1);
  visibility: hidden;
}

.frame.settling .after,
.frame.settling .divider {
  transition: clip-path 0.9s var(--ease), left 0.9s var(--ease);
}

.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split);
  width: 44px;
  margin-left: -22px;
  display: none;
  place-items: center;
  outline: none;
}

.divider::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.5px;
  margin-left: -0.75px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.grip {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #111;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s var(--ease);
}

.grip svg {
  width: 18px;
  height: 18px;
}

.divider:focus-visible .grip {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.frame:active .grip {
  transform: scale(0.92);
}

.tag {
  position: absolute;
  top: 10px;
  display: none;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
}

.tag-before {
  left: 10px;
}

.tag-after {
  right: 10px;
}

/* ---- progress ---- */

.progress {
  position: absolute;
  inset: auto 0 0 0;
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 40px 16px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
}

.progress-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.track {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s linear;
}

/* ------------------------------------------------------------ controls -- */

.controls {
  display: none;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px var(--pad) 16px;
  animation: rise 0.5s var(--ease) both;
}

.intensity {
  display: grid;
  grid-template-columns: auto 1fr 3ch;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.intensity output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--fill, 100%), rgba(255, 255, 255, 0.2) var(--fill, 100%));
}

input[type="range"]::-moz-range-track {
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
}

input[type="range"]::-moz-range-progress {
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s var(--ease), opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.primary {
  background: var(--text);
  color: #111110;
}

.btn.primary:hover {
  background: #fff;
}

.btn.quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.quiet:hover {
  border-color: rgba(255, 255, 255, 0.24);
}

.btn.large {
  flex: none;
  min-height: 54px;
  padding: 0 34px;
  border-radius: 999px;
  font-size: 16px;
}

.actions .primary {
  flex: 1.4;
}

/* ---------------------------------------------------------- drop veil -- */

.dropveil {
  position: fixed;
  inset: 10px;
  z-index: 5;
  display: none;
  place-items: center;
  border: 1.5px dashed var(--accent);
  border-radius: 20px;
  background: rgba(13, 13, 12, 0.86);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  pointer-events: none;
}

.app.dragging .dropveil {
  display: grid;
}

/* -------------------------------------------------------------- states -- */

.app:not([data-state="empty"]) .empty {
  display: none;
}

.app:not([data-state="empty"]) .frame {
  display: block;
}

.app[data-state="working"] .frame {
  cursor: progress;
}

.app[data-state="working"] .progress {
  display: flex;
}

.app[data-state="working"] .layer {
  filter: brightness(0.82);
}

.app[data-state="ready"] .after {
  visibility: visible;
}

.app[data-state="ready"] .divider {
  display: grid;
}

.app[data-state="ready"] .tag {
  display: block;
}

.app[data-state="ready"] .controls {
  display: flex;
}

.layer {
  transition: filter 0.4s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (min-width: 720px) {
  :root {
    --pad: 28px;
  }

  .bar {
    padding-top: 20px;
  }

  .controls {
    flex-direction: row;
    align-items: center;
    max-width: 860px;
    gap: 28px;
    padding-bottom: 24px;
  }

  .intensity {
    flex: 1;
  }

  .actions {
    flex: none;
  }

  .actions .btn {
    flex: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
