/* The folding sidebar: a light dashboard sidebar whose names fold away like paper concertinas. */
:root {
  --page: #ffffff;          /* the page */
  --bar: #fbfbfc;           /* the sidebar */
  --line: #e7e7ec;          /* its edge */
  --ink: #18181d;           /* the page chosen */
  --muted: #5f6070;         /* the other pages */
  --accent: #4b45d6;        /* the icon of the page chosen, and the badge */
  --mark: #ecebfd;          /* the ground under the page chosen */
  --hover: #f1f1f5;         /* a page pointed at */
  --tip: #1d1d24;           /* the tag beside a folded icon */
  --open: 236px;            /* the width of the open bar */
  --shut: 64px;             /* the width of the folded bar */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

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

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

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

.fs-wrap {
  position: relative;
  /* room for the tag beside the folded bar, so the whole thing stays centred either way */
  width: calc(var(--open) + 8px);
}

.fs {
  position: relative;
  width: var(--open);
  padding: 10px;
  border-radius: 18px;
  background: var(--bar);
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 1px 2px rgba(20, 20, 40, 0.05),
    0 24px 48px -28px rgba(20, 20, 40, 0.3);
  overflow: hidden;
}

.fs__head {
  display: flex;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.fs__toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.fs__toggle svg,
.fs__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

@media (hover: hover) {
  .fs__toggle:hover {
    background: var(--hover);
    color: var(--ink);
  }
}

.fs__toggle:active {
  transform: scale(0.94);
}

.fs__body {
  position: relative;
}

.fs__mark {
  position: absolute;
  left: 0;
  top: 0;
  height: 44px;
  border-radius: 12px;
  background: var(--mark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}

.fs__list {
  position: relative;
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fs__item {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  padding-left: 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.25s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.fs__icon {
  flex: none;
  transition: color 0.25s ease, transform 0.15s ease;
}

.fs__item[aria-current='page'] {
  --row: var(--mark);
  color: var(--ink);
}

.fs__item[aria-current='page'] .fs__icon {
  color: var(--accent);
}

@media (hover: hover) {
  .fs__item:not([aria-current='page']):hover {
    --row: var(--hover);
    background: var(--hover);
    color: var(--ink);
  }
}

.fs__item:active .fs__icon {
  transform: scale(0.9);
}

.fs__toggle:focus,
.fs__item:focus {
  outline: none;
}

.fs__toggle:focus-visible,
.fs__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* the name, for screen readers; the eye sees the folding strip the script makes of it */
.fs__sr,
.fs__label.is-split {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the folding strips */
/* a name is cut into panels, each nested in the one before and hinged on its left edge: turning them the opposite
   way one after the other closes the strip like a concertina, behind the icon */
.fs__fold {
  position: relative;
  flex: none;
  height: 28px;
  margin-left: 12px;
  perspective: 420px;
}

.fs__panel {
  position: absolute;
  top: 0;
  height: 100%;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}

.fs__face {
  position: absolute;
  inset: 0 -0.6px 0 0;
  overflow: hidden;
  backface-visibility: hidden;
  /* each panel is a slip of the row's own ground, so the shading reads as paper */
  background: var(--row, var(--bar));
}

.fs__panel.is-last > .fs__face {
  right: 0;
}

.fs__face > span {
  position: absolute;
  top: 0;
  line-height: 28px;
}

.fs__shade {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

/* a panel turned to the right faces away from the light, one turned to the left catches it */
.fs__panel--away > .fs__face > .fs__shade {
  background: linear-gradient(to right, rgba(20, 20, 40, 0.03), rgba(20, 20, 40, 0.2));
}

.fs__panel--toward > .fs__face > .fs__shade {
  background: linear-gradient(to right, rgba(255, 255, 255, 0.7), rgba(20, 20, 40, 0.05));
}

.fs__badge {
  position: absolute;
  left: 0;
  top: 50%;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-top: -10px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bar);
  transform-origin: 50% 50%;
}

/* ---------------------------------------------------------------- the tag beside a folded icon */
.fs__tip {
  position: absolute;
  left: 0;
  top: 0;
  height: 32px;
  margin-top: -16px;
  perspective: 420px;
  pointer-events: none;
  visibility: hidden;
  filter: drop-shadow(0 6px 10px rgba(20, 20, 40, 0.22));
  z-index: 2;
  font-size: 13.5px;
  font-weight: 520;
  white-space: nowrap;
}

.fs__tip .fs__face {
  background: var(--tip);
  color: #ffffff;
}

.fs__tip .fs__face > span {
  line-height: 32px;
}

.fs__tip .fs__panel:first-child > .fs__face {
  border-radius: 8px 0 0 8px;
}

.fs__tip .fs__panel.is-last > .fs__face {
  border-radius: 0 8px 8px 0;
}

.fs__tip .fs__panel--away > .fs__face > .fs__shade {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.55));
}

.fs__tip .fs__panel--toward > .fs__face > .fs__shade {
  background: linear-gradient(to right, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.1));
}

/* the little point of the tag, towards the icon */
.fs__tip::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 2px;
  background: var(--tip);
  transform: rotate(45deg);
  opacity: var(--point, 1);
}
