/* The single thread tab bar: a pale card alone on a white page, with one woollen thread drawn across it by the script.
   The thread, its twist and its red dyed stretch are an SVG laid over the five buttons; the colours are here. */
:root {
  --page: #ffffff;                    /* the page */
  --card: #fbf8f3;                    /* the bar, a warm off-white card */
  --wool: #8a7b6d;                    /* the undyed thread */
  --wool-twist: #5e5146;              /* the twist marks on it */
  --dye: #c23f2b;                     /* the stretch dyed madder red */
  --dye-twist: #84230f;               /* the twist marks on the red */
  --name: #a0968c;                    /* the names under the thread */
  --name-on: #2a241f;                 /* the name of the tab you are on */
  --ring: #2a241f;                    /* the keyboard focus */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--name-on);
  font-family: 'Instrument Sans Variable', 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- 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, minmax(0, 1fr));
  width: min(420px, 100%);
  height: 68px;
  padding: 0 6px;
  border-radius: 22px;
  background: var(--card);
  box-shadow:
    inset 0 0 0 1px rgba(60, 40, 20, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(60, 40, 20, 0.06),
    0 14px 30px -16px rgba(60, 40, 20, 0.28);
  -webkit-tap-highlight-color: transparent;
}

/* the thread: one SVG over the whole bar, cut at its rounded edges and fading out at both ends */
.yarn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
}

.yarn path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.yarn__shade {
  stroke: rgba(70, 45, 20, 0.12);
  stroke-width: 3.4;
}

.yarn__thread {
  stroke: var(--wool);
  stroke-width: 2.3;
}

.yarn__twist {
  stroke: var(--wool-twist);
  stroke-width: 0.8;
  stroke-linecap: butt;
  opacity: 0.55;
}

.yarn__dye {
  stroke: var(--dye);
  stroke-width: 2.6;
}

.yarn__dye-twist {
  stroke: var(--dye-twist);
  stroke-width: 0.85;
  stroke-linecap: butt;
  opacity: 0.6;
}

/* ---------------------------------------------------------------- the tabs */
/* the buttons hold only their names: the icons are the thread's */
.tab {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: end;
  margin: 0;
  padding: 0 0 9px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--name);
  font: inherit;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.tab__name {
  display: block;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variation-settings: 'wdth' 92;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.3s ease, font-weight 0.3s ease;
}

.tab[aria-current='page'] {
  color: var(--name-on);
}

.tab[aria-current='page'] .tab__name {
  font-weight: 620;
}

@media (hover: hover) and (pointer: fine) {
  .tab:not([aria-current='page']):hover {
    color: color-mix(in srgb, var(--name) 45%, var(--name-on));
  }
}

/* the focus, from the keyboard only: a thin ring round the whole column */
.tab::after {
  content: '';
  position: absolute;
  inset: 7px 3px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1.5px var(--ring);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.tab:focus-visible::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tab__name {
    transition: color 0.2s ease;
  }
}
