:root {
  --fondo: #f4f4f5;
  --carta: #ffffff;
  --inchiostro: #18181b;
  --grigio: #71717a;
  --grigio-chiaro: #a1a1aa;
  --linea: rgba(24, 24, 27, 0.08);
  --evidenzia: #fde68a;
  --attivo: #f59e0b;
  --anello: rgba(245, 158, 11, 0.32);
  --raggio: 18px;
}

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

html, body { height: 100%; }

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

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

.doc {
  position: relative;
  width: min(560px, 100%);
  background: var(--carta);
  border: 1px solid var(--linea);
  border-radius: var(--raggio);
  box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 24px 60px -24px rgba(24, 24, 27, 0.18);
  overflow: hidden;
}

.doc__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--linea);
  font-size: 13px;
}

.brand { display: flex; align-items: center; gap: 7px; min-width: 0; white-space: nowrap; }
.brand__mark { width: 18px; height: 18px; fill: none; stroke: var(--inchiostro); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.brand__name { font-weight: 640; }
.brand__sep { color: var(--grigio-chiaro); }
.brand__doc { color: var(--grigio); overflow: hidden; text-overflow: ellipsis; }

.keys { display: flex; gap: 4px; flex: none; }
.keys kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px 3px;
  font: 560 11px/1.2 "Mona Sans Variable", system-ui, sans-serif;
  text-align: center;
  color: var(--grigio);
  background: #fafafa;
  border: 1px solid rgba(24, 24, 27, 0.12);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(24, 24, 27, 0.1);
}

/* il corpo ha l'altezza fissa: la barra che si apre spinge giù il testo e la pagina non cambia misura */
.doc__body {
  display: flex;
  flex-direction: column;
  height: clamp(190px, 50vh, 320px);
}

.find-wrap {
  flex: none;
  height: 0;
  overflow: hidden;
}

.doc__view {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* il testo che continua sotto il bordo sfuma nella carta */
.doc__view::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  background: linear-gradient(rgba(255, 255, 255, 0), var(--carta));
  pointer-events: none;
}

.page {
  padding: 16px 34px 26px 22px;
  font-size: clamp(12.5px, 2.4vmin, 15px);
  line-height: 1.62;
  will-change: transform;
}

.page h2 {
  font-size: 1.55em;
  line-height: 1.2;
  font-weight: 680;
  font-stretch: 96%;
  letter-spacing: -0.01em;
  margin-bottom: 0.6em;
}

.page p { color: #3f3f46; margin-bottom: 0.85em; }
.page p:last-child { margin-bottom: 0; }

/* la parola trovata: il velo e il testo sono due figli, il velo cresce da sinistra senza schiacciare il testo */
.hit { position: relative; display: inline-block; color: var(--inchiostro); }
.hit__mark {
  position: absolute;
  inset: 0.1em -0.07em 0.04em;
  border-radius: 0.28em;
  background: var(--evidenzia);
  transform-origin: left center;
  transition: background-color 0.28s ease, box-shadow 0.28s ease;
}
.hit__text { position: relative; }
.hit.is-active .hit__mark { background: var(--attivo); box-shadow: 0 0 0 2px var(--anello); }
.hit.is-active .hit__text { color: #1c1300; }

.find {
  position: relative;
  margin: 10px 12px 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 11px;
  background: #ffffff;
  border: 1px solid rgba(24, 24, 27, 0.1);
  border-radius: 12px;
  box-shadow: 0 6px 18px -10px rgba(24, 24, 27, 0.22), 0 1px 2px rgba(24, 24, 27, 0.05);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.find.is-focus { border-color: rgba(245, 158, 11, 0.55); box-shadow: 0 0 0 3px var(--anello), 0 6px 18px -10px rgba(24, 24, 27, 0.22); }

.find__icon { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--grigio); stroke-width: 1.7; stroke-linecap: round; }

.find__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: 520 14px/1.2 "Mona Sans Variable", system-ui, sans-serif;
  color: var(--inchiostro);
  caret-color: var(--attivo);
}
.find__input::placeholder { color: var(--grigio-chiaro); }

.find__count {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  line-height: 1.2;
  color: var(--grigio);
  white-space: nowrap;
  flex: none;
}
.find__of { color: var(--grigio-chiaro); }
.roll { display: block; height: 1.2em; line-height: 1.2em; overflow: hidden; text-align: right; }
.roll__col { display: flex; flex-direction: column; }
.roll__col span { display: block; height: 1.2em; line-height: 1.2em; color: var(--inchiostro); font-weight: 600; }

.find__div { width: 1px; height: 18px; background: var(--linea); flex: none; }

.find__btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--inchiostro);
}
.find__btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.find__btn.is-press { background: rgba(24, 24, 27, 0.07); }
@media (hover: hover) {
  .find__btn:hover { background: rgba(24, 24, 27, 0.06); }
}

/* il binario a destra coi segni delle parole trovate, come nei browser */
.rail {
  position: absolute;
  top: 8px;
  right: 6px;
  bottom: 8px;
  width: 8px;
  border-radius: 4px;
}
.rail__thumb {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 0;
  border-radius: 2px;
  background: rgba(24, 24, 27, 0.14);
}
.rail__tick {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 1px;
  background: #f5c64a;
  transform-origin: right center;
}
.rail__tick.is-active { background: var(--attivo); height: 3px; }

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #ffffff;
  stroke: #18181b;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.28));
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}

@media (max-width: 420px) {
  .brand__name, .brand__sep { display: none; }
  .page { padding: 18px 26px 22px 16px; }
  .find { gap: 3px; padding-left: 9px; }
  .find__input { font-size: 13px; }
  .find__btn { width: 24px; height: 24px; }
}
