/* The certificate that assembles from the last lesson: the final lesson card of a made-up online type school,
   Kernwell, grows into its certificate of completion. One box (.carta) changes size; inside it the lesson and the
   certificate are two layers, centred, each at its own fixed width. The certificate is sized in container units,
   so it is the same drawing at any width. */
:root {
  --fondo: #eeeae2;        /* the page */
  --card: #ffffff;         /* the lesson card */
  --carta: #fbf8f0;        /* the paper of the certificate */
  --inchiostro: #1c2a45;   /* the ink: words, pill, ticks */
  --grigio: #7b8191;       /* the small words */
  --linea: rgba(28, 42, 69, 0.1); /* thin lines */
  --oro: #b08a3e;          /* the gold of the foil and the frame */
  --verde: #2f6b55;        /* the done ticks */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
  perspective: 1400px;
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 70%),
    var(--fondo);
}

.gruppo {
  position: relative;
  opacity: 0;
  transform-style: preserve-3d;
}

/* the one box that changes size */
.carta {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  box-shadow:
    0 0 0 1px rgba(28, 42, 69, 0.07),
    0 1px 2px rgba(28, 42, 69, 0.05),
    0 8px 18px -8px rgba(28, 42, 69, 0.12),
    0 34px 64px -28px rgba(28, 42, 69, 0.28);
}

/* the paper of the certificate fades in over the white as the box grows */
.carta__carta {
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    radial-gradient(90% 70% at 30% 20%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, #fdfbf5, var(--carta) 55%, #f4eee1);
}

.carta__carta::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* both layers sit in the middle of the box */
.lez,
.cert {
  position: absolute;
  left: 50%;
  top: 50%;
}

/* ---- the lesson ---- */
.lez {
  padding: clamp(16px, min(5vw, 3.6vh), 22px);
}

.lez__testa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.marca {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 640;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}

.marca__segno {
  width: 22px;
  height: 22px;
  flex: none;
  fill: var(--inchiostro);
  stroke: none;
}

.marca__segno path {
  fill: none;
  stroke: #fff;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lez__tag {
  font-size: 11.5px;
  font-weight: 560;
  color: var(--inchiostro);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(176, 138, 62, 0.13);
  box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.22);
}

.lez__corso {
  margin: clamp(12px, 2.4vh, 18px) 0 3px;
  font-size: 12.5px;
  color: var(--grigio);
}

.lez__titolo {
  margin: 0;
  font-size: clamp(19px, min(5.6vw, 3.6vh), 23px);
  line-height: 1.15;
  font-weight: 660;
  letter-spacing: -0.02em;
}

.avanz {
  margin-top: clamp(12px, 2.4vh, 18px);
}

.avanz__riga {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--grigio);
}

.avanz__n {
  color: var(--inchiostro);
  font-weight: 620;
}

.avanz__barra {
  position: relative;
  height: 6px;
  margin-top: 7px;
  border-radius: 999px;
  background: rgba(28, 42, 69, 0.08);
  overflow: hidden;
}

.avanz__pieno {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2c3d60, var(--inchiostro));
  transform-origin: 0 50%;
  transform: scaleX(0.96);
}

.compiti {
  list-style: none;
  margin: clamp(10px, 2vh, 14px) 0 0;
  padding: 0;
}

.compito {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(6px, 1.25vh, 9px) 0;
  font-size: 13.5px;
  border-top: 1px solid var(--linea);
}

.compito:first-child {
  border-top: 0;
}

.tondo {
  width: 20px;
  height: 20px;
  flex: none;
}

.tondo svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tondo__anello {
  fill: none;
  stroke: rgba(28, 42, 69, 0.25);
  stroke-width: 1.5;
}

.tondo__pieno {
  fill: var(--verde);
}

.tondo__spunta {
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 12;
  stroke-dashoffset: 12;
}

.compito.is-fatto .tondo__spunta {
  stroke-dashoffset: 0;
}

.compito__nome {
  flex: 1;
  min-width: 0;
}

.compito.is-fatto .compito__nome {
  color: var(--grigio);
}

.compito__t {
  font-size: 12px;
  color: var(--grigio);
}

/* ---- the pills: the box under the words swells, the words widen on the wdth axis ---- */
.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  isolation: isolate;
}

.pill__fondo {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
}

.pill--ink {
  color: #fff;
}

