:root {
  --fondo: #f4f2ee;          /* the warm white behind the card */
  --carta: #fffdfa;
  --bordo: rgba(36, 30, 24, 0.07);
  --linea: #ece7e0;
  --testo: #1a1816;
  --testo-2: #6d6862;
  --testo-3: #a8a299;
  --accento: #ff5a36;        /* the one accent: the marker ring, the copied tick, the active swatch line */
  --velo: #efece7;           /* the grey that covers the zones that are not the chosen colour */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
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; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 3vh, 28px) 14px;
  background: radial-gradient(120% 80% at 50% 0%, #faf9f6 0%, var(--fondo) 62%);
}

.card {
  position: relative;
  width: min(760px, 100%);
  background: var(--carta);
  border-radius: 22px;
  padding: clamp(10px, 2.6vh, 20px) clamp(12px, 3vw, 22px) clamp(10px, 2.4vh, 18px);
  box-shadow:
    0 0 0 1px var(--bordo),
    0 1px 1px rgba(36, 28, 18, 0.04),
    0 4px 10px -4px rgba(36, 28, 18, 0.06),
    0 26px 50px -26px rgba(36, 28, 18, 0.22);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vh, 14px);
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 30%);
  mask: linear-gradient(#000, #000) content-box exclude, linear-gradient(#000, #000);
}

.head { display: flex; align-items: center; gap: 10px; }
.brand {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; font-stretch: 112%; letter-spacing: 0.01em;
}
.brand svg { width: 15px; height: 15px; fill: none; stroke: var(--testo); stroke-width: 1.4; stroke-linecap: round; }
.head__title {
  font-size: clamp(13px, 2.2vh, 15px); font-weight: 500; font-stretch: 100%; color: var(--testo-2);
  padding-left: 10px; border-left: 1px solid var(--linea);
}
.head__meta { margin-left: auto; font-family: "JetBrains Mono Variable", ui-monospace, monospace; font-size: 11px; color: var(--testo-3); }

.body { display: grid; grid-template-columns: minmax(0, 1fr) clamp(150px, 26%, 200px); gap: clamp(10px, 2vw, 18px); }

/* the photo, the grey veil over the other colours, the marker and the loupe */
.photo {
  position: relative; border-radius: 14px; overflow: hidden;
  aspect-ratio: 3 / 2; max-height: 58vh;
  background: #ddd;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 10px 24px -16px rgba(30, 20, 10, 0.35);
  cursor: crosshair;
  touch-action: none;
}
.photo__img, .photo__veil { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.photo__veil { opacity: 0; pointer-events: none; }
.photo::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.mark { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; opacity: 0; }
.mark__ring, .mark__dot { position: absolute; left: 0; top: 0; border-radius: 50%; transform: translate(-50%, -50%); }
.mark__ring {
  width: 30px; height: 30px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px var(--accento), 0 4px 12px rgba(0, 0, 0, 0.28);
}
.mark__dot { width: 5px; height: 5px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }

.loupe { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; opacity: 0; }
.loupe__px, .loupe__cell { position: absolute; left: 0; top: 0; border-radius: 50%; transform: translate(-50%, -50%); }
.loupe__px {
  width: clamp(76px, 13vh, 104px); height: clamp(76px, 13vh, 104px);
  image-rendering: pixelated;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 10px 26px -6px rgba(0, 0, 0, 0.4);
  background: #888;
}
.loupe__cell {
  width: 10px; height: 10px; border-radius: 2px;
  box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(0, 0, 0, 0.35);
}
.loupe__chip {
  position: absolute; left: 0; top: calc(clamp(76px, 13vh, 104px) / 2 + 8px); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 5px; border-radius: 999px;
  background: rgba(20, 18, 16, 0.86); color: #fff;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.loupe--su .loupe__chip { top: auto; bottom: calc(clamp(76px, 13vh, 104px) / 2 + 8px); }
.loupe__sw { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }

.hex { font-family: "JetBrains Mono Variable", ui-monospace, monospace; font-size: 11.5px; letter-spacing: 0.02em; display: inline-flex; }
.hex .c { display: inline-block; overflow: hidden; height: 1.25em; line-height: 1.25em; vertical-align: top; }
.hex .c > span { display: block; }

.copied {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px 5px 8px; border-radius: 999px;
  background: #fff; color: var(--testo); font-size: 12px; font-weight: 550;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 8px 18px -8px rgba(0, 0, 0, 0.35);
  opacity: 0; pointer-events: none;
}
.copied svg { width: 13px; height: 13px; fill: none; stroke: var(--accento); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* the five swatches */
.swatches { list-style: none; display: flex; flex-direction: column; gap: clamp(4px, 1vh, 7px); min-height: 0; }
.swatches > li { flex: 1 1 0; min-height: 0; display: flex; }
.sw {
  position: relative; flex: 1 1 0; min-height: 0; width: 100%;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px;
  padding: clamp(4px, 1vh, 7px) 8px clamp(4px, 1vh, 7px) clamp(4px, 1vh, 7px);
  border-radius: 12px; cursor: pointer; text-align: left;
  outline: none;
}
.sw__bg { position: absolute; inset: 0; border-radius: inherit; background: #f4f1ec; opacity: 0; }
.sw__chip {
  position: relative; width: clamp(26px, 6vh, 40px); aspect-ratio: 1; border-radius: 9px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.25);
}
.sw__chip::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 45%);
}
.sw__txt { position: relative; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sw__name { font-size: clamp(11px, 1.7vh, 12.5px); font-weight: 560; font-stretch: 104%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw .hex { color: var(--testo-2); font-size: clamp(10px, 1.55vh, 11.5px); }
.sw__pct { position: relative; font-family: "JetBrains Mono Variable", ui-monospace, monospace; font-size: 10.5px; color: var(--testo-3); }
.sw__line { position: absolute; left: 6px; right: 6px; bottom: 2px; height: 1.5px; border-radius: 2px; background: var(--accento); transform: scaleX(0); transform-origin: left; }
.sw:focus-visible .sw__bg { opacity: 1; box-shadow: 0 0 0 2px var(--accento); }

.foot { display: flex; align-items: center; }
.foot__tip { display: inline-flex; align-items: center; gap: 6px; font-size: clamp(10.5px, 1.6vh, 12px); color: var(--testo-3); }
.foot__tip svg { width: 13px; height: 13px; fill: none; stroke: var(--testo-3); stroke-width: 1.3; stroke-linejoin: round; }

.ptr {
  position: fixed; left: 0; top: 0; width: 22px; height: 22px; z-index: 5;
  pointer-events: none; opacity: 0;
  fill: var(--testo); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  transform-origin: 5px 3px;
}

/* narrow and tall boxes: the swatches go under the photo, in a row */
@media (max-width: 600px), (max-aspect-ratio: 1/1) {
  .card { width: min(420px, 100%); }
  .body { grid-template-columns: 1fr; }
  .photo { max-height: 40vh; aspect-ratio: auto; height: min(40vh, calc((100vw - 52px) * 0.62)); }
  .swatches { flex-direction: row; gap: 5px; }
  .sw { grid-template-columns: 1fr; justify-items: center; gap: 3px; padding: 5px 2px 7px; text-align: center; }
  .sw__chip { width: clamp(24px, 6.5vh, 40px); }
  .sw__name, .sw__pct { display: none; }
  .sw .hex { font-size: 9.5px; }
  .head__title { display: none; }
}
@media (max-height: 470px) {
  .foot { display: none; }
}
@media (min-width: 1100px) and (min-height: 760px) {
  .card { width: min(900px, 100%); }
}
