@property --divider {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}

html {
  overflow-y: scroll;
  scrollbar-color: oklch(0.4 0.02 264) #15181d;
}

body {
  margin: 0;
  scrollbar-color: auto;
}

nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--bar);
  padding-inline: 2rem;
  font: 1.125rem/1.6 system-ui, sans-serif;
  color: #eee;
  background: #222;
}

:root {
  --bar: 3.8rem;
  --sweep: 1.2s cubic-bezier(0.65, 0, 0.35, 1);
  --slide: 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

workspace {
  --files: 19rem;
  --diffs: 32rem;
  position: relative;
  display: grid;
  grid-template-columns: 0 minmax(0, 1fr) 0;
  min-height: calc(100vh - var(--bar));
}

workspace[settled] {
  transition: grid-template-columns var(--slide);
}

workspace[settled] > :is(file-tree, diff-list) {
  transition: visibility var(--slide);
}

workspace[diffs] {
  grid-template-columns: 0 minmax(0, 1fr) var(--diffs);
}

workspace[diffs][files] {
  grid-template-columns: var(--files) minmax(0, 1fr) var(--diffs);
}

workspace:not([files]) > file-tree,
workspace:not([diffs]) > diff-list {
  visibility: hidden;
}

workspace:not([files]) stage > button {
  display: none;
}

stage > button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.5rem;
  aspect-ratio: 1;
  border: 2px solid #222;
  border-radius: 50%;
  color: #fff;
  background: #222;
  cursor: pointer;
}

workspace[code] stage > button {
  color: #222;
  background: #fff;
}

stage > codie {
  grid-area: 1 / 1;
  contain: size;
  border-radius: 0;
  font-size: 0.8125rem;
}

workspace[code] stage > component:last-of-type {
  display: none;
}

file-tree,
diff-list {
  --green: oklch(0.76 0.13 145);
  --red: oklch(0.72 0.15 27);
  display: flex;
  flex-direction: column;
  contain: size;
  overflow: hidden;
  color: #eee;
  background: #222;
}

pane-title {
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #333;
  font: 600 0.875rem/1.6 system-ui, sans-serif;
}

pane-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  background-color: #222;
}

file-tree {
  align-items: flex-end;
}

file-tree > * {
  width: var(--files);
}

diff-list > * {
  width: var(--diffs);
}

file-tree > pane-body {
  gap: 0.25rem;
}

diff-list > pane-body {
  gap: 1rem;
  padding: 0;
}

file {
  display: flex;
  font: 0.875rem/1.6 ui-monospace, monospace;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

folder,
files-placeholder {
  font: 0.875rem/1.6 ui-monospace, monospace;
  padding: 0.5rem 0.75rem;
}

folder ~ file,
files-placeholder {
  margin-left: 1rem;
}

file[aria-current="page"],
file:hover {
  background: #333;
}

diff-list {
  position: absolute;
  grid-area: 1 / 3;
  inset: 0;
}

nav :is(a, icon) {
  color: #999;
  text-decoration: none;
}

nav a[aria-current="page"] {
  color: inherit;
}

stage {
  position: relative;
  display: grid;
}

stage > component {
  display: block;
  grid-area: 1 / 1;
  background: #fff;
}

stage > component > step-body {
  display: block;
}

stage > component > step-body main {
  min-height: calc(100vh - var(--bar));
  padding-inline: 2rem;
}

stage > component > step-body sidebar {
  height: auto;
  max-height: 100dvh;
}

stage > component > step-body:not([stylecheat]) main {
  display: flow-root;
}

stage[forward] > component:last-of-type,
stage[back] > component:last-of-type {
  position: relative;
  animation: sweep var(--sweep);
}

@keyframes sweep {
  from {
    --divider: 0;
  }
}

stage[forward] > component:last-of-type::before,
stage[back] > component:last-of-type::before {
  content: '';
  position: absolute;
  inset-block: 0;
  width: 2px;
  background: #222;
}

stage[forward] > component:last-of-type {
  clip-path: inset(0 0 0 calc((1 - var(--divider)) * 100%));
}

stage[forward] > component:last-of-type::before {
  left: calc((1 - var(--divider)) * 100%);
}

stage[back] > component:last-of-type {
  clip-path: inset(0 calc((1 - var(--divider)) * 100%) 0 0);
}

stage[back] > component:last-of-type::before {
  right: calc((1 - var(--divider)) * 100%);
}
