/* The palette kaleidoscope: a graphite card on a black page, a kaleidoscope with a knurled steel drum on the left,
   the words and the button on the right, the five swatches below. The five glass colours are the palette the demo's
   moodboard settles on; script.js paints the glass chips in shades of them and writes them on the swatches. */
:root {
  --page: #000000;          /* the page */
  --card: #111214;          /* the card */
  --edge: #25272b;          /* the card's thin edge */
  --ink: #f3f0ea;           /* the words */
  --muted: #8b8a86;         /* the quieter words */
  --well: #07080b;          /* the inside of the kaleidoscope, behind the glass */
  --backlight: #2a2f3a;     /* the soft light behind the glass, strongest in the middle */
  --steel-hi: #c9cdd3;      /* the drum: where it catches the light */
  --steel-lo: #1d1f23;      /* the drum: its dark side */
  --glass-1: #1f5d6e;       /* the palette: deep tide */
  --glass-2: #7fbca5;       /* the palette: sea glass */
  --glass-3: #e6b873;       /* the palette: driftwood */
  --glass-4: #d65f3e;       /* the palette: terracotta */
  --glass-5: #7a5288;       /* the palette: dusk */
  --done: #8fdcb0;          /* the tick of a finished palette */
  --error: #ff8a6b;         /* the words that say what went wrong */
  --button: #f3f0ea;        /* the button */
  --button-ink: #111214;    /* its words */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

/* ---------------------------------------------------------------- the card */
.pal {
  position: relative;
  width: min(388px, 100%);
  padding: 18px 18px 16px;
  border-radius: 26px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  isolation: isolate;
}

.pal__top {
  display: flex;
  gap: 16px;
}

/* ---------------------------------------------------------------- the kaleidoscope */
.pal__scope {
  --size: 184px;
  --ring: 9px;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* the drum: fine knurling that turns with the chamber */
.pal__knurl {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.16) 0deg 1.4deg, rgba(0, 0, 0, 0.32) 1.4deg 4deg),
    var(--steel-lo);
  will-change: transform;
}

/* the light on the drum stays where it is while the knurling turns under it */
.pal__scope::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--steel-hi) 70%, transparent) 0%, transparent 34%, transparent 66%, rgba(0, 0, 0, 0.55) 100%);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - var(--ring)), #000 calc(50% - var(--ring) + 0.5px));
  mask: radial-gradient(circle, transparent calc(50% - var(--ring)), #000 calc(50% - var(--ring) + 0.5px));
  pointer-events: none;
}

.pal__well {
  position: absolute;
  inset: var(--ring);
  z-index: 2;
  overflow: hidden;
  border-radius: 50%;
  background: var(--well);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8);
}

.pal__glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* the eyepiece's own glass: a soft reflection and a dark rim, over the picture */
.pal__lens {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(120% 70% at 30% 8%, rgba(255, 255, 255, 0.13), transparent 46%),
    radial-gradient(circle, transparent 62%, rgba(0, 0, 0, 0.55) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), inset 0 2px 6px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
.pal__words {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding-top: 2px;
}

.pal__title {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  font-stretch: 90%;
  line-height: 1.3;
  white-space: nowrap;
}

.pal__big {
  margin: 10px 0 0;
  font-size: 30px;
  font-weight: 620;
  font-stretch: 84%;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pal__status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 14px 0 0;
  font-size: 13.5px;
  font-weight: 580;
  font-stretch: 90%;
  line-height: 20px;
  white-space: nowrap;
}

.pal__sub {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  font-stretch: 92%;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pal__swap {
  display: inline-block;
}

.pal__swap .is-error {
  color: var(--error);
}

.pal__tick {
  flex: none;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--done);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  visibility: hidden;
}

/* ---------------------------------------------------------------- the button */
/* the site's elastic pill: the words widen on the width axis under the pointer, the pill squashes when pressed */
.pal__btn {
  position: relative;
  flex: none;
  height: 36px;
  margin-top: auto;
  padding: 0 17px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 620;
  line-height: 36px;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.pal__label {
  display: inline-block;
  font-stretch: 84%;
  transition: font-stretch 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* while the glass tumbles the button only says so: it steps back */
.pal__btn.is-quiet {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 14%, transparent);
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .pal__btn:not(.is-quiet):hover .pal__label {
    font-stretch: 100%;
  }

  .pal__btn:not(.is-quiet):hover {
    background: color-mix(in srgb, var(--button) 88%, var(--glass-3));
  }
}

.pal__btn:focus-visible {
  outline: 2px solid var(--glass-2);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the swatches */
.pal__swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.pal__slot {
  position: relative;
  min-width: 0;
}

/* the empty place of a swatch, before the palette is made */
.pal__slot::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 34px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.022);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* a swatch is a chip of the same glass: its colour, a lit top edge and a sheen across it */
.pal__chip {
  position: relative;
  display: block;
  height: 34px;
  border-radius: 11px;
  background-color: transparent;
  visibility: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 6px 14px -8px rgba(0, 0, 0, 0.9);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 42%, rgba(0, 0, 0, 0.14));
}

.pal__hex {
  display: block;
  height: 22px;
  padding-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 560;
  font-stretch: 92%;
  font-variation-settings: 'opsz' 96;
  line-height: 16px;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
}

/* on a narrow phone the kaleidoscope gives a little room to the words */
@media (max-width: 400px) {
  .pal {
    padding: 16px 16px 14px;
  }

  .pal__top {
    gap: 14px;
  }

  .pal__scope {
    --size: 164px;
    --ring: 8px;
  }

  .pal__big {
    font-size: 27px;
  }

  .pal__swatches {
    gap: 6px;
  }
}

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