:root {
  --carta: #f3f2ec;
  --inchiostro: #282828;
  --grigio: #b3b3af;
  --grigio-scuro: #72726f;
  --accento: #f15534;
  --accento-velo: rgba(241, 85, 52, 0.64);
  --mono: 'Geist Mono Variable', ui-monospace, monospace;
  --sans: 'Mona Sans Variable', system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* a light paper grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.16 0 0 0 0 0.16 0 0 0 0 0.15 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.pagina {
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: clamp(8px, 1.6vmin, 18px);
  gap: 0;
}

/* ---- the stage with the drawing ---- */
.palco {
  position: relative;
  min-height: 0;
  border: 1px solid var(--grigio);
  border-bottom: 0;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.righello {
  position: absolute;
  pointer-events: none;
  --tacca: rgba(40, 40, 40, 0.28);
}
.righello--su, .righello--giu {
  left: 22px; right: 22px; height: 7px;
  background: repeating-linear-gradient(90deg, var(--tacca) 0 1px, transparent 1px 8px);
}
.righello--su { top: 9px; }
.righello--giu { bottom: 9px; }
.righello--sx, .righello--dx {
  top: 22px; bottom: 22px; width: 7px;
  background: repeating-linear-gradient(180deg, var(--tacca) 0 1px, transparent 1px 8px);
}
.righello--sx { left: 9px; }
.righello--dx { right: 9px; }

.angolo {
  position: absolute;
  width: 10px; height: 10px;
  fill: none;
  stroke: var(--inchiostro);
  stroke-width: 1;
  pointer-events: none;
}
.angolo--a { top: 8px; left: 8px; }
.angolo--b { top: 8px; right: 8px; }
.angolo--c { bottom: 8px; left: 8px; }
.angolo--d { bottom: 8px; right: 8px; }

.disegno {
  --mx: clamp(14px, 3vmin, 40px);
  --mt: clamp(18px, 4vmin, 44px);
  --mb: clamp(14px, 2.5vmin, 30px);
  position: absolute;
  left: var(--mx);
  top: var(--mt);
  width: calc(100% - 2 * var(--mx));
  height: calc(100% - var(--mt) - var(--mb));
  overflow: visible;
  pointer-events: none;
}

.disegno line { stroke: var(--inchiostro); }
#tratteggio line { stroke-width: 0.45; opacity: 0.22; }
#ombra line { stroke-width: 0.6; opacity: 0.55; }
#puntini rect { fill: var(--inchiostro); opacity: 0.35; }

.terra { stroke: var(--inchiostro); stroke-width: 1.4; fill: none; }
.muro { fill: #f7f6f1; stroke: var(--inchiostro); stroke-width: 1.1; }
.muro--trat { fill: url(#puntini); stroke: none; }
.solaio { fill: #ecebe4; stroke: var(--inchiostro); stroke-width: 1; }
.zoccolo { fill: #e6e5de; stroke: var(--inchiostro); stroke-width: 1; }
.vetro { fill: #dedcd4; stroke: var(--inchiostro); stroke-width: 1; }
.vetro--cieco { fill: url(#tratteggio); }
.telaio { stroke: var(--inchiostro); stroke-width: 1; fill: none; }
.porta { fill: #cfcdc5; stroke: var(--inchiostro); stroke-width: 1; }
.pilastro { fill: #f7f6f1; stroke: var(--inchiostro); stroke-width: 1; }
.ombra { fill: url(#ombra); stroke: none; }
.scala { fill: none; stroke: var(--inchiostro); stroke-width: 1; }
.scala-cosciale { fill: none; stroke: var(--inchiostro); stroke-width: 1.2; }
.quota { fill: none; stroke: var(--grigio-scuro); stroke-width: 0.8; }
.quota-testo { font: 500 9px var(--mono); fill: var(--grigio-scuro); text-anchor: middle; letter-spacing: 0.06em; }
.alberi path { fill: none; stroke: var(--inchiostro); stroke-linecap: round; }

.rimedio path {
  fill: none;
  stroke: var(--accento);
  stroke-width: 1.4;
  stroke-linecap: square;
}

/* ---- the rulers that follow the pointer ---- */
.mira {
  position: absolute;
  background: var(--inchiostro);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.mira--v { top: 0; bottom: 0; left: 0; width: 1px; }
.mira--h { left: 0; right: 0; top: 0; height: 1px; }

.piu {
  position: absolute;
  left: 0; top: 0;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  stroke: var(--accento);
  stroke-width: 1.4;
  fill: none;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.coord {
  position: absolute;
  left: 0; top: 0;
  display: grid;
  gap: 1px;
  font: 500 9px/1.2 var(--mono);
  letter-spacing: 0.04em;
  color: var(--grigio-scuro);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.coord b { font-weight: 500; color: var(--inchiostro); }

/* ---- the selection box ---- */
.riquadro {
  position: absolute;
  border: 1px solid var(--accento);
  pointer-events: none;
}
.riquadro i {
  position: absolute;
  width: 5px; height: 5px;
  background: var(--carta);
  border: 1px solid var(--accento);
}
.riquadro i:nth-child(1) { left: -3px; top: -3px; }
.riquadro i:nth-child(2) { right: -3px; top: -3px; }
.riquadro i:nth-child(3) { left: -3px; bottom: -3px; }
.riquadro i:nth-child(4) { right: -3px; bottom: -3px; }

/* ---- the error marks and their labels ---- */
.segni { position: absolute; inset: 0; pointer-events: none; }

.segno {
  position: absolute;
  left: 0; top: 0;
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
}
.segno__quadro {
  position: absolute;
  inset: 0;
  background: var(--accento);
}
.segno__mirino {
  position: absolute;
  inset: -6px;
  overflow: visible;
  fill: none;
  stroke: var(--accento);
  stroke-width: 1;
}

.guida {
  position: absolute;
  left: 0; top: 0;
  overflow: visible;
  fill: none;
  stroke: var(--accento);
  stroke-width: 1;
}

.etichetta {
  position: absolute;
  left: 0; top: 0;
  width: clamp(104px, 22vmin, 196px);
  padding: clamp(5px, 0.9vmin, 7px) 20px clamp(6px, 1vmin, 8px) clamp(6px, 1vmin, 9px);
  background: var(--accento);
  color: #fff8f4;
  font: 500 clamp(7.5px, 1.25vmin, 11px)/1.3 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: auto;
  box-shadow: 0 8px 18px -10px rgba(120, 30, 10, 0.55);
  transform-origin: 0 0;
}
.etichetta small {
  display: block;
  margin-bottom: 3px;
  font-size: 0.82em;
  opacity: 0.75;
  text-transform: none;
}
.etichetta__chiudi {
  position: absolute;
  top: 5px; right: 5px;
  width: 13px; height: 13px;
  padding: 0;
  border: 1px solid rgba(255, 248, 244, 0.8);
  background: transparent;
  cursor: pointer;
}
.etichetta__chiudi svg {
  display: block;
  width: 100%; height: 100%;
  stroke: #fff8f4;
  stroke-width: 1.2;
  fill: none;
}
@media (hover: hover) {
  .etichetta__chiudi:hover { background: rgba(255, 248, 244, 0.22); }
}

.puntatore {
  position: absolute;
  left: 0; top: 0;
  width: 18px; height: 18px;
  margin: -3px 0 0 -4px;
  fill: var(--inchiostro);
  stroke: #fff;
  stroke-width: 1.3;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.18));
}

/* ---- the strip under the drawing ---- */
.piede {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px 24px;
  border: 1px solid var(--grigio);
  padding: clamp(8px, 1.6vmin, 18px) clamp(10px, 2vmin, 22px);
}

.marchio {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: clamp(4px, 1vmin, 10px);
  font: 600 clamp(11px, 1.5vmin, 14px)/1 var(--sans);
  letter-spacing: 0.01em;
}
.marchio svg { width: 15px; height: 15px; fill: var(--inchiostro); stroke: var(--inchiostro); stroke-width: 0.8; }

h1 {
  font-size: clamp(17px, min(4.2vw, 5.6vh), 54px);
  font-weight: 640;
  font-stretch: 92%;
  line-height: 0.95;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  max-width: 15ch;
}

.piede__stato {
  display: grid;
  justify-items: end;
  gap: 4px;
  font: 500 clamp(8.5px, 1.2vmin, 11px)/1.3 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: right;
}
.suggerimento { color: var(--grigio-scuro); max-width: 20ch; }
.conto { color: var(--accento); display: flex; align-items: baseline; gap: 0.6ch; }
.conto__cifra {
  position: relative;
  display: inline-block;
  height: 1.3em;
  overflow: hidden;
  vertical-align: bottom;
}
.conto__cifra span { display: block; }

@media (max-width: 560px) {
  .piede { grid-template-columns: 1fr; }
  .piede__stato { justify-items: start; text-align: left; }
  .suggerimento { max-width: none; }
}
