:root {
  --fondo: #f3f1ec;
  --carta: #ffffff;
  --inchiostro: #16161a;
  --grigio: #6f6e74;
  --grigio-chiaro: #a9a8ad;
  --linea: rgba(22, 22, 26, 0.08);
  --tinta: #e0703a;
  --tinta-morbida: rgba(224, 112, 58, 0.16);
  --vetro: rgba(255, 255, 255, 0.58);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 16px;
}

/* one warm light behind the card */
.stage::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(86vw, 640px);
  height: min(60vh, 420px);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(224, 112, 58, 0.1), transparent);
  pointer-events: none;
}

.card {
  --w: min(560px, calc(100vw - 32px), calc((100vh - 150px) * 1.6));
  position: relative;
  width: var(--w);
  background: var(--carta);
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 1px 0 rgba(22, 22, 26, 0.04), 0 1px 2px rgba(22, 22, 26, 0.06), 0 18px 44px -18px rgba(60, 40, 20, 0.26);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px 9px;
}

.brand { display: flex; align-items: center; gap: 7px; min-width: 0; }
.brand__mark { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--inchiostro); stroke-width: 1.6; stroke-linecap: round; }
.brand__name { font-size: 13px; font-weight: 640; letter-spacing: -0.01em; }
.brand__file { font-size: 12px; color: var(--grigio-chiaro); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 9px;
  border-radius: 99px;
  background: #f1f0ed;
  color: var(--grigio);
  font-size: 11.5px;
  font-weight: 560;
  white-space: nowrap;
  transition: background 0.3s ease, color 0.3s ease;
}
.chip__tick { width: 0; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.chip.is-edited { background: var(--tinta-morbida); color: #b9531f; }

.photo {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 13px;
  overflow: hidden;
  background: #2b2a33;
  isolation: isolate;
}
.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -30px 50px -40px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.photo__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.filtri { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* a thin warm light that crosses the photo when a pull is released */
.photo__sheen {
  position: absolute;
  inset: -10% auto -10% 0;
  width: 34%;
  background: linear-gradient(100deg, transparent, rgba(255, 236, 214, 0.22) 45%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
  transform: translateX(-120%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.curve {
  --s: clamp(86px, 29%, 150px);
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: var(--s);
  height: var(--s);
  border-radius: 12px;
  background: var(--vetro);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 10px 24px -12px rgba(20, 14, 10, 0.5);
  touch-action: none;
  cursor: crosshair;
}
.curve__svg { position: absolute; inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px); overflow: visible; }
.curve__grid line { stroke: rgba(22, 22, 26, 0.09); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.curve__hist { fill: rgba(22, 22, 26, 0.12); }
.curve__ref { stroke: rgba(22, 22, 26, 0.2); stroke-width: 0.8; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.curve__glow { fill: none; stroke: var(--tinta); stroke-width: 5; opacity: 0.16; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.curve__line { fill: none; stroke: var(--inchiostro); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.curve.is-active .curve__line { stroke: #b9531f; }

.curve__read {
  position: absolute;
  left: 9px;
  top: 7px;
  font-size: 9.5px;
  font-weight: 560;
  color: var(--grigio);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

/* the handle: GSAP moves the button, the CSS draws the span */
.handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 0;
  background: none;
  cursor: grab;
  display: grid;
  place-items: center;
  touch-action: none;
}
.handle span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--inchiostro), 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.25s ease;
}
.handle.is-on span { box-shadow: 0 0 0 1.5px var(--tinta), 0 0 0 5px var(--tinta-morbida), 0 2px 6px rgba(0, 0, 0, 0.3); }
.handle:focus-visible { outline: 2px solid var(--tinta); outline-offset: -4px; border-radius: 50%; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px 2px 6px;
}
.bar__info { display: grid; gap: 1px; min-width: 0; }
.bar__label { font-size: 12.5px; font-weight: 620; }
.bar__hint { font-size: 11.5px; color: var(--grigio-chiaro); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__tools { display: flex; gap: 6px; flex: none; }

.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--linea);
  background: #fff;
  color: var(--inchiostro);
  font: inherit;
  font-size: 12px;
  font-weight: 580;
  font-variation-settings: "wdth" 100;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tool svg .fill { fill: currentColor; stroke: none; opacity: 0.18; transition: opacity 0.25s ease; }
.tool--round { width: 32px; padding: 0; justify-content: center; }
.tool.is-down { background: var(--inchiostro); border-color: var(--inchiostro); color: #fff; }
.tool.is-down svg .fill { opacity: 0.6; }
.tool:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }
@media (hover: hover) {
  .tool:hover { border-color: rgba(22, 22, 26, 0.18); }
  .tool.is-down:hover { border-color: var(--inchiostro); }
}

@media (max-width: 420px) {
  .tool span { display: none; }
  .tool { width: 32px; padding: 0; justify-content: center; }
  .brand__file { display: none; }
}

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 10;
  fill: var(--inchiostro);
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}
