:root {
  --paper: #ffffff;      /* the page */
  --ink: #141414;        /* the chosen country and the line */
  --muted: #9a9a9a;      /* the label, the days and the far faces of the drum */
  --hair: #e4e4e4;       /* the thin bands around the middle face */
  --accent: #ff4a1c;     /* the line that draws itself while the drum is open */
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo Variable", "Archivo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* the room the open drum needs above and below the line */
.frame {
  height: min(300px, 74vh);
  display: grid;
  place-items: center;
}

/* the select: label, value and days on one thin line; the drum opens over the value column */
.sel {
  --item: 40px;
  position: relative;
  width: min(380px, 88vw);
  height: 60px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  column-gap: 14px;
}

.sel__label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-variation-settings: "wdth" 100;
  font-weight: 500;
  white-space: nowrap;
}

.sel__field {
  all: unset;
  position: relative;
  height: 60px;
  display: flex;
  align-items: center;
  cursor: pointer;
  min-width: 0;
}

.sel__field:focus-visible { outline: none; }
.sel:has(.sel__field:focus-visible) .sel__line { background: var(--ink); height: 2px; }

.sel__value {
  display: block;
  overflow: hidden;
  height: var(--item);
  line-height: var(--item);
  white-space: nowrap;
}

.sel__value-in,
.sel__face {
  display: block;
  font-size: 23px;
  letter-spacing: -0.01em;
  font-weight: 760;
  font-variation-settings: "wdth" 100;
}

.sel__value-in { will-change: transform; }

.sel__days {
  display: block;
  overflow: hidden;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sel__days-in { display: block; }

.sel__chev {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.35s cubic-bezier(.3, 1.4, .5, 1);
}

.sel[data-open] .sel__chev { transform: rotate(180deg); }

/* the line under everything; while the drum is open it steps back and the accent draws itself under the middle face */
.sel__line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--ink);
}

.sel__ink {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + var(--item) / 2 - 0.5px);
  height: 2px;
  z-index: 1;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* the two hairlines that frame the middle face while the drum is open */
.sel__band {
  position: absolute;
  left: var(--col-left, 80px);
  right: 0;
  height: 1px;
  background: var(--hair);
  opacity: 0;
  pointer-events: none;
}

.sel__band--top { top: calc(50% - var(--item) / 2); }
.sel__band--bottom { top: calc(50% + var(--item) / 2); }

/* the drum: the faces sit on a cylinder around the value; only the ones turned towards us are drawn */
.sel__drum {
  position: absolute;
  left: var(--col-left, 80px);
  right: 0;
  top: 50%;
  height: 0;
  perspective: 900px;
  perspective-origin: 18% 50%;
  touch-action: none;
  z-index: 2;
}

.sel__drum[hidden] { display: none; }

.sel__roll {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.sel__face {
  position: absolute;
  left: 0;
  top: calc(var(--item) / -2);
  height: var(--item);
  line-height: var(--item);
  white-space: nowrap;
  backface-visibility: hidden;
  cursor: pointer;
  color: var(--ink);
  transform-origin: 0 50%;
  will-change: transform, opacity;
}

@media (hover: hover) {
  .sel__field:hover ~ .sel__chev { transform: translateY(2px); }
  .sel[data-open] .sel__field:hover ~ .sel__chev { transform: rotate(180deg); }
}

/* the phone: the same select, a little narrower type */
@media (max-width: 420px) {
  .sel { column-gap: 10px; }
  .sel__value-in, .sel__face { font-size: 20px; }
  .sel__days { display: none; }
}
