/* The light mode button: a pill with a moon that turns into a sun; the page goes from night to day. */
:root {
  /* the night theme (the start) */
  --fondo: #000000;
  --carta: #0d0d0e;
  --bordo: rgba(255, 255, 255, 0.09);
  --testo: #f3f1ec;
  --testo-2: #9c9890;
  --testo-3: #5d5a55;
  --pill: #17171a;
  --pill-bordo: rgba(255, 255, 255, 0.12);
  --pill-testo: #f3f1ec;
  --ombra: 0, 0, 0;
  --ombra-forza: 0.6;
  /* the single accent: the warm sun and the edge of the light */
  --accento: #f6a623;
  --luce-giorno: #ffffff;
  --luce-orlo: rgba(255, 196, 112, 0.55);
  --notte: #000000;
  --notte-orlo: rgba(88, 104, 160, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-size: clamp(10px, min(3.9vw, 3.3vh), 17px); background: var(--fondo); }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* the light: a circle centred on the icon, scaled from nothing to cover the farthest corner */
.flood {
  position: fixed;
  left: 0; top: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  pointer-events: none;
  transform: scale(0);
  z-index: 0;
  will-change: transform;
}

.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.6em;
  padding: 2vh 4vw;
}

.group { display: grid; place-items: center; gap: 1.6em; }

/* the example page: a small card that takes the theme */
.note {
  position: relative;
  width: min(19em, 88vw);
  padding: 1.15em 1.3em 1.25em;
  border-radius: 1.2em;
  background: var(--carta);
  box-shadow:
    0 0 0 1px var(--bordo),
    0 1px 2px rgba(var(--ombra), calc(var(--ombra-forza) * 0.25)),
    0 10px 24px -10px rgba(var(--ombra), calc(var(--ombra-forza) * 0.5)),
    0 30px 60px -30px rgba(var(--ombra), calc(var(--ombra-forza) * 0.6));
}
.note__edge {
  position: absolute; inset: 0 1.2em auto; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
}
.note__kicker {
  display: block;
  font-size: 0.72em;
  font-weight: 560;
  letter-spacing: 0.04em;
  color: var(--testo-3);
  margin-bottom: 0.55em;
}
.note__title {
  font-size: 1.38em;
  line-height: 1.1;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  margin-bottom: 0.45em;
}
.note__line { font-size: 0.86em; line-height: 1.45; color: var(--testo-2); }
.note__line--short { color: var(--testo-3); }

/* the pill: the body is a separate layer so it can swell without moving the label */
.pill {
  position: relative;
  display: inline-grid;
  place-items: center;
  height: 3em;
  padding: 0 1.2em;
  border-radius: 999px;
  color: var(--pill-testo);
  isolation: isolate;
  outline: none;
}
.pill__bg {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--pill);
  box-shadow:
    inset 0 0 0 1px var(--pill-bordo),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(var(--ombra), calc(var(--ombra-forza) * 0.3)),
    0 8px 18px -8px rgba(var(--ombra), calc(var(--ombra-forza) * 0.55));
  z-index: -1;
}
/* the thread of light that passes along the edge after a change */
.pill__shine {
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(100deg, transparent 30%, var(--accento) 50%, transparent 70%) -120% 0 / 220% 100% no-repeat;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}
.pill:focus-visible .pill__bg { box-shadow: inset 0 0 0 1px var(--pill-bordo), 0 0 0 3px color-mix(in srgb, var(--accento) 55%, transparent); }

/* icon and label sit in one row whose width never changes: both labels are absolute in a fixed box */
.pill__in { display: flex; align-items: center; gap: 0.6em; }
.icon {
  width: 1.3em; height: 1.3em;
  display: block;
  overflow: visible;
  flex: none;
}
.icon__body { fill: var(--pill-testo); }
.icon line { stroke: var(--accento); stroke-width: 1.9; stroke-linecap: round; }
.pill__labels {
  position: relative;
  display: block;
  height: 1.3em;
  /* clipped only above and below, so the labels can roll in and out but never lose a letter at the side */
  clip-path: inset(0 -1em);
}
.pill__label {
  position: absolute;
  left: 50%; top: 50%;
  white-space: nowrap;
  font-size: 0.98em;
  font-weight: 600;
  font-stretch: 100%;
  line-height: 1;
}
.pill__label + .pill__label { opacity: 0; }

/* the day theme, set at the end of the change (and at once with reduced motion) */
html.chiaro {
  --fondo: #ffffff;
  --carta: #ffffff;
  --bordo: rgba(20, 18, 14, 0.09);
  --testo: #15130f;
  --testo-2: #5f5b54;
  --testo-3: #a29d95;
  --pill: #15130f;
  --pill-bordo: rgba(255, 255, 255, 0.06);
  --pill-testo: #ffffff;
  --ombra: 40, 30, 16;
  --ombra-forza: 0.32;
}

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