/* The rewinding breadcrumbs: the path bar of a studio's file drive, alone on a white page. The path is a tape that
   runs under the chevrons, and the yellow hook at its end is the case's hook of a tape measure. */
:root {
  --page: #ffffff;          /* the page */
  --bar: #f1f2f4;           /* the bar under the path */
  --bar-edge: #e2e4e8;      /* its edge */
  --ink: #15171b;           /* the folder you are in */
  --muted: #6c717a;         /* the folders above it */
  --chevron: #a6abb3;       /* the chevrons between the folders */
  --hook: #ffd12e;          /* the hook at the end of the path */
  --hook-edge: #d6a400;     /* the hook's shaded lower edge */
  --hook-down: #f6c419;     /* the hook pressed in, while the folders inside show */
  --hook-ink: #15171b;      /* the chevron on the hook */
  --hook-off: #e1e3e7;      /* the hook when the folder has no folders inside */
  --kid: #ffffff;           /* a folder offered inside the current one */
  --kid-ink: #4c515a;       /* its name */
  --ring: #2b62f0;          /* the outline of the keyboard focus */
}

* {
  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: 'Albert Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* the room the path can take; the bar hugs the path inside it, from the left */
.frame {
  width: min(600px, 100%);
}

/* ---------------------------------------------------------------- the bar */
.crumbs {
  position: relative;
  height: 56px;
  -webkit-tap-highlight-color: transparent;
}

/* until the script has laid the path out, nothing shows (no flash of the path before it unrolls) */
.crumbs:not(.is-ready) {
  visibility: hidden;
}

/* the bar itself: its right edge follows the hook, set by the script */
.crumbs__case {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 18px;
  background: var(--bar);
  box-shadow:
    inset 0 0 0 1px var(--bar-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(20, 22, 28, 0.05),
    0 12px 26px -16px rgba(20, 22, 28, 0.28);
  pointer-events: none;
}

/* the path, the hook and the folders inside: on a narrow screen it scrolls sideways when it is unrolled */
.crumbs__strip {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 14px 0 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  --fade-l: 0px;
  --fade-r: 0px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}

.crumbs__strip::-webkit-scrollbar {
  display: none;
}

.crumbs__strip.is-after {
  --fade-l: 22px;
}

.crumbs__strip.is-before {
  --fade-r: 28px;
}

.crumbs__list {
  display: flex;
  flex: none;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------------------------------------------------------------- a folder */
.crumb {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  transition: opacity 0.22s ease;
}

.crumb[hidden] {
  display: none;
}

.crumb__link {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 5px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 520;
  letter-spacing: -0.005em;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.crumb__link[aria-current='page'] {
  color: var(--ink);
  font-weight: 520;
  cursor: default;
}

.crumb__icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the name, and the letters the script lays over it while the tape runs */
.crumb__name {
  position: relative;
  display: block;
  transition: transform 0.16s ease-out;
}

.crumb__text {
  display: block;
  font-variant-ligatures: none;
}

.crumb__text.is-split {
  visibility: hidden;
}

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

.crumb__letter {
  position: absolute;
  top: 0;
  white-space: pre;
  will-change: transform;
}

/* the folders a pointed link would leave behind: they fade back and lean towards its chevron */
.crumb.is-leaving {
  opacity: 0.42;
}

/* the chevron between two folders: the slot the tape slips under */
.crumb__sep {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--chevron);
  transition: color 0.2s ease;
}

.crumb__sep svg {
  width: 24px;
  height: 24px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the chevron the tape is going into, or would go into, darkens */
.crumb.is-slot .crumb__sep {
  color: var(--ink);
}

/* the last folder has the hook instead of a chevron */
.crumb:last-child .crumb__sep {
  display: none;
}

/* on a narrow screen the first chevron holds the folders in between, one chevron each: this button shows them */
.crumb__spool {
  position: absolute;
  top: 50%;
  right: -2px;
  width: 28px;
  height: 36px;
  margin: -18px 0 0;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.crumb__spool[hidden] {
  display: none;
}

/* a bigger target for a finger */
.crumb__spool::before {
  content: '';
  position: absolute;
  inset: -4px -6px;
}

/* ---------------------------------------------------------------- the hook */
/* in the flow it is as wide as a chevron, so it lands exactly where the chevron was */
.hook {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 7px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--hook-ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* a 44 pixel target for a finger */
.hook::before {
  content: '';
  position: absolute;
  inset: -10px;
}

.hook__body {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  transition: transform 0.18s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.hook__plate {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 8px;
  background: var(--hook);
  box-shadow:
    inset 0 -2px 0 var(--hook-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 1px 1.5px rgba(110, 80, 0, 0.22),
    0 5px 12px -5px rgba(110, 80, 0, 0.4);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.hook__chevron {
  position: relative;
  width: 24px;
  height: 24px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color 0.2s ease;
}

/* open: the hook is pressed in, its chevron turns down (the script bends it), and the folders inside stand out of it */
.hook[aria-expanded='true'] .hook__plate {
  background: var(--hook-down);
  box-shadow:
    inset 0 2px 3px rgba(110, 80, 0, 0.32),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 1px rgba(110, 80, 0, 0.1);
}


/* a folder with no folders inside: the hook is grey */
.hook[aria-disabled='true'] {
  color: var(--chevron);
  cursor: default;
}

.hook[aria-disabled='true'] .hook__plate {
  background: var(--hook-off);
  box-shadow: inset 0 -2px 0 rgba(20, 22, 28, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.hook:active:not([aria-disabled='true']) .hook__body {
  transform: scale(0.9);
  transition-duration: 0.08s;
}

@media (hover: hover) and (pointer: fine) {
  /* pointed at, the hook leans out a little, ready to be pulled */
  .hook:hover:not([aria-disabled='true']):not(:active) .hook__body {
    transform: translateX(2px);
  }

  .crumb__link:not([aria-current='page']):hover {
    color: var(--ink);
  }

  .kid:hover {
    color: var(--ink);
    border-color: rgba(20, 22, 28, 0.16);
  }

  .crumb--root:has(.crumb__spool:hover) .crumb__sep {
    color: var(--ink);
  }
}

.crumb__link:active:not([aria-current='page']) .crumb__name {
  transform: scale(0.96);
}

/* ---------------------------------------------------------------- the folders inside */
/* they come out from under the hook: anything left of the box's edge is under the hook */
.kids {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding-right: 2px;
  clip-path: inset(-14px -40px -14px -10px);
}

.kids[hidden] {
  display: none;
}

.kids__tape {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kid {
  flex: none;
  height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(20, 22, 28, 0.09);
  border-radius: 9px;
  background: var(--kid);
  color: var(--kid-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 520;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 1.5px rgba(20, 22, 28, 0.06), 0 3px 8px -5px rgba(20, 22, 28, 0.18);
  transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.kid:active {
  background: #f6f7f8;
}

.kid.is-picked {
  color: var(--ink);
  border-color: rgba(20, 22, 28, 0.22);
}

/* ---------------------------------------------------------------- keys */
a:focus,
button:focus {
  outline: none;
}

.crumb__link:focus-visible,
.kid:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -1px;
}

.crumb__spool:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -4px;
}

.hook:focus-visible .hook__plate {
  box-shadow:
    inset 0 -2px 0 var(--hook-edge),
    0 0 0 2px var(--bar),
    0 0 0 4px var(--ring);
}

.hook[aria-expanded='true']:focus-visible .hook__plate {
  box-shadow: inset 0 2px 3px rgba(110, 80, 0, 0.32), 0 0 0 2px var(--bar), 0 0 0 4px var(--ring);
}

/* ---------------------------------------------------------------- narrow screens */
/* the first folder keeps only its icon */
@media (max-width: 560px) {
  .crumb--root .crumb__name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .crumb--root .crumb__link {
    gap: 0;
    padding: 0 6px;
  }
}

/* with less motion nothing moves: the presses do not shrink, things only fade */
@media (prefers-reduced-motion: reduce) {
  .hook:active:not([aria-disabled='true']) .hook__body,
  .crumb__link:active:not([aria-current='page']) .crumb__name {
    transform: none;
  }

  @media (hover: hover) {
    .hook:hover:not([aria-disabled='true']):not(:active) .hook__body {
      transform: none;
    }
  }
}
