/* 540 frame. The photograph is the ground; the control sits on the empty paper under the mug. */
@property --gz-wipe {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 100%;
}

.gz {
  --ink: #2a1206;
  --chip: #f3e9dc;
  --chip-ink: #5a2a12;
  position: relative;
  width: 540px;
  height: 540px;
  overflow: hidden;
  background: #ef4008;
  color: #fff3e2;
  font-family: "Hanken Grotesk Variable", sans-serif;
  user-select: none;
}

.gz[data-glaze="celadon"] { --chip: #a9c5a2; --chip-ink: #1c3323; }
.gz[data-glaze="tenmoku"] { --chip: #2a150b; --chip-ink: #f6c79b; }
.gz[data-glaze="shino"] { --chip: #f3e9dc; --chip-ink: #6b2c0f; }
.gz[data-glaze="cobalt"] { --chip: #1b3aa8; --chip-ink: #e9efff; }

.gz * { box-sizing: border-box; }

.gz-photo {
  position: absolute;
  inset: 0;
  width: 540px;
  height: 540px;
  display: block;
  visibility: hidden;
}

.gz-photo[data-layer="under"] { visibility: visible; z-index: 1; }

/* The new glaze is revealed across the mug by an edge that travels with the indicator: same direction,
   same curve, same 540 ms. The mug's body and handle sit between 19.5% and 78.6% of the width, and the
   paper outside is the same in every photograph, so the edge runs 17% to 82% and then lets go. */
.gz-photo[data-layer="in"] {
  --edge: calc(17% + var(--gz-wipe) * 0.65 + max(0%, var(--gz-wipe) - 99.9%) * 4000);
  visibility: visible;
  z-index: 2;
  mask-image: linear-gradient(90deg, #000 calc(var(--edge) - 0.75%), transparent var(--edge));
  animation: gz-wipe 540ms cubic-bezier(0.25, 0.1, 0.6, 1) both;
}

.gz[data-dir="left"] .gz-photo[data-layer="in"] {
  --edge: calc(18% + var(--gz-wipe) * 0.65 + max(0%, var(--gz-wipe) - 99.9%) * 4000);
  mask-image: linear-gradient(270deg, #000 calc(var(--edge) - 0.75%), transparent var(--edge));
}

@keyframes gz-wipe {
  from { --gz-wipe: 0%; }
  to { --gz-wipe: 100%; }
}

/* the selected glaze, described: helper text set on the control's own left edge */
.gz-note {
  position: absolute;
  z-index: 3;
  left: 46px;
  top: 382px;
  margin: 0;
  font-size: 21px;
  line-height: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 80ms linear;
}

.gz-note[data-on] { opacity: 1; transition: opacity 200ms ease-out 80ms; }

.gz-control {
  position: absolute;
  z-index: 3;
  left: 20px;
  top: 426px;
  width: 500px;
  height: 92px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  border-radius: 46px;
  background: #7a140066;
}

.gz-item,
.gz-over span {
  display: grid;
  place-items: center;
  height: 80px;
  padding: 0 0 2px;
  font-family: "Instrument Serif", serif;
  font-size: 29px;
  line-height: 34px;
  font-weight: 400;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.gz-item {
  border: 0;
  border-radius: 40px;
  background: none;
  color: inherit;
  outline: none;
  cursor: pointer;
}

.gz-item:focus-visible { box-shadow: inset 0 0 0 3px #fff3e2; }

/* The indicator is a full-size layer in the glaze's colour, clipped to a pill over the checked item. */
.gz-indicator {
  --l: var(--segmented-control-indicator-left);
  --r: calc(100% - var(--segmented-control-indicator-left) - var(--segmented-control-indicator-width));
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 46px;
  background: var(--chip);
  clip-path: inset(6px var(--r) 6px var(--l) round 40px);
  pointer-events: none;
  transition:
    clip-path 540ms cubic-bezier(0.25, 0.1, 0.6, 1),
    background-color 200ms linear;
}

.gz-over {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  color: var(--chip-ink);
  transition: color 0s linear 110ms;
}
