/* The Generate image button with the preview that comes out of the noise. A near black page with a soft light from
   above and a fine grain; in the middle one pill of smoked glass. Inside, layered in one rounded box (.gi__body, moved
   only by GSAP): the glass fill, the wash of the picture's colours spreading from the tile, the light under the
   pointer, the reflection that crosses at the end and the 1px edge that catches the light. Then the row: the tile with
   the preview (a canvas) and its ring of light, two lines of words, and the end slot (spark and credits, percent,
   check). Under the button, the picture's colours on the floor. */
:root {
  --page: #09090b;            /* the page */
  --lift: #1c1a24;            /* the soft light from above, behind the button */
  --glass: #17161c;           /* the smoked glass of the button */
  --glass-low: #0f0e13;       /* the glass at the bottom */
  --ink: #f2f1f6;             /* the words */
  --muted: rgba(242, 241, 246, 0.5); /* the small line under the words */
  --beam: #ffd7b0;            /* the light that closes around the tile */
  --done: #b9f5cf;            /* the check */
  --img-a: #d9587e;           /* first colour of the picture (set by the script for each prompt) */
  --img-b: #ffa65c;           /* second colour of the picture */
}

* {
  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;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(min(80vw, 560px) min(50vh, 340px) at 50% 40%, color-mix(in srgb, var(--lift) 90%, transparent), transparent 72%),
    var(--page);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' 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.06 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

.gi {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

/* the picture's colours thrown on the floor under the button */
.gi__glow {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 104%;
  height: 46px;
  margin: -18px 0 0 -52%;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent 4%, color-mix(in srgb, var(--img-a) 70%, transparent) 30%, color-mix(in srgb, var(--img-b) 70%, transparent) 70%, transparent 96%);
  filter: blur(18px);
  opacity: 0.12;
  pointer-events: none;
}

.gi__btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.gi__btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--beam) 70%, white);
  outline-offset: 5px;
}

.gi__body {
  --mx: 30%;
  --my: 40%;
  position: relative;
  display: block;
  width: min(86vw, 312px);
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.85),
    0 8px 18px -10px rgba(0, 0, 0, 0.9),
    0 26px 50px -24px rgba(0, 0, 0, 1);
}

.gi__fill,
.gi__wash,
.gi__shine,
.gi__sweep,
.gi__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

/* the smoked glass: darker at the bottom, a soft lift at the top */
.gi__fill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 46%),
    linear-gradient(180deg, var(--glass), var(--glass-low));
  box-shadow: inset 0 -10px 18px -12px rgba(0, 0, 0, 0.8);
}

/* the picture's colours bleeding into the glass from the tile */
.gi__wash-light {
  position: absolute;
  left: -20%;
  top: -60%;
  width: 90%;
  height: 220%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--img-b) 50%, transparent), color-mix(in srgb, var(--img-a) 32%, transparent) 55%, transparent);
  filter: blur(6px);
  opacity: 0;
  transform-origin: 30% 50%;
}

/* the light under the pointer */
.gi__shine {
  opacity: 0;
  background: radial-gradient(120px 80px at var(--mx) var(--my), rgba(255, 255, 255, 0.11), transparent 70%);
}

/* the reflection that crosses the glass at the end */
.gi__sweep-band {
  position: absolute;
  top: -20%;
  left: 0;
  width: 34%;
  height: 140%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16) 45%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0.16) 55%, transparent);
}

/* the 1px edge: bright at the top, gone at the sides, a faint lip at the bottom */
.gi__edge {
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.05) 38%, rgba(255, 255, 255, 0.03) 70%, rgba(255, 255, 255, 0.1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.gi__row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 18px 0 8px;
  gap: 12px;
}

/* the tile with the preview */
.gi__tile {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
}

.gi__tile-face {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  overflow: hidden;
  background: #0c0b10;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 4px 10px -4px rgba(0, 0, 0, 0.9);
}

.gi__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* a glass gloss over the preview, light at the top left */
.gi__tile-gloss {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 40%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.gi__tile-flash {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.gi__tile-flash-band {
  position: absolute;
  top: -40%;
  left: 0;
  width: 46%;
  height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55) 50%, transparent);
  mix-blend-mode: overlay;
}

/* the ring of light around the tile, a little outside it */
.gi__ring {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 52px;
  height: 52px;
  overflow: visible;
  pointer-events: none;
}

.gi__ring-track,
.gi__ring-run {
  fill: none;
  stroke-width: 1.2;
}

.gi__ring-track {
  stroke: rgba(255, 255, 255, 0);
}

.gi__ring-run {
  stroke: var(--beam);
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  opacity: 0;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--beam) 80%, transparent));
}

/* the words */
.gi__text {
  position: relative;
  text-align: left;
  flex: 1;
  min-width: 0;
  height: 38px;
}

.gi__state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.gi__title,
.gi__sub {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gi__title {
  font-size: 15px;
  line-height: 1.15;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.005em;
}

.gi__title--busy {
  color: transparent;
  background: linear-gradient(90deg, var(--ink) 0%, var(--ink) 35%, #ffffff 48%, var(--beam) 52%, var(--ink) 65%, var(--ink) 100%);
  background-size: 250% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
}

.gi__sub {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 450;
  color: var(--muted);
}

.gi__num {
  font-weight: 550;
  color: rgba(242, 241, 246, 0.82);
}

/* the end slot: spark and credits, then the percent, then the check */
.gi__end {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
}

.gi__end-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.gi__spark {
  width: 14px;
  height: 14px;
  fill: var(--beam);
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--beam) 50%, transparent));
}

.gi__cost {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
}

.gi__pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.gi__pct-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: -2px;
}

.gi__check {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--done);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--done) 45%, transparent));
}

.gi__check path {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}

@media (hover: hover) {
  .gi__btn {
    cursor: pointer;
  }
}

@media (max-width: 360px) {
  .gi__row {
    gap: 10px;
    padding-right: 14px;
  }
  .gi__end {
    width: 38px;
  }
}
