/* Arca Photo, the crop tool: the frame with its handles, the formats and the straighten dial */
:root {
  --fondo: #09090a;            /* the room behind the window */
  --pannello: #141416;         /* the editor window */
  --pannello-2: #0f0f11;       /* the bottom of the window */
  --tavolo: #0b0b0c;           /* the table under the photo */
  --testo: #ededee;            /* type */
  --grigio: #85858b;           /* small type, ticks */
  --filo: rgba(255, 255, 255, 0.08); /* hairlines */
  --accento: #f4b740;          /* the one accent: amber */
  --cornice: rgba(255, 255, 255, 0.92); /* the crop frame */
  --ombra: 0.66;               /* how dark the photo is outside the frame */
  --barra: clamp(38px, 8vh, 52px);
  --ghiera: clamp(50px, 12vh, 70px);
  --formati: clamp(34px, 8vh, 44px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(70% 55% at 50% 30%, rgba(232, 110, 52, 0.10), transparent 70%),
    radial-gradient(120% 90% at 50% 110%, #121214 0%, var(--fondo) 60%);
  color: var(--testo);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.pagina {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.4vmin, 22px);
}

.editor {
  position: relative;
  width: min(760px, 100%);
  height: min(620px, 100%);
  display: grid;
  grid-template-rows: var(--barra) 1fr var(--ghiera) var(--formati);
  padding: 0 clamp(8px, 2vmin, 16px) clamp(8px, 1.6vh, 14px);
  border-radius: clamp(14px, 3vmin, 22px);
  background: linear-gradient(180deg, #18181b 0%, var(--pannello) 40%, var(--pannello-2) 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 24px 60px -18px rgba(0, 0, 0, 0.85),
    0 60px 120px -40px rgba(120, 50, 20, 0.25);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* the top bar */
.barra {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.reset {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  font-size: clamp(11px, 2.2vmin, 13px);
  font-weight: 500;
  color: var(--testo);
  transition: color 0.3s, background-color 0.3s, opacity 0.3s;
}
.reset:disabled { color: var(--grigio); opacity: 0.55; cursor: default; }
.reset svg { display: block; }
.titolo { display: grid; justify-items: center; line-height: 1.15; }
.titolo__nome { font-size: clamp(12px, 2.4vmin, 14px); font-weight: 620; font-stretch: 112%; letter-spacing: 0.01em; }
.titolo__dim { font-size: clamp(9.5px, 1.9vmin, 11px); color: var(--grigio); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.fatto {
  justify-self: end;
  position: relative;
  height: 28px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--accento);
  color: #1c1406;
  font-size: clamp(11px, 2.2vmin, 13px);
  font-weight: 640;
  font-stretch: 108%;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 14px -4px rgba(244, 183, 64, 0.55);
}
.fatto__luce {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.65) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}
.fatto__finestra { position: relative; display: block; height: 1.3em; overflow: hidden; }
.fatto__riga { display: block; }
.fatto__voce { display: flex; align-items: center; justify-content: center; gap: 4px; height: 1.3em; line-height: 1.3em; }
.fatto__voce svg { display: block; }
[data-spunta] { stroke-dasharray: 1; stroke-dashoffset: 1; }

/* the table, the photo and the frame */
.tavolo {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background:
    radial-gradient(80% 70% at 50% 50%, #121214 0%, var(--tavolo) 100%);
  box-shadow: inset 0 0 0 1px var(--filo);
  touch-action: none;
}
.foto {
  position: absolute;
  left: 0; top: 0;
  will-change: transform;
}
.foto img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}
.cornice {
  position: absolute;
  left: 0; top: 0;
  box-shadow: 0 0 0 200vmax rgba(9, 9, 10, var(--ombra));
}
.cornice::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--cornice);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.griglia { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.griglia--terzi i { position: absolute; background: rgba(255, 255, 255, 0.55); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12); }
.griglia--terzi .v { top: 0; bottom: 0; width: 1px; }
.griglia--terzi .o { left: 0; right: 0; height: 1px; }
.griglia--fine {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px calc(100% / 8)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px calc(100% / 6));
}

.maniglia {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  display: grid;
  place-items: center;
  touch-action: none;
  z-index: 2;
}
.maniglia--angolo[data-maniglia="nw"], .maniglia--angolo[data-maniglia="se"] { cursor: nwse-resize; }
.maniglia--angolo[data-maniglia="ne"], .maniglia--angolo[data-maniglia="sw"] { cursor: nesw-resize; }
.maniglia--o { cursor: ns-resize; }
.maniglia--v { cursor: ew-resize; }
.segno { display: block; position: relative; }
.maniglia--angolo .segno { width: 22px; height: 22px; }
.maniglia--angolo svg {
  position: absolute;
  width: 22px;
  height: 22px;
  left: 0; top: 0;
  overflow: visible;
  transform-origin: 50% 50%;
}
.maniglia--angolo svg path {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.45));
}
/* the corner sits at the centre of its handle: the L starts just outside the frame line */
.maniglia--angolo[data-maniglia="nw"] svg { left: 7.5px; top: 7.5px; }
.maniglia--angolo[data-maniglia="ne"] svg { left: -7.5px; top: 7.5px; }
.maniglia--angolo[data-maniglia="se"] svg { left: -7.5px; top: -7.5px; }
.maniglia--angolo[data-maniglia="sw"] svg { left: 7.5px; top: -7.5px; }
.maniglia--lato .segno { background: #fff; border-radius: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); }
.maniglia--o .segno { width: 20px; height: 3px; }
.maniglia--v .segno { width: 3px; height: 20px; }

/* the straighten dial */
.ghiera {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: end;
  padding-top: clamp(4px, 1.2vh, 10px);
}
.ghiera__valore {
  justify-self: center;
  display: flex;
  align-items: center;
  height: 1.2em;
  font-size: clamp(11px, 2.2vmin, 13px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--testo);
  line-height: 1.2em;
}
.meno { display: inline-block; width: 0.62em; text-align: right; opacity: 0; }
.cifra { display: inline-block; height: 1.2em; width: 0.62em; overflow: hidden; text-align: center; }
.cifra--decine { width: 0; transition: width 0.25s cubic-bezier(0.3, 0.7, 0.2, 1.2); }
.cifra--decine.piena { width: 0.62em; }
.nastro-cifre { display: block; will-change: transform; }
.nastro-cifre b { display: block; height: 1.2em; font-weight: inherit; }
.punto { display: inline-block; width: 0.28em; text-align: center; }
.grado { display: inline-block; width: 0.4em; color: var(--grigio); }

.righello {
  position: relative;
  height: clamp(28px, 6.4vh, 38px);
  overflow: hidden;
  cursor: ew-resize;
  touch-action: none;
  outline: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}
.righello:focus-visible .righello__indice { background: var(--accento); }
.righello__nastro {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  overflow: visible;
  will-change: transform;
}
.righello__nastro line { stroke: #fff; stroke-width: 1; shape-rendering: crispEdges; }
.righello__nastro .zero { stroke: var(--accento); stroke-width: 1.5; }
.righello__nastro text { fill: var(--grigio); font-size: 8.5px; font-weight: 500; font-variant-numeric: tabular-nums; text-anchor: middle; }
.righello__indice {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 58%;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--testo);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  transform-origin: 50% 0;
}

/* the formats */
.formati {
  position: relative;
  justify-self: center;
  align-self: center;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--filo);
}
.formati__pillola {
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a2a2e, #222225);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.4);
}
.formati button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: clamp(24px, 5.4vh, 30px);
  padding: 0 clamp(8px, 2vmin, 12px);
  border-radius: 999px;
  font-size: clamp(10.5px, 2.1vmin, 12.5px);
  font-weight: 560;
  color: var(--grigio);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.formati button[aria-checked="true"] { color: var(--accento); }
.formati svg { width: 13px; height: 13px; display: block; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* the drawn pointer of the automatic tour */
.dito {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
  overflow: visible;
}

@media (hover: hover) {
  .reset:not(:disabled):hover { background: rgba(255, 255, 255, 0.06); }
  .fatto:hover { filter: brightness(1.06); }
  .formati button:hover { color: var(--testo); }
  .formati button[aria-checked="true"]:hover { color: var(--accento); }
}

@media (max-width: 420px) {
  .titolo__dim { display: none; }
  .formati button svg { display: none; }
}
