/* The Rollback button with the regions going back to the last version. A dark glass panel on a black page: a
   gradient body, a 1px edge that catches the light from above, a fine grain. GSAP moves the button's fill, the
   comets on the lines and the words; the CSS draws them. */
:root {
  --page: #000000;                        /* the page */
  --glass-top: rgba(30, 31, 36, 0.94);    /* the glass, at the top */
  --glass-bottom: rgba(14, 15, 18, 0.98); /* the glass, at the bottom */
  --edge: rgba(235, 240, 255, 0.09);      /* the 1px border */
  --ink: #eef0f4;                         /* the words */
  --muted: #8b8f9b;                       /* the small words */
  --faint: #5b5f6a;                       /* the region codes */
  --track: rgba(235, 240, 255, 0.07);     /* the empty lines */
  --warn: #f59e5b;                        /* the broken version, the errors */
  --ok: #5eead4;                          /* the good version, the light that runs back */
  --button: #f2f3f6;                      /* the button at rest */
  --button-ink: #0b0c0f;                  /* the words on the button */
}

* { box-sizing: border-box; }
html { touch-action: manipulation; }
html, body { margin: 0; overflow-x: clip; }
body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
.mono { font-family: 'Geist Mono Variable', ui-monospace, monospace; letter-spacing: -0.01em; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

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

/* ------------------------------------------------------------------ the panel */
.card {
  position: relative;
  width: min(420px, 92vw);
  padding: clamp(14px, 3.6vmin, 20px);
  border-radius: 22px;
  background:
    radial-gradient(90% 70% at 100% 0%, rgba(245, 158, 91, var(--heat, 0.09)) 0%, transparent 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(94, 234, 212, var(--calm, 0)) 0%, transparent 62%),
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 1px rgba(0, 0, 0, 0.7),
    0 14px 30px -10px rgba(0, 0, 0, 0.9),
    0 40px 90px -30px rgba(94, 234, 212, var(--calm-shadow, 0.06));
  opacity: 0;
}
.card::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
.card::after {
  content: '';
  position: absolute; left: 10%; right: 10%; top: 0; height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
}

/* ------------------------------------------------------------------ the head */
.head { display: flex; align-items: center; gap: 11px; }
.mark {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(180deg, #2a2c33, #17181c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 10px -4px rgba(0, 0, 0, 0.8);
}
.mark svg { width: 19px; height: 19px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.head__name { min-width: 0; flex: 1; }
.head__title { font-size: 15px; font-weight: 640; letter-spacing: -0.01em; }
.head__sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.head__sub .mono { display: inline-block; color: var(--warn); font-size: 11.5px; margin-left: 3px; }

.errs {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.errs__spark { width: 52px; height: 22px; overflow: visible; }
.errs__line { fill: none; stroke: var(--spark, var(--warn)); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.errs__area { fill: var(--spark, var(--warn)); opacity: 0.14; }
.errs__text { display: grid; line-height: 1.05; text-align: right; }
.errs__num { font-size: 13px; font-weight: 600; color: var(--spark, var(--warn)); }
.errs__label { font-size: 10.5px; color: var(--muted); }

/* ------------------------------------------------------------------ the regions */
.regions {
  list-style: none;
  margin: 14px -8px 14px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.region {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(18px, 1fr) 46px 60px;
  align-items: center;
  gap: 10px;
  height: clamp(30px, 7.4vh, 36px);
  padding: 0 8px;
  border-radius: 9px;
  transition: background-color 0.25s ease;
}
@media (hover: hover) {
  .region:hover { background: rgba(255, 255, 255, 0.035); }
}
.region__name { font-size: 13px; font-weight: 540; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.region__name .mono { font-size: 11px; color: var(--faint); margin-left: 4px; font-weight: 400; }

.region__line {
  position: relative;
  height: 1px;
  background: var(--track);
  overflow: visible;
}
/* the part the light has already crossed: it stays lit, very softly */
.region__glow {
  position: absolute; inset: 0;
  background: linear-gradient(270deg, rgba(94, 234, 212, 0.55), rgba(94, 234, 212, 0.18));
  transform-origin: 100% 50%;
  transform: scaleX(0);
}
/* the comet: a short bright head with its tail behind, running from right to left */
.region__comet {
  position: absolute; top: -1px;
  right: calc(var(--p, 0) * (100% - min(34px, 70%)));
  width: min(34px, 70%); height: 3px;
  border-radius: 3px;
  background: linear-gradient(270deg, rgba(94, 234, 212, 0) 0%, rgba(94, 234, 212, 0.55) 55%, #e9fffb 100%);
  filter: drop-shadow(0 0 4px rgba(94, 234, 212, 0.7));
  opacity: 0;
}

.region__ms { font-size: 11.5px; color: var(--muted); text-align: right; white-space: nowrap; }
.ver {
  position: relative;
  height: 22px;
  border-radius: 7px;
  overflow: hidden;
  font-size: 11.5px;
  background: rgba(245, 158, 91, 0.1);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 91, 0.22);
  color: var(--warn);
}
.ver { transition: background-color 0.35s ease, box-shadow 0.35s ease, color 0.35s ease; }
.ver.is-ok {
  background: rgba(94, 234, 212, 0.09);
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.24);
  color: var(--ok);
}
.ver__in {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ the button */
.rb {
  --mx: 50%;
  position: relative;
  display: block;
  width: 100%;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  overflow: hidden;
  cursor: pointer;
  color: var(--button-ink);
  font: inherit;
  background: linear-gradient(180deg, #ffffff, var(--button));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 10px 22px -10px rgba(255, 255, 255, 0.22);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.rb:focus-visible { box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--ok); }
.rb.is-busy, .rb.is-done { cursor: default; }

/* the dark body that the busy and done faces sit on; GSAP fades it in over the light button */
.rb__fill {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #1d1f25, #121317);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0;
}
.rb.is-done .rb__fill { box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -18px 30px -24px rgba(94, 234, 212, 0.35); transition: box-shadow 0.5s ease; }
/* the light that follows the pointer along the top of the button */
.rb__shine {
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120px 46px at var(--mx) 0%, rgba(255, 255, 255, 0.9), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  mix-blend-mode: soft-light;
}
@media (hover: hover) {
  .rb:not(.is-busy):not(.is-done):hover .rb__shine { opacity: 1; }
}

.rb__face {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap;
}
.rb__face--idle { justify-content: center; }
.rb__face--idle .mono { font-weight: 500; }
.rb__face--busy, .rb__face--done { color: var(--ink); visibility: hidden; opacity: 0; }
.rb__face--done .ico { stroke: var(--ok); }
.rb__words { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.rb__words .mono { font-weight: 500; }
.rb__clock { font-size: 12px; color: var(--muted); font-weight: 500; }

.where {
  position: relative;
  display: inline-block;
  height: 20px;
  min-width: 86px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 520;
}
.where__in { position: absolute; left: 0; top: 1.5px; line-height: 20px; white-space: nowrap; }

.ico { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 380px) {
  .region { gap: 7px; grid-template-columns: minmax(0, auto) minmax(14px, 1fr) 42px 56px; }
  .region__name .mono { display: none; }
  .rb__face { padding: 0 14px; font-size: 13.5px; gap: 8px; }
  .errs__spark { width: 40px; }
  .where { min-width: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  .rb__shine, .region { transition: none; }
}
