/* The game piece tab bar: a green felt bar alone on a white page, with the names and the icons printed on the felt
   in a pale green, and an ivory game piece on the tab you are on, its icon carved in the top. */
:root {
  --page: #ffffff;          /* the page */
  --felt: #0d5341;          /* the felt of the bar */
  --felt-deep: #083b2e;     /* the felt in the shade of the bar's rim */
  --print: #9ccbb8;         /* the icons and names printed on the felt */
  --print-hover: #d2ebe0;   /* a tab under the pointer */
  --name-on: #f7f0e1;       /* the name of the tab you are on */
  --ivory: #f2e9d6;         /* the top of the game piece */
  --ivory-side: #d3c19c;    /* its side, ridged */
  --carve: #1b4637;         /* the icon carved in the piece */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

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

/* ---------------------------------------------------------------- the bar */
/* as wide as a phone's tab bar, never wider than 420 pixels nor than the screen */
.bar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(420px, 100%);
  height: 70px;
  padding: 0 6px;
  border-radius: 24px;
  /* felt: a fine fuzz of light and dark fibres over the green, a little brighter where the lamp falls */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.25 .7' numOctaves='3' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 .92 1.1 0 0 0 -.5'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23f)' opacity='.2'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 .05 0 0 0 0 .03 0 1.2 0 0 -.55'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23g)' opacity='.35'/%3E%3C/svg%3E"),
    radial-gradient(120% 140% at 30% 0%, color-mix(in srgb, var(--felt) 86%, #ffffff) 0%, var(--felt) 55%, var(--felt-deep) 100%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.3),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(6, 40, 31, 0.2),
    0 16px 28px -14px rgba(6, 46, 35, 0.55),
    0 4px 10px -4px rgba(6, 46, 35, 0.22);
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.tab {
  display: grid;
  justify-items: center;
  align-content: start;
  padding: 14px 0 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--print);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.2s ease-out;
}

/* the icon printed on the felt: its wrapper springs back when the piece leaves it (the script), the icon inside
   answers the pointer (here) */
.tab__print {
  display: block;
  width: 24px;
  height: 24px;
}

.tab__icon {
  display: block;
  width: 24px;
  height: 24px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.tab__label {
  margin-top: 9px;
  font-size: 11px;
  font-weight: 540;
  letter-spacing: 0.015em;
  line-height: 13px;
  white-space: nowrap;
  transition: color 0.25s ease-out, font-weight 0.3s ease-out;
}

/* the name of the tab the piece stands on: lit and heavier (the typeface's weight axis) */
.tab.is-lit .tab__label {
  color: var(--name-on);
  font-weight: 720;
}

.tab.is-lit {
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .tab:not(.is-lit):hover {
    color: var(--print-hover);
  }

  .tab:not(.is-lit):hover .tab__icon {
    transform: translateY(-1px);
  }
}

.tab:active .tab__icon {
  transform: scale(0.9);
  transition: transform 0.08s ease-out;
}

.tab:focus-visible {
  outline: 2px solid var(--name-on);
  outline-offset: -4px;
}

html[data-using='pointer'] .tab:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the shadow and the piece */
/* the shadow falls on the felt only: its layer is cut to the bar */
.bar__shade {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.bar__shadow {
  position: absolute;
  left: 0;
  top: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(2, 22, 16, 0.62) 0%, rgba(2, 22, 16, 0.42) 62%, rgba(2, 22, 16, 0.14) 86%, rgba(2, 22, 16, 0) 100%);
  will-change: transform, opacity;
}

/* the piece: placed and lifted by the script; its body turns in 3D inside it */
.piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 38px;
  height: 38px;
  perspective: 480px;
  pointer-events: none;
  will-change: transform;
}

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

/* the side of the piece: thin discs stacked between the two faces, a ridge every other one */
.piece__layer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ivory-side);
}

.piece__layer:nth-child(even) {
  background: color-mix(in srgb, var(--ivory-side) 78%, #5c4a2a);
}

.piece__band {
  position: absolute;
  left: 50%;
  top: 0;
  width: 8px;
  height: 100%;
  margin-left: -4px;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(70, 52, 20, 0.45), rgba(255, 250, 235, 0.25) 30%, rgba(255, 250, 235, 0.1) 55%, rgba(70, 52, 20, 0.5)),
    repeating-linear-gradient(90deg, var(--ivory-side) 0 1px, color-mix(in srgb, var(--ivory-side) 78%, #5c4a2a) 1px 2px);
}

.piece__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--ivory) 55%, #ffffff) 0%, var(--ivory) 46%, color-mix(in srgb, var(--ivory) 84%, #8d7446) 100%);
  box-shadow: inset 0 0 0 1px rgba(110, 86, 44, 0.28);
}

.piece__face svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* the groove round the top, and the carved icon: a dark cut with a lit lip on the side away from the light */
.piece__groove {
  fill: none;
  stroke: color-mix(in srgb, var(--ivory-side) 80%, #6b5532);
  stroke-width: 1;
}

.piece__lip,
.piece__cut {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.piece__lip {
  stroke: #fffaf0;
  stroke-width: 2.1;
  opacity: 0.9;
}

.piece__cut {
  stroke: var(--carve);
  stroke-width: 2;
}

.piece__ring {
  stroke-width: 1.1;
}

.piece__lip .piece__ring {
  stroke: rgba(255, 251, 240, 0.85);
}

.piece__cut .piece__ring {
  stroke: color-mix(in srgb, var(--ivory-side) 70%, #5c4a2a);
}

/* the light on the top as it tilts: brighter turned to the lamp, darker turned away (set by the script) */
.piece__light {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
