:root {
  --fondo: #ffffff;
  --card: #ffffff;
  --inchiostro: #111113;
  --grigio: #6f6f77;
  --grigio-chiaro: #a1a1aa;
  --bordo: rgba(17, 17, 19, 0.09);
  --riga: rgba(17, 17, 19, 0.06);
  --campo: #f4f4f5;
  --accento: #5b5bd6;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 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;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

/* the invisible frame of the preview: the page plus the open menu, measured at 1320x880 (from 30vh above the middle to 38vh below) */
.cornice { position: absolute; left: 50%; top: calc(50% - 30vh); width: min(520px, calc(100% - 32px)); height: 68vh; transform: translateX(-50%); pointer-events: none; visibility: hidden; }

/* the page */
.doc {
  position: relative;
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  padding: clamp(16px, 4.4vmin, 28px) clamp(18px, 5vmin, 32px) clamp(18px, 5vmin, 30px);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 22px 56px -24px rgba(17, 17, 19, 0.18);
  cursor: text;
}

.doc__crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--grigio-chiaro);
  font-variation-settings: "wdth" 100;
}
.doc__crumbs svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.doc__title {
  margin-top: clamp(6px, 1.6vmin, 12px);
  font-size: clamp(20px, 5.4vmin, 26px);
  font-weight: 640;
  letter-spacing: -0.02em;
  font-variation-settings: "wdth" 96;
}

.doc__para {
  margin-top: clamp(4px, 1.2vmin, 8px);
  font-size: clamp(13px, 3.4vmin, 15px);
  line-height: 1.5;
  color: var(--grigio);
}

.doc__lines { margin-top: clamp(6px, 1.6vmin, 10px); }

/* a block of the page: GSAP moves the block, CSS styles its children */
.blocco {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: clamp(26px, 6.6vmin, 30px);
  font-size: clamp(13.5px, 3.5vmin, 15px);
  line-height: 1.45;
  border-radius: 6px;
}
.blocco__testo { white-space: pre; }
.blocco__corpo { position: relative; display: inline-flex; align-items: center; min-height: 1.45em; }

.blocco__vuoto {
  position: absolute;
  left: 2px;
  white-space: nowrap;
  color: var(--grigio-chiaro);
  pointer-events: none;
}

/* the slash and what follows it, while the menu is open */
.blocco__cerca {
  white-space: pre;
  color: var(--accento);
  background: var(--accento-tenue, rgba(91, 91, 214, 0.09));
  border-radius: 4px;
  padding: 0 2px;
  margin: 0 -1px;
}

.cursore {
  display: inline-block;
  width: 1.5px;
  height: 1.15em;
  margin-left: 1px;
  background: var(--inchiostro);
  border-radius: 1px;
  vertical-align: middle;
}
.cursore.lampeggia { animation: lampeggio 1.05s steps(1) infinite; }
@keyframes lampeggio { 50% { opacity: 0; } }

/* the blocks the menu makes */
.blocco[data-tipo="heading"] { font-size: clamp(17px, 4.5vmin, 20px); font-weight: 640; letter-spacing: -0.015em; min-height: clamp(32px, 8vmin, 38px); }

