/* Penwell, draft to compare: the window of an invented AI writing app on a near black page. The two pages are the
   same size all the time (no reflow): in the draft the rewrite sits in the middle with the original tucked under it,
   in the compare view they stand side by side (or one above the other when the window is narrow). The script places
   them in pixels and draws the threads between the edits. */
:root {
  --page: #08080a;          /* the page around the window */
  --window: #101013;        /* the app window */
  --sheet: #17171b;         /* the paper of the pages */
  --edge: rgba(255, 255, 255, 0.075); /* the 1px edges */
  --ink: #ececf1;           /* the words */
  --muted: #8d8d98;         /* the small words */
  --dim: #5d5d68;           /* the faintest words */
  --light: #a3bcff;         /* the light: threads, seam, scan */
  --out: #ff8e8e;           /* the words taken out */
  --in: #7fe3b8;            /* the words put in */
  --button: #f2f2f5;        /* the button */
  --button-ink: #0b0b0d;    /* the words on the button */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.palco {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vmin, 24px);
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(163, 188, 255, 0.07), transparent 70%),
    var(--page);
}

/* the app window */
.finestra {
  position: relative;
  width: min(94vw, 820px);
  height: min(90vh, 540px);
  display: flex;
  flex-direction: column;
  border-radius: clamp(14px, 2.4vmin, 20px);
  background: linear-gradient(180deg, #131317, var(--window) 40%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px var(--edge),
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 24px 60px -18px rgba(0, 0, 0, 0.85),
    0 60px 120px -40px rgba(30, 40, 80, 0.35);
}

/* the bar on top */
.barra {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: clamp(40px, 7vmin, 50px);
  padding: 0 clamp(10px, 2.2vmin, 16px);
  border-bottom: 1px solid var(--edge);
}

.marchio {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(22px, 4vmin, 26px);
  aspect-ratio: 1;
  border-radius: 7px;
  background: linear-gradient(150deg, #2a2f44, #16171d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.marchio svg {
  width: 62%;
  fill: none;
  stroke: var(--light);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.marchio circle {
  fill: var(--window);
}

.barra-titolo {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.barra-titolo strong {
  font-size: clamp(12px, 2.1vmin, 13.5px);
  font-weight: 620;
  letter-spacing: -0.005em;
}

.barra-sotto {
  position: relative;
  display: block;
  height: 1.3em;
  font-size: clamp(10.5px, 1.8vmin, 11.5px);
  color: var(--muted);
}

.barra-sotto span,
.barra-versione > span,
.aiuto-testo > span,
.pulsante-scritte > span {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
}

.barra-versione {
  position: relative;
  margin-left: auto;
  height: 22px;
  min-width: 52px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 560;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--edge);
}

.barra-versione > span,
.pulsante-scritte > span {
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* the desk the pages lie on */
.tavolo {
  position: relative;
  flex: 1;
  min-height: 0;
  --fs: 13px;
}

.pagina {
  position: absolute;
  left: 0;
  top: 0;
  padding: calc(var(--fs) * 1.2) calc(var(--fs) * 1.35);
  border-radius: 12px;
  background: linear-gradient(180deg, #1b1b20, var(--sheet) 30%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 30px -12px rgba(0, 0, 0, 0.8);
  font-size: var(--fs);
  overflow: hidden;
  visibility: hidden;
}

.pagina--v1 {
  background: linear-gradient(180deg, #18181c, #141418 30%);
}

/* the light that slides over a page edge while it moves */
.pagina-luce {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(70% 40% at 50% 0%, rgba(163, 188, 255, 0.12), transparent 70%);
  opacity: 0;
}

/* the scan line that runs across the rewrite before it splits */
.scansione {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 46%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(163, 188, 255, 0.05) 60%, rgba(196, 212, 255, 0.5) 98%, transparent);
  opacity: 0;
}

.pagina-testa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7em;
  font-size: 0.8em;
}

.etichetta {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.22em 0.6em;
  border-radius: 999px;
  font-weight: 580;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 0 0 1px var(--edge);
}

.etichetta--ai {
  color: #cfdbff;
  background: rgba(163, 188, 255, 0.09);
  box-shadow: inset 0 0 0 1px rgba(163, 188, 255, 0.2);
}

.etichetta svg {
  width: 1.05em;
  fill: currentColor;
}

.quando {
  color: var(--dim);
}

.pagina-titolo {
  margin: 0 0 0.45em;
  font-size: 1.22em;
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.012em;
  line-height: 1.15;
}

.pagina-testo {
  margin: 0 0 0.7em;
  line-height: 1.55;
  color: #c9c9d2;
}

.pagina-firma {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.pagina-piede {
  position: absolute;
  left: calc(var(--fs) * 1.35);
  right: calc(var(--fs) * 1.35);
  bottom: calc(var(--fs) * 1);
  display: flex;
  justify-content: space-between;
  padding-top: 0.7em;
  border-top: 1px solid var(--edge);
  font-size: 0.78em;
  color: var(--dim);
}

.tavolo.e-stretto .pagina-altro {
  display: none;
}

/* an edit: tint and strike are two backgrounds whose width the script tweens (--f and --s) */
.segno {
  --f: 0%;
  --s: 0%;
  --a: 1;
  border-radius: 4px;
  padding: 0.05em 0.12em;
  margin: 0 -0.12em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background-repeat: no-repeat;
  transition: filter 0.25s ease, opacity 0.25s ease;
}

.segno--tolto {
  background-image:
    linear-gradient(var(--out), var(--out)),
    linear-gradient(rgba(255, 142, 142, 0.13), rgba(255, 142, 142, 0.13));
  background-size: var(--s) 1.5px, var(--f) 100%;
  background-position: 0 56%, 0 0;
}

.segno--messo {
  background-image:
    linear-gradient(rgba(127, 227, 184, 0.75), rgba(127, 227, 184, 0.75)),
    linear-gradient(rgba(127, 227, 184, 0.14), rgba(127, 227, 184, 0.14));
  background-size: var(--s) 1px, var(--f) 100%;
  background-position: 0 100%, 0 0;
}

.tavolo.e-confronto .segno {
  cursor: default;
}

.tavolo.e-confronto .segno--tolto {
  color: #f3b3b3;
}

.tavolo.e-confronto .segno--messo {
  color: #b9f1d8;
}

.tavolo.e-guarda .segno {
  opacity: 0.4;
}

.tavolo.e-guarda .segno.e-acceso {
  opacity: 1;
  filter: brightness(1.25);
}

/* the seam between the two pages */
.cucitura {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 100px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(163, 188, 255, 0.28) 20%, rgba(163, 188, 255, 0.28) 80%, transparent);
  opacity: 0;
  overflow: hidden;
}

.cucitura i {
  position: absolute;
  left: -2px;
  top: 0;
  width: 5px;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(214, 226, 255, 0.95), transparent);
  filter: blur(1.5px);
}

.tavolo.e-stretto .cucitura {
  width: 100px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(163, 188, 255, 0.28) 20%, rgba(163, 188, 255, 0.28) 80%, transparent);
}

.tavolo.e-stretto .cucitura i {
  left: 0;
  top: -2px;
  width: 34%;
  height: 5px;
  background: linear-gradient(90deg, transparent, rgba(214, 226, 255, 0.95), transparent);
}

/* the threads between the edits */
.fili {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.filo {
  fill: none;
  stroke: rgba(163, 188, 255, 0.42);
  stroke-width: 1;
  stroke-linecap: butt;
  transition: stroke 0.25s ease, stroke-width 0.25s ease, opacity 0.25s ease;
}

.cometa {
  fill: none;
  stroke: #dfe7ff;
  stroke-width: 1.6;
  stroke-linecap: round;
  filter: url(#bagliore);
  opacity: 0;
}

.fili.e-guarda .filo {
  opacity: 0.3;
}

.fili.e-guarda .filo.e-acceso {
  opacity: 1;
  stroke: rgba(196, 212, 255, 0.95);
  stroke-width: 1.5;
}

/* the reason of an edit, on the thread while you look at it */
.motivo {
  position: absolute;
  left: 0;
  top: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 580;
  white-space: nowrap;
  color: #dfe7ff;
  background: rgba(22, 24, 34, 0.92);
  box-shadow: inset 0 0 0 1px rgba(163, 188, 255, 0.3), 0 6px 16px -6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

/* the AI bar at the bottom */
.aiuto {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 clamp(8px, 1.8vmin, 14px) clamp(8px, 1.8vmin, 14px);
  padding: 7px 7px 7px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 0 0 1px var(--edge);
}

.aiuto-icona {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 25%, rgba(163, 188, 255, 0.35), rgba(163, 188, 255, 0.08) 70%);
  box-shadow: inset 0 0 0 1px rgba(163, 188, 255, 0.25);
}

.aiuto-icona svg {
  width: 15px;
  fill: #dbe4ff;
}

.aiuto-testo {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 32px;
}

.aiuto-testo > span {
  right: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  line-height: 1.25;
}

.aiuto-testo strong,
.aiuto-piccolo {
  overflow: hidden;
  text-overflow: ellipsis;
}

.aiuto-testo strong {
  font-size: clamp(11.5px, 2vmin, 13px);
  font-weight: 600;
}

.aiuto-testo b {
  font-weight: 660;
}

.tolte {
  color: var(--out);
}

.messe {
  color: var(--in);
}

.aiuto-piccolo {
  font-size: clamp(10px, 1.7vmin, 11px);
  color: var(--muted);
}

.pulsante {
  position: relative;
  flex: none;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--button-ink);
  font: inherit;
  font-size: clamp(11.5px, 2vmin, 12.5px);
  font-weight: 620;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pulsante-fondo {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, var(--button));
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px -6px rgba(163, 188, 255, 0.45);
}

.pulsante-scritte {
  position: relative;
  display: block;
  height: 100%;
  overflow: hidden;
  border-radius: 999px;
}

.pulsante:focus-visible {
  outline: 2px solid var(--light);
  outline-offset: 3px;
  border-radius: 999px;
}

@media (hover: hover) {
  .pulsante:hover .pulsante-fondo {
    filter: brightness(1.04);
  }
}

/* the fake pointer of the automatic tour */
.puntatore {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -4px;
  fill: #f4f4f6;
  stroke: #0b0b0d;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 5;
}

@media (max-width: 420px) {
  .aiuto-piccolo {
    display: none;
  }
  .barra-versione,
  .lungo {
    display: none;
  }
}
