/* The file tree: a light explorer on a white page, the item chosen in soft blue. */
:root {
  --page: #ffffff;          /* the page */
  --panel: #fbfaf8;
  --ink: #1f1e1b;
  --muted: #8a877f;
  --line: #e9e6df;
  --guide: #dcd8cf;         /* the lines that hang the files from their folder */
  --mark: #e3ecff;          /* the item chosen */
  --mark-ink: #1f4fd1;
  --folder: #f2c14e;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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

/* the panel hangs from the top: it grows and shrinks downwards as the folders open and close, and never jumps */
.stage {
  min-height: 100svh;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: max(28px, 9vh) 16px 28px;
}

.files {
  width: min(360px, 100%);
  padding: 16px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 20px 40px -30px rgba(31, 30, 27, 0.3);
}

.files__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 10px;
}

.files__title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.files__new {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 6px 7px;
  border: 0;
  border-radius: 9px;
  background: #efece6;
  color: var(--ink);
  font: 650 13px 'Encode Sans Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 0.2s;
}

@media (hover: hover) {
  .files__new:hover {
    background: #e6e2d9;
  }
}

.files__new svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the tree */
.tree {
  position: relative;
}

.tree__root {
  outline: none;
}

/* the one highlight, moved by the script under the item chosen */
.tree__mark {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  border-radius: 9px;
  background: var(--mark);
  opacity: 0;
  pointer-events: none;
}

.tree__root,
.tree ul {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree ul ul {
  margin-left: 15px;
}

/* the line that hangs the files from their folder */
.tree ul ul::before {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 6px;
  left: 3px;
  border-left: 1.5px solid var(--guide);
  transform-origin: 50% 0;
  transform: scaleY(var(--hang, 1));
}

.tree [role='group'] {
  overflow: hidden;
}

.tree [role='group'][hidden] {
  display: none;
}

.node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px 0 4px;
  border-radius: 9px;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.node.is-on {
  color: var(--mark-ink);
  font-weight: 650;
}

.node__chev {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.node__chev--none {
  visibility: hidden;
}

.node__icon {
  flex: none;
  width: 18px;
  height: 18px;
  overflow: visible;
}

.node__name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the caret while a new name writes itself */
.node__caret {
  display: inline-block;
  width: 1.5px;
  height: 15px;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--mark-ink);
}

/* with the keys the highlight wears the ring of the focus, so the ring travels with it */
.tree:has(.tree__root:focus-visible) .tree__mark {
  box-shadow: inset 0 0 0 2px var(--mark-ink);
}

html[data-using='pointer'] .tree:has(.tree__root:focus-visible) .tree__mark {
  box-shadow: none;
}

.files__new:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