.pill--ink .pill__fondo {
  background: linear-gradient(180deg, #2a3a5c, var(--inchiostro));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 2px rgba(28, 42, 69, 0.3),
    0 8px 18px -8px rgba(28, 42, 69, 0.55);
}

.pill--chiara .pill__fondo {
  background: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(28, 42, 69, 0.1),
    0 1px 2px rgba(28, 42, 69, 0.06),
    0 8px 18px -10px rgba(28, 42, 69, 0.25);
}

.pill--larga {
  display: flex;
  width: 100%;
  margin-top: clamp(12px, 2.4vh, 18px);
  height: clamp(40px, 6vh, 44px);
}

.pill__testo {
  display: inline-block;
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
}

.pill__giro,
.pill__ok {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  opacity: 0;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill__giro circle {
  stroke-dasharray: 32 48;
}

.pill__ok path {
  stroke-dasharray: 15;
  stroke-dashoffset: 15;
}

.pill__icona {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.pdf__traccia {
  stroke: rgba(28, 42, 69, 0.14);
  opacity: 0;
}

.pdf__arco {
  stroke-dasharray: 44;
  stroke-dashoffset: 44;
  transform-origin: 10px 10px;
  transform: rotate(-90deg);
}

.pdf__ok {
  stroke-dasharray: 12;
  stroke-dashoffset: 12;
}

/* ---- the certificate, drawn in container units ---- */
.cert {
  container-type: inline-size;
  opacity: 0;
  visibility: hidden;
}

.cert__cornice,
.cert__rosa {
  position: absolute;
  pointer-events: none;
}

.cert__cornice {
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
}

.cornice__fuori {
  stroke: var(--oro);
  stroke-width: 2.4;
  opacity: 0.75;
}

.cornice__dentro {
  stroke: var(--oro);
  stroke-width: 1;
  opacity: 0.5;
}

/* the faint guilloché rose behind the name */
.cert__rosa {
  left: 50%;
  top: 44%;
  width: 62cqw;
  height: 62cqw;
  margin: -31cqw 0 0 -31cqw;
  fill: none;
  stroke: var(--oro);
  stroke-width: 0.35;
  opacity: 0.24;
}

.cert__corpo {
  position: absolute;
  inset: 0;
  padding: 6.4cqw 7.2cqw 6cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cert__testa {
  align-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.95cqw;
}

.marca--cert {
  font-size: 2.15cqw;
  gap: 1.3cqw;
}

.marca--cert .marca__segno {
  width: 3.5cqw;
  height: 3.5cqw;
}

.cert__id {
  color: var(--grigio);
  letter-spacing: 0.02em;
}

.cert__codice {
  color: var(--inchiostro);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.cert__kicker {
  margin: 5.2cqw 0 0;
  font-size: 1.9cqw;
  font-weight: 620;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--oro);
  font-variation-settings: 'wdth' 112;
}

.cert__piccolo {
  margin: 2.2cqw 0 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-style: italic;
  font-size: 2.4cqw;
  color: var(--grigio);
}

.cert__nome {
  margin: 0.8cqw 0 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-weight: 400;
  font-size: 8.6cqw;
  line-height: 1.08;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.cert__nome .l {
  display: inline-block;
  font-variation-settings: 'opsz' 144, 'SOFT' 50, 'wght' 560;
}

.cert__corso {
  margin: 1.2cqw 0 0;
  font-size: 2.35cqw;
  color: var(--grigio);
}

.cert__corso em {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-style: italic;
  font-weight: 560;
  color: var(--inchiostro);
}

.cert__dati {
  display: flex;
  justify-content: center;
  gap: 5.4cqw;
  margin-top: 4cqw;
  padding-top: 2.6cqw;
  border-top: 1px solid rgba(176, 138, 62, 0.28);
}

.dato {
  display: flex;
  flex-direction: column;
  gap: 0.5cqw;
}

.dato b {
  font-size: 2.35cqw;
  font-weight: 640;
}

.dato small {
  font-size: 1.7cqw;
  color: var(--grigio);
}

.cert__piede {
  margin-top: auto;
  align-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.firma {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 27cqw;
}

.firma__segno {
  width: 24cqw;
  height: auto;
  margin-bottom: -0.8cqw;
  fill: none;
  stroke: var(--inchiostro);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.firma__linea {
  display: block;
  width: 100%;
  height: 1px;
  background: rgba(28, 42, 69, 0.35);
  transform-origin: 0 50%;
}

.firma__chi {
  margin-top: 1cqw;
  font-size: 1.75cqw;
  color: var(--grigio);
  white-space: nowrap;
}

.sigillo {
  position: relative;
  width: 15cqw;
  height: 15cqw;
  margin: 0 1cqw -0.6cqw 0;
  filter: drop-shadow(0 0.25cqw 0.35cqw rgba(110, 80, 20, 0.35)) drop-shadow(0 1.2cqw 1.6cqw rgba(110, 80, 20, 0.18));
}

.sigillo__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sigillo__anello {
  fill: none;
  stroke: rgba(255, 246, 220, 0.75);
  stroke-width: 0.8;
}

.sigillo__anello--fine {
  stroke: rgba(105, 75, 20, 0.5);
  stroke-width: 0.6;
}

.sigillo__scritta {
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: 5.6px;
  font-weight: 650;
  letter-spacing: 0.9px;
  fill: rgba(90, 62, 14, 0.78);
}

.sigillo__k {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 27px;
  font-weight: 640;
  fill: #7a5718;
  paint-order: stroke;
  stroke: rgba(255, 240, 200, 0.55);
  stroke-width: 0.6;
}

/* the dent the stamp leaves in the paper */
.sigillo__solco {
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  border: 1px solid rgba(176, 138, 62, 0.45);
  opacity: 0;
}

/* the light that follows the pointer over the paper */
.cert__luce {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(40% 50% at var(--mx, 50%) var(--my, 40%), rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 70%);
  mix-blend-mode: soft-light;
}

/* ---- the two actions under the certificate ---- */
.azioni {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 12px);
  display: flex;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.azioni .pill {
  opacity: 0;
  height: 38px;
  padding: 0 15px;
  font-size: 13px;
}

.azioni .pill--tondo {
  width: 38px;
  padding: 0;
}

.azioni.is-su {
  pointer-events: auto;
}

.cursore {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 20;
  fill: #fff;
  stroke: var(--inchiostro);
  stroke-width: 1.4;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(28, 42, 69, 0.3));
}

@media (prefers-reduced-motion: reduce) {
  .cursore {
    display: none;
  }
}