.spunta {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid rgba(17, 17, 19, 0.28);
  background: #fff;
  padding: 0;
  cursor: pointer;
}
.spunta svg { position: absolute; inset: -1.5px; width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.spunta__fondo { position: absolute; inset: -1.5px; border-radius: 5px; background: var(--accento); transform: scale(0); }
.blocco__barra { position: absolute; left: 0; right: 0; top: 52%; height: 1.5px; background: var(--grigio-chiaro); transform-origin: left center; transform: scaleX(0); }
.blocco.fatto .blocco__testo { color: var(--grigio-chiaro); }

.blocco[data-tipo="quote"] { padding-left: 14px; font-size: clamp(14px, 3.7vmin, 16px); font-weight: 520; }
.blocco__regola { position: absolute; left: 0; top: 3px; bottom: 3px; width: 2.5px; border-radius: 2px; background: var(--inchiostro); transform-origin: center top; }

.blocco[data-tipo="callout"] { padding: 6px 10px; background: var(--campo); border-radius: 10px; }
.blocco[data-tipo="callout"] .blocco__icona { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--accento); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.blocco[data-tipo="code"] { padding: 6px 10px; background: var(--campo); border-radius: 8px; font-family: var(--mono); font-size: 12.5px; }

.blocco[data-tipo="divider"] { min-height: 18px; }
.blocco__linea { flex: 1; height: 1px; background: rgba(17, 17, 19, 0.14); transform-origin: left center; }

.blocco[data-tipo="image"] .blocco__foto,
.blocco[data-tipo="table"] .blocco__foto {
  flex: 1;
  height: clamp(44px, 12vmin, 64px);
  border-radius: 10px;
  background: var(--campo);
  border: 1px dashed rgba(17, 17, 19, 0.16);
  display: grid;
  place-items: center;
  color: var(--grigio);
  font-size: 12px;
}

/* the menu */
.menu {
  position: absolute;
  z-index: 5;
  width: min(278px, calc(100% - 24px));
  background: #fff;
  border: 1px solid var(--bordo);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.05), 0 12px 32px -8px rgba(17, 17, 19, 0.2), 0 28px 60px -30px rgba(17, 17, 19, 0.25);
  overflow: hidden;
  cursor: default;
}
.menu[hidden] { display: none; }

.menu__list {
  position: relative;
  max-height: clamp(150px, 40vh, 300px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 6px;
}
.menu__list::-webkit-scrollbar { display: none; }

.menu__pill {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  height: 40px;
  border-radius: 9px;
  background: var(--campo);
  pointer-events: none;
}
.menu__ghosts { position: absolute; inset: 0; pointer-events: none; }

.menu__gruppo {
  position: relative;
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--grigio-chiaro);
}

.voce {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 5px 8px;
  border: 0;
  background: none;
  border-radius: 9px;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.voce__icona {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--bordo);
  background: #fff;
  box-shadow: 0 1px 1px rgba(17, 17, 19, 0.04);
}
.voce__icona svg { width: 15px; height: 15px; fill: none; stroke: var(--inchiostro); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.voce__testi { flex: 1; min-width: 0; }
.voce__nome { display: block; font-size: 13px; font-weight: 540; line-height: 1.25; }
.voce__nome mark { background: none; color: var(--accento); font-weight: 680; }
.voce__desc { display: block; font-size: 11px; color: var(--grigio-chiaro); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

kbd {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  border: 1px solid var(--bordo);
  border-bottom-width: 2px;
  background: #fff;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--grigio);
}
kbd svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.voce__flash { position: absolute; inset: 0; border-radius: 9px; background: var(--accento); opacity: 0; pointer-events: none; }

.menu__empty { display: none; padding: 18px 16px 16px; text-align: center; }
.menu.vuoto .menu__empty { display: block; }
.menu.vuoto .menu__list { padding: 0; }
.menu__empty-title { font-size: 13px; font-weight: 560; }
.menu__empty-title span { color: var(--accento); }
.menu__empty-hint { margin-top: 3px; font-size: 11.5px; color: var(--grigio); }
.menu__empty-hint em { font-style: normal; font-family: var(--mono); font-size: 11px; padding: 1px 4px; border-radius: 4px; background: var(--campo); color: var(--inchiostro); }

.menu__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-top: 1px solid var(--riga);
  background: #fcfcfc;
  font-size: 11px;
  color: var(--grigio-chiaro);
}
.menu__keys { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.menu__keys kbd { min-width: 18px; height: 18px; padding: 0 3px; }
.menu__keys span { margin: 0 4px 0 1px; }
.menu__count { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--grigio); }
.menu__count-num { position: relative; display: inline-block; overflow: hidden; min-width: 1ch; height: 1.25em; line-height: 1.25em; text-align: right; }
.menu__count-num span { display: block; }

@media (hover: hover) {
  .spunta:hover { border-color: rgba(17, 17, 19, 0.45); }
}

/* the hidden field that brings up the phone keyboard and catches the keys */
.tasti {
  position: fixed;
  left: -200px;
  top: 0;
  width: 10px;
  height: 10px;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}

@media (max-width: 420px) {
  .doc__para { display: none; }
  .menu__keys span:first-of-type { display: none; }
}

/* on tall screens the page sits higher, so the page and the open menu are centred together */
@media (min-height: 560px) {
  .doc { margin-bottom: min(26vh, 260px); }
}
